Add first-class Okta application-INI values to deployment_utils - #340
Open
willronchetti wants to merge 2 commits into
Open
Add first-class Okta application-INI values to deployment_utils#340willronchetti wants to merge 2 commits into
willronchetti wants to merge 2 commits into
Conversation
Extends build_ini_file_from_template and build_ini_stream_from_template with okta_issuer, okta_client, okta_scopes and okta_require_email_verified, bound to the OKTA_ISSUER, OKTA_CLIENT, OKTA_SCOPES and OKTA_REQUIRE_EMAIL_VERIFIED template substitutions. Each resolves from the explicit argument, then the corresponding ENCODED_OKTA_* environment variable, then a safe default, matching existing Auth0 precedence. OKTA_SCOPES defaults to empty so the consuming application picks its own scopes. OKTA_REQUIRE_EMAIL_VERIFIED is omitted from the generated file unless a boolean is actually supplied, so the application's secure default (require a verified email) applies; an unset, empty or unparseable value cannot turn that check off, and cannot break .ini generation either. There is deliberately no Okta secret: this is a public SPA using the Authorization Code flow with PKCE. Existing callers, Auth0 values and generated output are unchanged.
Coverage Report for CI Build 33664603284Coverage increased (+0.03%) to 74.667%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Retarget this branch's release metadata from 8.20.0 to the beta 8.19.0.1b1 so the Okta INI values can be consumed from PyPI before 8.20.0 is cut. No functional change: pyproject version and the matching top CHANGELOG heading only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds first-class Okta values to
dcicutils.deployment_utils, so a portal container can materialize Okta settings intoproduction.iniduring its existing one-time startup configuration step — the same path Auth0 already takes — instead of the running Pyramid application making its own Secrets Manager call.build_ini_file_from_templateandbuild_ini_stream_from_templatenow accept four new keyword arguments, bound to four new template substitutions:okta_issuerENCODED_OKTA_ISSUEROKTA_ISSUERokta_clientENCODED_OKTA_CLIENTOKTA_CLIENTokta_scopesENCODED_OKTA_SCOPESOKTA_SCOPESokta_require_email_verifiedENCODED_OKTA_REQUIRE_EMAIL_VERIFIEDOKTA_REQUIRE_EMAIL_VERIFIEDPrecedence matches Auth0: explicit argument, then the
ENCODED_*environment variable, then a safe default.Defaults, deliberately chosen
OKTA_SCOPESdefaults to empty, so the line is omitted and the consuming application applies its own scopes (openid email profile). Nothing is hardcoded upstream.OKTA_REQUIRE_EMAIL_VERIFIEDis omitted unless a boolean is actually supplied. This is a real tri-state, not truthiness: an explicitFalseargument does not fall through to the environment variable, and an absent, empty, or unparseable value renders as the empty string, whichIniFileManager.omittabledrops from the output entirely — so the application's secure default (require a verified email) applies. Unparseable input is omitted rather than raising, so a typo in configuration cannot break.inigeneration at container startup.IniFileManager.okta_require_email_verified_settingencodes this and is directly tested.No Okta secret
There is deliberately no
okta_secretargument and noOKTA_SECRETsubstitution. The portal's Okta integration is a public SPA using the Authorization Code flow with PKCE, which has no client secret. A test asserts against the signature that nookta-prefixed parameter other than the four above exists, and that a template referencing${OKTA_SECRET}is left unexpanded rather than being filled from the environment.Backward compatibility
All four arguments default to
None, so every existing caller is unaffected. Auth0 resolution, bindings, and generated output are untouched; a test renders the same template with and without Okta values and asserts theauth0.*lines are identical.main()/argparse is intentionally not changed — the consumer here is the container'sassume_identity.py, which setsENCODED_*variables and calls the builder directly.Tests
Seven new tests in
test/test_deployment_utils.pycover explicit arguments, environment-derived values, argument-over-environment precedence (including explicitFalse), all four substitutions in a rendered template, omission when Okta is absent or partial, Auth0 output unchanged, and the absence of any secret field.Verification
pytest test/test_deployment_utils.py(CI marker selection): 32 passed, 1 skippedpytest -m "static and not last": 4 passed, 1 xfailedflake8 dcicutilsandflake8 test --exclude=data_files: cleanRun in this repository's Poetry virtualenv (Python 3.12). The local
utils311pyenv environment could not be used: it has setuptools 83, sopkg_resourcesis absent anddeployment_utilswill not import there. Remaining failures in the broader local suite are all expired-AWS-SSO / credential errors intest_ff_utils,test_s3_utils,test_validation_utilsetc., unrelated to this change; none of those modules importdeployment_utils.Version set to the beta
8.19.0.1b1with a matching changelog heading, and published to PyPI as a pre-release from a tag on this branch's head so the portal can consume it before 8.20.0 is cut. This PR is not merged by that release.🤖 Generated with Claude Code