Skip to content

WIP: Automate creation of Okta service app#16

Open
tschuy wants to merge 6 commits into
indentapis:mainfrom
tschuy:main
Open

WIP: Automate creation of Okta service app#16
tschuy wants to merge 6 commits into
indentapis:mainfrom
tschuy:main

Conversation

@tschuy

@tschuy tschuy commented Oct 28, 2022

Copy link
Copy Markdown
Contributor

Comment thread main.tf
env = {
OKTA_DOMAIN = var.okta_domain
OKTA_TOKEN = var.okta_token
OKTA_DOMAIN = "${var.okta_prefix}.okta.com"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Convert this into a generated locals

Comment thread main.tf
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")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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 n value. Clean this up -- make them both vars, probably (and ignore changes as well).

Comment thread main.tf

resource "okta_app_oauth_api_scope" "indent-scopes" {
app_id = okta_app_oauth.indent.id
issuer = "https://${var.okta_prefix}.okta.com"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

use generated local for this

Comment thread variables.tf
sensitive = true
}

variable "okta_jwk_n" {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Comment thread scripts/jwk.rb
require 'openssl'
require 'json/jwt'
rsa_private = OpenSSL::PKey::RSA.generate 2048
File.write('./private.pem', rsa_private.to_pem)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

either all file output, or all env var.

Comment thread main.tf
provider "okta" {
org_name = var.okta_prefix
base_url = "okta.com"
api_token = var.okta_token

Copy link
Copy Markdown
Contributor Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant