Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create_user_assign_to_group mod #25

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions create_user_assign_to_group/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Create a user in Okta and assign to a group
karanpopat marked this conversation as resolved.
Show resolved Hide resolved

Create a user in Okta and assign to a group.

## Usage

- Add following required credentials to `flowpipe.fpvars`
- Okta domain and API token

- Start your Flowpipe server `flowpipe server`

- Create a user in Okta and add to a group. This step is an independent pipeline to create user and assign to a group e.g.

```
flowpipe pipeline run create_user_assign_to_group --arg first_name='Foo' --arg last_name='Bar' --arg email='[email protected]' --arg login='foo.bar' --arg password='password' --arg group_id='00g1x2x3x4x5x6x7x8x9'
```
81 changes: 81 additions & 0 deletions create_user_assign_to_group/create_user_assign_to_group.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
pipeline "create_user_assign_to_group" {
title = "Create User Assign Group"
description = "Create a user and assign it to a group."

param "api_token" {
description = "The personal api_token to authenticate to the Okta APIs."
type = string
default = var.api_token
}

param "domain" {
description = "The domain of your Okta account."
type = string
default = var.okta_domain
}

param "group_id" {
description = "The ID of the group."
type = string
default = var.group_id
}

param "first_name" {
description = "Given name of the user."
type = string
default = var.first_name
}

param "last_name" {
description = "The family name of the user."
type = string
default = var.last_name
}

param "email" {
description = "The primary email address of the user."
type = string
default = var.email
}

param "login" {
description = "The unique identifier for the user."
type = string
default = var.login
}

param "password" {
description = "Specifies the password for a user."
type = string
default = var.password
}

step "pipeline" "create_user" {
pipeline = pipeline.create_user
karanpopat marked this conversation as resolved.
Show resolved Hide resolved
args = {
first_name = param.first_name
last_name = param.last_name
email = param.email
login = param.login
password = param.password
}
}

step "pipeline" "assign_user" {
pipeline = pipeline.assign_user
karanpopat marked this conversation as resolved.
Show resolved Hide resolved
args = {
group_id = param.group_id
user_id = jsondecode(step.pipeline.create_user.user).id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the outputs of pipelines are wrapped in the attribute "output" right? does step.pipeline.create_user.user work here?

}
}

output "user" {
value = step.pipeline.create_user.response_body
description = "User details."
}

output "assignment" {
value = step.pipeline.assign_user.response_body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assign_user pipeline in okta mod does not have any outputs, will this work?

description = "Group assignment details for a user."
}
}
8 changes: 8 additions & 0 deletions create_user_assign_to_group/flowpipe.fpvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
domain = "<Domain>"
api_token = "<API Token>"
group_id = "<Group ID>"
first_name = "<First Name>"
last_name = "<Last Name>"
email = "<Email>"
login = "<Username>"
password = "<Password>"
14 changes: 14 additions & 0 deletions create_user_assign_to_group/mod.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod "create_user_assign_to_group" {
title = "Create User and Assign Group"
description = "Create a user in Okta and assign to a group."

require {
mod "github.com/turbot/flowpipe-mod-okta" {
version = "v0.0.2-rc.1"
args = {
api_token = var.api_token
domain = var.domain
karanpopat marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}
39 changes: 39 additions & 0 deletions create_user_assign_to_group/variables.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
variable "okta_domain" {
type = string
description = "The URL of the Okta domain. Exmaple1: 'https://dev-50078045.okta.com'"
karanpopat marked this conversation as resolved.
Show resolved Hide resolved
}

variable "api_token" {
type = string
description = "The Okta personal access api_token to authenticate to the okta APIs, e.g., '00B630jSCGU4jV4o5Yh4KQMAdqizwE2OgVcS7N9UHb'. Please see https://developer.okta.com/docs/guides/create-an-api-api_token/main/#oauth-2-0-instead-of-api-api_tokens for more information."
karanpopat marked this conversation as resolved.
Show resolved Hide resolved
}

variable "group_id" {
description = "The ID of the group."
type = string
}

variable "first_name" {
description = "Given name of the user."
type = string
}

variable "last_name" {
description = "The family name of the user."
type = string
}

variable "email" {
description = "The primary email address of the user."
type = string
}

variable "login" {
description = "The unique identifier for the user."
type = string
}

variable "password" {
description = "Specifies the password for a user."
type = string
}