-
Notifications
You must be signed in to change notification settings - Fork 2
WIP: Automate creation of Okta service app #16
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
base: main
Are you sure you want to change the base?
Changes from all commits
4141ce7
396a8b3
28d5a35
2ddd700
c1c9dfd
883bd78
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,29 +5,56 @@ terraform { | |
| region = "us-west-2" | ||
| key = "indent/terraform.tfstate" | ||
| } | ||
| } | ||
|
|
||
| # Configure the Okta Provider | ||
| provider "okta" { | ||
| org_name = var.okta_prefix | ||
| base_url = "okta.com" | ||
| api_token = var.okta_token | ||
| } | ||
|
|
||
| # Indent + Okta Integration | ||
|
|
||
| # Details: https://github.com/indentapis/integrations/tree/f494cef86094c3b40ac124e3159f5f3391c7e6c8/packages/stable/indent-integration-okta | ||
| # Last Change: https://github.com/indentapis/integrations/commit/f494cef86094c3b40ac124e3159f5f3391c7e6c8 | ||
| # Details: https://github.com/indentapis/integrations/tree/f0cea0e363f8950c7a217d186df6c377ed52e9d7/packages/stable/indent-integration-okta | ||
| # Last Change: https://github.com/indentapis/integrations/commit/f0cea0e363f8950c7a217d186df6c377ed52e9d7 | ||
|
|
||
| module "idt-okta-webhook" { | ||
| source = "git::https://github.com/indentapis/integrations//terraform/modules/indent_runtime_aws_lambda" | ||
| name = "idt-okta-webhook" | ||
| indent_webhook_secret = var.indent_webhook_secret | ||
| artifact = { | ||
| bucket = "indent-artifacts-us-west-2" | ||
| function_key = "webhooks/aws/lambda/okta-f494cef86094c3b40ac124e3159f5f3391c7e6c8-function.zip" | ||
| deps_key = "webhooks/aws/lambda/okta-f494cef86094c3b40ac124e3159f5f3391c7e6c8-deps.zip" | ||
| function_key = "webhooks/aws/lambda/okta-f0cea0e363f8950c7a217d186df6c377ed52e9d7-function.zip" | ||
| deps_key = "webhooks/aws/lambda/okta-f0cea0e363f8950c7a217d186df6c377ed52e9d7-deps.zip" | ||
| } | ||
| env = { | ||
| OKTA_DOMAIN = var.okta_domain | ||
| OKTA_TOKEN = var.okta_token | ||
| OKTA_DOMAIN = "${var.okta_prefix}.okta.com" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convert this into a generated locals |
||
| # OKTA_TOKEN = var.okta_token | ||
| OKTA_SLACK_APP_ID = var.okta_slack_app_id | ||
| OKTA_CLIENT_ID = var.okta_client_id | ||
| OKTA_PRIVATE_KEY = var.okta_private_key | ||
| OKTA_CLIENT_ID = okta_app_oauth.indent.id | ||
| OKTA_PRIVATE_KEY = file("./private.pem") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is generated by the jwk.rb script, which also sets a TF_VAR for the jwk |
||
| } | ||
| } | ||
|
|
||
| resource "okta_app_oauth" "indent" { | ||
| label = "indent_integration" | ||
| type = "service" | ||
| token_endpoint_auth_method = "private_key_jwt" | ||
| grant_types = ["client_credentials"] | ||
| response_types = ["token"] | ||
| pkce_required = true | ||
|
|
||
| jwks { | ||
| kty = "RSA" | ||
| kid = "SIGNING_KEY" | ||
| e = "AQAB" | ||
| n = var.okta_jwk_n | ||
| } | ||
| } | ||
|
|
||
| resource "okta_app_oauth_api_scope" "indent-scopes" { | ||
| app_id = okta_app_oauth.indent.id | ||
| issuer = "https://${var.okta_prefix}.okta.com" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use generated local for this |
||
| scopes = ["okta.groups.manage", "okta.users.manage"] | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| require 'openssl' | ||
| require 'json/jwt' | ||
| rsa_private = OpenSSL::PKey::RSA.generate 2048 | ||
| File.write('./private.pem', rsa_private.to_pem) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either all file output, or all env var. |
||
| rsa_private = OpenSSL::PKey::RSA.new rsa_private_string | ||
| puts rsa_private.public_key.to_jwk["n"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,25 @@ variable "okta_domain" { | |
| default = "" | ||
| sensitive = true | ||
| } | ||
| variable "okta_prefix" { | ||
| type = string | ||
| default = "" | ||
| sensitive = true | ||
| } | ||
|
|
||
| variable "okta_private_key" { | ||
| type = string | ||
| default = "" | ||
| sensitive = true | ||
| } | ||
|
|
||
| variable "okta_jwk_n" { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did it this way because it was easier to get working, but should fully flesh this out as the full jwk, or even the full pub/priv key and read fields from it at a time. |
||
| # just the `n` portion of the okta jwk; | ||
| # TF_VARS_okta_private_key="" scripts/jwk.rb | ||
| type = string | ||
| default = "" | ||
| sensitive = true | ||
| } | ||
|
|
||
| variable "okta_token" { | ||
| type = string | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the Number 1 thing here: we need to handle this gracefully: what happens when we delete the token?
Current thought is a runonce stage that sets up the
okta_app_oauth; we can then read the necessary values from state in the bucket without having to refresh it (and run into API rejections from token revocation).