thinkwork-cli 0.13.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -14
- package/dist/{api-client-4DZ266J5.js → api-client-4P4JZOBX.js} +3 -1
- package/dist/bowser-6Z6JFAIR.js +2822 -0
- package/dist/{chunk-Y2WHJECR.js → chunk-4OMDWYZQ.js} +5 -44
- package/dist/chunk-AD2NIWB5.js +6516 -0
- package/dist/chunk-DV3MRBR5.js +43 -0
- package/dist/chunk-EI5ZX7CN.js +522 -0
- package/dist/chunk-EUJ7X6YD.js +126 -0
- package/dist/chunk-GG5WKBOX.js +436 -0
- package/dist/chunk-I64EZSU5.js +358 -0
- package/dist/chunk-KMIJ5KGT.js +128 -0
- package/dist/chunk-MWQ7RO76.js +137 -0
- package/dist/chunk-OCPHU34C.js +996 -0
- package/dist/chunk-OLUQ4U2Z.js +1728 -0
- package/dist/chunk-XYM7PE2A.js +2264 -0
- package/dist/chunk-YQCYD6NE.js +3299 -0
- package/dist/cli.js +49156 -31257
- package/dist/commands/enterprise/templates/deploy-repo/scripts/apply-release.mjs +0 -1
- package/dist/commands/enterprise/templates/deploy-repo/scripts/smoke.mjs +0 -1
- package/dist/commands/enterprise/templates/deploy-repo/terraform/main.tf +0 -14
- package/dist/dist-es-2OTNTL4N.js +315 -0
- package/dist/dist-es-2XVAH4BQ.js +14726 -0
- package/dist/dist-es-3DPDUJAH.js +2000 -0
- package/dist/dist-es-BNZTBBVC.js +176 -0
- package/dist/dist-es-CD2RBDAC.js +88 -0
- package/dist/dist-es-I4FW57PS.js +88 -0
- package/dist/dist-es-KL7Y5NB2.js +377 -0
- package/dist/dist-es-KVFWJNDY.js +318 -0
- package/dist/dist-es-PS73DWNL.js +70 -0
- package/dist/dist-es-S3NZQFGT.js +170 -0
- package/dist/dist-es-SGCA4P32.js +48 -0
- package/dist/dist-es-WBM6J4RA.js +70 -0
- package/dist/dist-es-ZGVADYIF.js +485 -0
- package/dist/dist-es-ZKC2QKD2.js +377 -0
- package/dist/drizzle/0076_scheduled_jobs_marco_backfill.sql +2 -1
- package/dist/drizzle/0079_seed_tenant_customize_catalog.sql +1 -0
- package/dist/drizzle/0090_brain_schema_extraction.sql +10 -0
- package/dist/drizzle/0132_drop_computer_tables.sql +3 -0
- package/dist/drizzle/0160_compliance_event_types_plugins.sql +2 -0
- package/dist/drizzle/0214_think137_drop_judge_evidence_roi.sql +1 -0
- package/dist/drizzle/0216_drop_agent_loop_versions_goal_worker_policy.sql +1 -0
- package/dist/drizzle/0227_analyst_reader_role.sql +17 -20
- package/dist/drizzle/0230_analyst_rls.sql +28 -36
- package/dist/drizzle/0250_kg_schema_extraction.sql +27 -0
- package/dist/drizzle/0251_brain_stragglers.sql +21 -0
- package/dist/drizzle/0253_drop_brain_substrate.sql +2 -0
- package/dist/drizzle/0257_agents_runtime_allow_harness.sql +24 -0
- package/dist/drizzle/0261_native_auth_control_plane.sql +332 -0
- package/dist/drizzle/0262_auth_subscription_tickets.sql +59 -0
- package/dist/drizzle/0263_agentcore_runtime_identifier.sql +69 -0
- package/dist/drizzle/0263_drop_workos_auth_runtime.sql +236 -0
- package/dist/drizzle/0264_auth_enrollment_attempt_limits.sql +15 -0
- package/dist/drizzle/0265_eval_runs_requester_identity.sql +28 -0
- package/dist/drizzle/0265_require_fully_valid_auth_publication.sql +27 -0
- package/dist/drizzle/0266_auth_identity_recovery_grants.sql +9 -0
- package/dist/drizzle/0266_eval_profiles_runtime_type.sql +12 -0
- package/dist/drizzle/0267_ontology_candidate_rejections.sql +53 -0
- package/dist/drizzle/0268_identity_crosswalk_routing.sql +182 -0
- package/dist/drizzle/0269_ontology_system_map.sql +31 -0
- package/dist/drizzle/0270_tool_execution_ledger.sql +115 -0
- package/dist/drizzle/0271_ontology_twin_declarations.sql +47 -0
- package/dist/drizzle/0272_identity_graph_projection_cursor.sql +23 -0
- package/dist/drizzle/0273_twin_materialization_suggestions.sql +29 -0
- package/dist/drizzle/0274_tenant_mcp_twin_keys.sql +59 -0
- package/dist/drizzle/0275_identity_bulk_rebuild_fence.sql +30 -0
- package/dist/drizzle/0276_tool_execution_ledger_allow_cascade_delete.sql +18 -0
- package/dist/drizzle/0277_knowledge_base_sources.sql +107 -0
- package/dist/drizzle/0278_kb_page_transcription.sql +55 -0
- package/dist/drizzle/0279_mcp_servers_off_plugin_provenance.sql +93 -0
- package/dist/drizzle/0280_work_item_external_refs_drop_plane_provider.sql +46 -0
- package/dist/drizzle/0281_tenant_mcp_twin_keys_expiry_suffix.sql +9 -0
- package/dist/drizzle/0282_tenant_mcp_twin_keys_grants.sql +24 -0
- package/dist/drizzle/0283_agents_agentcore_runtime_dispatch.sql +13 -0
- package/dist/drizzle/0284_user_brain_claims.sql +69 -0
- package/dist/drizzle/0285_tenant_mcp_twin_keys_trusted_subsystem.sql +30 -0
- package/dist/drizzle/0286_brain_analytics_key.sql +26 -0
- package/dist/drizzle/0287_brain_subject.sql +25 -0
- package/dist/drizzle/0288_multi_lane_identities.sql +25 -0
- package/dist/event-streams-7JNLJEEL.js +894 -0
- package/dist/event-streams-KDF5RWR6.js +1515 -0
- package/dist/loadSso-ETCXTR4I.js +576 -0
- package/dist/loadSso-UBD7KUHE.js +583 -0
- package/dist/plugins/README.md +2 -2
- package/dist/plugins/catalog/package.json +1 -5
- package/dist/plugins/catalog/src/__tests__/build-catalog.test.ts +6 -4
- package/dist/plugins/catalog/src/__tests__/catalog.test.ts +21 -21
- package/dist/plugins/catalog/src/__tests__/contracts.test.ts +102 -94
- package/dist/plugins/catalog/src/__tests__/plugin-package.test.ts +7 -8
- package/dist/plugins/catalog/src/__tests__/plugin-registry.test.ts +0 -20
- package/dist/plugins/catalog/src/contracts.ts +17 -179
- package/dist/plugins/catalog/src/registry/generated-first-party.ts +0 -24
- package/dist/plugins/n8n/test/integrated-app-contract.test.ts +1 -1
- package/dist/plugins/twenty/package.json +2 -1
- package/dist/plugins/twenty/scripts/LAMBDA_DEPLOY.md +114 -0
- package/dist/plugins/twenty/scripts/build-lambda.sh +29 -0
- package/dist/plugins/twenty/scripts/configure-product-views.ts +195 -0
- package/dist/plugins/twenty/scripts/lambda-handler.ts +49 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-attachments.test.ts +38 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/load-records.test.ts +145 -2
- package/dist/plugins/twenty/scripts/lib/__tests__/mappers.test.ts +397 -151
- package/dist/plugins/twenty/scripts/lib/__tests__/members-ensure.test.ts +28 -129
- package/dist/plugins/twenty/scripts/lib/__tests__/provision-members-db.test.ts +10 -0
- package/dist/plugins/twenty/scripts/lib/__tests__/schema-ensure.test.ts +13 -8
- package/dist/plugins/twenty/scripts/lib/lastmile-reader.ts +222 -2
- package/dist/plugins/twenty/scripts/lib/load-attachments.ts +29 -0
- package/dist/plugins/twenty/scripts/lib/load-records.ts +160 -43
- package/dist/plugins/twenty/scripts/lib/mappers.ts +368 -152
- package/dist/plugins/twenty/scripts/lib/members-ensure.ts +43 -268
- package/dist/plugins/twenty/scripts/lib/provision-members-db.ts +57 -0
- package/dist/plugins/twenty/scripts/lib/schema-ensure.ts +136 -31
- package/dist/plugins/twenty/scripts/migrate-lastmile.ts +254 -152
- package/dist/plugins/twenty/scripts/provision-twenty-members.ts +44 -1
- package/dist/plugins/twenty/scripts/purge-lastmile-import.ts +178 -0
- package/dist/plugins/twenty/scripts/restructure-products.ts +312 -0
- package/dist/plugins/twenty/scripts/retag-stage-values.ts +362 -0
- package/dist/plugins/twenty/test/manifest.test.ts +2 -4
- package/dist/scripts/post-deploy.sh +79 -1
- package/dist/signin-5QZNRSOO.js +821 -0
- package/dist/sso-oidc-XK673P54.js +837 -0
- package/dist/sts-OXI2UALF.js +1113 -0
- package/dist/sts-SQW4NBK3.js +1117 -0
- package/dist/terraform/examples/greenfield/main.tf +391 -176
- package/dist/terraform/examples/greenfield/terraform.tfvars.example +26 -8
- package/dist/terraform/modules/app/agentcore-admin/main.tf +47 -0
- package/dist/terraform/modules/app/agentcore-code-interpreter/README.md +39 -47
- package/dist/terraform/modules/app/agentcore-code-interpreter/main.tf +13 -66
- package/dist/terraform/modules/app/agentcore-identity/main.tf +253 -0
- package/dist/terraform/modules/app/agentcore-identity/outputs.tf +51 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/bootstrap_twenty_oauth_client.sh +239 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_identity.sh +22 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_twenty_identity.sh +16 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/delete_workload_identity.sh +19 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/ensure_workload_identity.sh +29 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/read_identity.sh +55 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_identity.sh +73 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_twenty_identity.sh +45 -0
- package/dist/terraform/modules/app/agentcore-identity/scripts/reconcile_twenty_provider.mjs +123 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/after.tf +15 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/before.tf +7 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/identity-after.tf +8 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/identity-before.tf +9 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/thinkwork-after.tf +3 -0
- package/dist/terraform/modules/app/agentcore-identity/tests/tainted-marker/thinkwork-before.tf +3 -0
- package/dist/terraform/modules/app/agentcore-identity/variables.tf +60 -0
- package/dist/terraform/modules/app/agentcore-memory/README.md +46 -9
- package/dist/terraform/modules/app/agentcore-memory/main.tf +27 -10
- package/dist/terraform/modules/app/agentcore-memory/scripts/create_or_find_memory.sh +156 -24
- package/dist/terraform/modules/app/agentcore-pi/README.md +1 -3
- package/dist/terraform/modules/app/agentcore-pi/main.tf +42 -52
- package/dist/terraform/modules/app/agentcore-pi/outputs.tf +3 -3
- package/dist/terraform/modules/app/agentcore-pi/scripts/reconcile_pi_runtime.mjs +175 -0
- package/dist/terraform/modules/app/agentcore-pi/variables.tf +35 -28
- package/dist/terraform/modules/app/agentcore-platform/main.tf +68 -0
- package/dist/terraform/modules/app/agentcore-runtime/main.tf +4 -20
- package/dist/terraform/modules/app/appsync-subscriptions/main.tf +127 -21
- package/dist/terraform/modules/app/appsync-subscriptions/outputs.tf +0 -6
- package/dist/terraform/modules/app/appsync-subscriptions/variables.tf +5 -0
- package/dist/terraform/modules/app/capability-broker/main.tf +2 -2
- package/dist/terraform/modules/app/capability-broker/variables.tf +11 -0
- package/dist/terraform/modules/app/deployment-control-plane/README.md +264 -0
- package/dist/terraform/modules/app/deployment-control-plane/buildspec.yml +4 -1
- package/dist/terraform/modules/app/deployment-control-plane/main.tf +94 -0
- package/dist/terraform/modules/app/deployment-control-plane/outputs.tf +5 -0
- package/dist/terraform/modules/app/deployment-control-plane/runner.py +3689 -233
- package/dist/terraform/modules/app/deployment-control-plane/test_runner_bundle.py +2579 -140
- package/dist/terraform/modules/app/deployment-control-plane/variables.tf +33 -0
- package/dist/terraform/modules/app/lambda-api/auth-state.tf +72 -0
- package/dist/terraform/modules/app/lambda-api/chat-latency-observability.tf +466 -0
- package/dist/terraform/modules/app/lambda-api/dispatch-dlq.tf +55 -0
- package/dist/terraform/modules/app/lambda-api/handlers.tf +531 -619
- package/dist/terraform/modules/app/lambda-api/iam-grouped.tf +350 -241
- package/dist/terraform/modules/app/lambda-api/main.tf +75 -13
- package/dist/terraform/modules/app/lambda-api/memory-alarms.tf +3 -28
- package/dist/terraform/modules/app/lambda-api/oauth-secrets.tf +1 -2
- package/dist/terraform/modules/app/lambda-api/outputs.tf +17 -10
- package/dist/terraform/modules/app/lambda-api/runtime-config.tf +3 -21
- package/dist/terraform/modules/app/lambda-api/turn-assertion.tf +45 -0
- package/dist/terraform/modules/app/lambda-api/variables.tf +307 -121
- package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/README.md +1 -1
- package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/main.tf +18 -18
- package/dist/terraform/modules/app/sandbox-log-scrubber/README.md +11 -10
- package/dist/terraform/modules/app/sandbox-log-scrubber/main.tf +5 -5
- package/dist/terraform/modules/app/static-site/main.tf +1 -1
- package/dist/terraform/modules/app/www-dns/main.tf +9 -27
- package/dist/terraform/modules/app/www-dns/variables.tf +4 -10
- package/dist/terraform/modules/data/aurora-postgres/README.md +34 -0
- package/dist/terraform/modules/data/aurora-postgres/alarms.tf +82 -0
- package/dist/terraform/modules/data/aurora-postgres/main.tf +27 -57
- package/dist/terraform/modules/data/aurora-postgres/outputs.tf +0 -9
- package/dist/terraform/modules/data/aurora-postgres/variables.tf +41 -0
- package/dist/terraform/modules/data/s3-buckets/main.tf +5 -6
- package/dist/terraform/modules/foundation/cognito/main.tf +367 -72
- package/dist/terraform/modules/foundation/cognito/outputs.tf +47 -0
- package/dist/terraform/modules/foundation/cognito/variables.tf +131 -9
- package/dist/terraform/modules/thinkwork/README.md +5 -1
- package/dist/terraform/modules/thinkwork/main.tf +459 -234
- package/dist/terraform/modules/thinkwork/outputs.tf +44 -62
- package/dist/terraform/modules/thinkwork/variables.tf +353 -89
- package/dist/terraform/schema.graphql +69 -36
- package/dist/workspace-defaults/files/INSTRUCTIONS.md +9 -11
- package/dist/workspace-defaults/files/MEMORY_GUIDE.md +38 -35
- package/dist/workspace-defaults/files/ROUTER.md +1 -1
- package/dist/workspace-defaults/files/TOOLS.md +9 -39
- package/dist/workspace-defaults/files/USER.md +1 -0
- package/dist/workspace-defaults/files/agents/analyst/INSTRUCTIONS.md +6 -3
- package/dist/workspace-defaults/files/catalog-skills/brain-brief-builder/SKILL.md +165 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/SKILL.md +75 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/mcp-tooling.md +40 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/validation-and-handoff.md +40 -0
- package/dist/workspace-defaults/files/catalog-skills/n8n-workflow-operator/references/workflow-authoring.md +46 -0
- package/dist/workspace-defaults/files/skills/artifact-builder/references/crm-dashboard.md +1 -1
- package/dist/workspace-defaults/files/skills/document-composer/SKILL.md +22 -3
- package/package.json +3 -2
- package/dist/drizzle/0261_thread_turns_origin_turn_index.sql +0 -11
- package/dist/plugins/company-data/README.md +0 -49
- package/dist/plugins/company-data/package.json +0 -21
- package/dist/plugins/company-data/src/index.ts +0 -30
- package/dist/plugins/company-data/src/manifest.ts +0 -26
- package/dist/plugins/company-data/test/manifest.test.ts +0 -116
- package/dist/plugins/company-data/tsconfig.json +0 -8
- package/dist/plugins/company-etl/README.md +0 -46
- package/dist/plugins/company-etl/package.json +0 -21
- package/dist/plugins/company-etl/src/index.ts +0 -29
- package/dist/plugins/company-etl/src/manifest.ts +0 -26
- package/dist/plugins/company-etl/test/manifest.test.ts +0 -108
- package/dist/plugins/company-etl/tsconfig.json +0 -8
- package/dist/plugins/lastmile/README.md +0 -50
- package/dist/plugins/lastmile/package.json +0 -23
- package/dist/plugins/lastmile/smoke/lastmile-plugin-smoke.mjs +0 -661
- package/dist/plugins/lastmile/src/api/tasks-adapter.ts +0 -572
- package/dist/plugins/lastmile/src/discovery.fixture.ts +0 -64
- package/dist/plugins/lastmile/src/index.ts +0 -46
- package/dist/plugins/lastmile/src/manifest.ts +0 -139
- package/dist/plugins/lastmile/test/api/tasks-adapter.test.ts +0 -266
- package/dist/plugins/lastmile/test/discovery.test.ts +0 -88
- package/dist/plugins/lastmile/tsconfig.json +0 -8
- package/dist/plugins/n8n/smoke/n8n-managed-app-smoke.mjs +0 -409
- package/dist/plugins/twenty/smoke/twenty-managed-app-smoke.mjs +0 -359
- package/dist/plugins/workos-auth/package.json +0 -22
- package/dist/plugins/workos-auth/src/index.ts +0 -30
- package/dist/plugins/workos-auth/src/manifest.ts +0 -40
- package/dist/plugins/workos-auth/src/provider-contract.ts +0 -39
- package/dist/plugins/workos-auth/test/manifest.test.ts +0 -94
- package/dist/plugins/workos-auth/tsconfig.json +0 -8
- package/dist/terraform/modules/app/agentcore-code-interpreter/Dockerfile.sandbox-base +0 -61
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/sitecustomize.py +0 -227
- package/dist/terraform/modules/app/agentcore-code-interpreter/sandbox/test_sitecustomize.py +0 -277
- package/dist/terraform/modules/app/agentcore-code-interpreter/scripts/build_and_push_sandbox_base.sh +0 -70
- package/dist/terraform/modules/app/agentcore-harness/main.tf +0 -101
- package/dist/terraform/modules/app/agentcore-harness/outputs.tf +0 -9
- package/dist/terraform/modules/app/agentcore-harness/variables.tf +0 -25
- package/dist/terraform/modules/app/hindsight-memory/README.md +0 -89
- package/dist/terraform/modules/app/hindsight-memory/main.tf +0 -411
- package/dist/terraform/modules/data/bedrock-knowledge-base/main.tf +0 -102
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/outputs.tf +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/scripts/sync-database.py +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/scripts/test_sync_database.py +0 -0
- /package/dist/{plugins/n8n/terraform → terraform/modules/app}/n8n/variables.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/README.md +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/main.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/outputs.tf +0 -0
- /package/dist/{plugins/twenty/terraform → terraform/modules/app}/twenty/variables.tf +0 -0
|
@@ -9,15 +9,21 @@
|
|
|
9
9
|
locals {
|
|
10
10
|
create = var.create_cognito
|
|
11
11
|
create_pre_signup = local.create && var.pre_signup_lambda_zip != ""
|
|
12
|
+
create_pre_token_generation = local.create && trimspace(var.pre_token_generation_lambda_s3_bucket) != "" && trimspace(var.pre_token_generation_lambda_s3_key) != ""
|
|
13
|
+
workos_rollback_enabled = var.auth_retirement_phase != "retired"
|
|
12
14
|
use_local_custom_auth_artifact = trimspace(var.custom_auth_lambda_zip) != ""
|
|
13
15
|
use_remote_custom_auth_artifact = trimspace(var.custom_auth_lambda_s3_bucket) != ""
|
|
14
16
|
custom_auth_artifact_count = (local.use_local_custom_auth_artifact ? 1 : 0) + (local.use_remote_custom_auth_artifact ? 1 : 0)
|
|
15
|
-
create_custom_auth = local.create && local.custom_auth_artifact_count == 1
|
|
16
|
-
|
|
17
|
-
user_pool_id
|
|
18
|
-
user_pool_arn
|
|
19
|
-
admin_client_id
|
|
20
|
-
|
|
17
|
+
create_custom_auth = local.create && local.workos_rollback_enabled && local.custom_auth_artifact_count == 1
|
|
18
|
+
|
|
19
|
+
user_pool_id = local.create ? aws_cognito_user_pool.main[0].id : var.existing_user_pool_id
|
|
20
|
+
user_pool_arn = local.create ? aws_cognito_user_pool.main[0].arn : var.existing_user_pool_arn
|
|
21
|
+
admin_client_id = local.create ? (
|
|
22
|
+
local.workos_rollback_enabled ? aws_cognito_user_pool_client.admin[0].id : aws_cognito_user_pool_client.auth_route["web:local"].id
|
|
23
|
+
) : var.existing_admin_client_id
|
|
24
|
+
mobile_client_id = local.create ? (
|
|
25
|
+
local.workos_rollback_enabled ? aws_cognito_user_pool_client.mobile[0].id : aws_cognito_user_pool_client.auth_route["mobile:local"].id
|
|
26
|
+
) : var.existing_mobile_client_id
|
|
21
27
|
identity_pool_id = local.create ? aws_cognito_identity_pool.main[0].id : var.existing_identity_pool_id
|
|
22
28
|
oidc_identity_providers = {
|
|
23
29
|
for provider in var.oidc_identity_providers : provider.provider_name => provider
|
|
@@ -25,10 +31,79 @@ locals {
|
|
|
25
31
|
saml_identity_providers = {
|
|
26
32
|
for provider in var.saml_identity_providers : provider.provider_name => provider
|
|
27
33
|
}
|
|
34
|
+
auth_client_families = {
|
|
35
|
+
web = {
|
|
36
|
+
callback_urls = [for url in var.admin_callback_urls : url if !strcontains(url, ":42010/")]
|
|
37
|
+
logout_urls = var.admin_logout_urls
|
|
38
|
+
refresh_token_days = 30
|
|
39
|
+
}
|
|
40
|
+
mobile = {
|
|
41
|
+
callback_urls = var.mobile_callback_urls
|
|
42
|
+
logout_urls = var.mobile_logout_urls
|
|
43
|
+
refresh_token_days = 90
|
|
44
|
+
}
|
|
45
|
+
cli = {
|
|
46
|
+
callback_urls = var.cli_callback_urls
|
|
47
|
+
logout_urls = var.cli_logout_urls
|
|
48
|
+
refresh_token_days = 30
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
static_auth_routes = merge(
|
|
52
|
+
{
|
|
53
|
+
for family, config in local.auth_client_families : "${family}:local" => {
|
|
54
|
+
route_key = "local"
|
|
55
|
+
client_family = family
|
|
56
|
+
provider_names = ["COGNITO"]
|
|
57
|
+
explicit_auth_flows = ["ALLOW_USER_PASSWORD_AUTH", "ALLOW_USER_SRP_AUTH", "ALLOW_REFRESH_TOKEN_AUTH"]
|
|
58
|
+
callback_urls = config.callback_urls
|
|
59
|
+
logout_urls = config.logout_urls
|
|
60
|
+
refresh_token_days = config.refresh_token_days
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
var.google_oauth_client_id != "" ? {
|
|
64
|
+
for family, config in local.auth_client_families : "${family}:google" => {
|
|
65
|
+
route_key = "google"
|
|
66
|
+
client_family = family
|
|
67
|
+
provider_names = ["Google"]
|
|
68
|
+
explicit_auth_flows = ["ALLOW_REFRESH_TOKEN_AUTH"]
|
|
69
|
+
callback_urls = config.callback_urls
|
|
70
|
+
logout_urls = config.logout_urls
|
|
71
|
+
refresh_token_days = config.refresh_token_days
|
|
72
|
+
}
|
|
73
|
+
} : {},
|
|
74
|
+
var.microsoft_oauth_client_id != "" ? {
|
|
75
|
+
for family, config in local.auth_client_families : "${family}:microsoft" => {
|
|
76
|
+
route_key = "microsoft"
|
|
77
|
+
client_family = family
|
|
78
|
+
provider_names = ["MicrosoftOrganizations"]
|
|
79
|
+
explicit_auth_flows = ["ALLOW_REFRESH_TOKEN_AUTH"]
|
|
80
|
+
callback_urls = config.callback_urls
|
|
81
|
+
logout_urls = config.logout_urls
|
|
82
|
+
refresh_token_days = config.refresh_token_days
|
|
83
|
+
}
|
|
84
|
+
} : {},
|
|
85
|
+
)
|
|
86
|
+
tenant_auth_routes = merge({}, [
|
|
87
|
+
for connection in var.tenant_entra_connections : {
|
|
88
|
+
for family, config in local.auth_client_families : "${family}:entra:${lower(connection.tenant_id)}" => {
|
|
89
|
+
route_key = "entra-${replace(lower(connection.tenant_id), "-", "")}"
|
|
90
|
+
client_family = family
|
|
91
|
+
provider_names = [connection.provider_name]
|
|
92
|
+
explicit_auth_flows = ["ALLOW_REFRESH_TOKEN_AUTH"]
|
|
93
|
+
callback_urls = config.callback_urls
|
|
94
|
+
logout_urls = config.logout_urls
|
|
95
|
+
refresh_token_days = config.refresh_token_days
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
]...)
|
|
99
|
+
auth_routes = merge(local.static_auth_routes, local.tenant_auth_routes)
|
|
28
100
|
}
|
|
29
101
|
|
|
30
102
|
resource "terraform_data" "custom_auth_artifact_validation" {
|
|
31
|
-
input =
|
|
103
|
+
input = {
|
|
104
|
+
phase = var.auth_retirement_phase
|
|
105
|
+
artifact_count = local.custom_auth_artifact_count
|
|
106
|
+
}
|
|
32
107
|
|
|
33
108
|
lifecycle {
|
|
34
109
|
precondition {
|
|
@@ -40,6 +115,16 @@ resource "terraform_data" "custom_auth_artifact_validation" {
|
|
|
40
115
|
condition = !local.use_remote_custom_auth_artifact || trimspace(var.custom_auth_lambda_s3_key) != ""
|
|
41
116
|
error_message = "custom_auth_lambda_s3_key must be set when custom_auth_lambda_s3_bucket is set."
|
|
42
117
|
}
|
|
118
|
+
|
|
119
|
+
precondition {
|
|
120
|
+
condition = !local.create_custom_auth || var.api_auth_secret != ""
|
|
121
|
+
error_message = "The WorkOS rollback custom-auth Lambda requires api_auth_secret until auth_retirement_phase is retired."
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
precondition {
|
|
125
|
+
condition = var.microsoft_oauth_client_id == "" || var.microsoft_oauth_tenant != ""
|
|
126
|
+
error_message = "microsoft_oauth_tenant is required when microsoft_oauth_client_id is configured because Cognito requires an exact tenant issuer."
|
|
127
|
+
}
|
|
43
128
|
}
|
|
44
129
|
}
|
|
45
130
|
|
|
@@ -69,26 +154,6 @@ resource "aws_iam_role_policy_attachment" "pre_signup_basic" {
|
|
|
69
154
|
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
|
|
70
155
|
}
|
|
71
156
|
|
|
72
|
-
resource "aws_iam_role_policy" "pre_signup_cognito" {
|
|
73
|
-
count = local.create_pre_signup ? 1 : 0
|
|
74
|
-
name = "cognito-access"
|
|
75
|
-
role = aws_iam_role.pre_signup[0].id
|
|
76
|
-
|
|
77
|
-
policy = jsonencode({
|
|
78
|
-
Version = "2012-10-17"
|
|
79
|
-
Statement = [{
|
|
80
|
-
Effect = "Allow"
|
|
81
|
-
Action = [
|
|
82
|
-
"cognito-idp:ListUsers",
|
|
83
|
-
"cognito-idp:AdminLinkProviderForUser",
|
|
84
|
-
"cognito-idp:AdminCreateUser",
|
|
85
|
-
"cognito-idp:AdminSetUserPassword"
|
|
86
|
-
]
|
|
87
|
-
Resource = aws_cognito_user_pool.main[0].arn
|
|
88
|
-
}]
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
|
|
92
157
|
resource "aws_lambda_function" "pre_signup" {
|
|
93
158
|
count = local.create_pre_signup ? 1 : 0
|
|
94
159
|
function_name = "thinkwork-${var.stage}-cognito-pre-signup"
|
|
@@ -111,15 +176,62 @@ resource "aws_lambda_permission" "cognito_pre_signup" {
|
|
|
111
176
|
}
|
|
112
177
|
|
|
113
178
|
################################################################################
|
|
114
|
-
#
|
|
179
|
+
# Pre Token Generation Client Cutoff Lambda
|
|
180
|
+
################################################################################
|
|
181
|
+
|
|
182
|
+
resource "aws_iam_role" "pre_token_generation" {
|
|
183
|
+
count = local.create_pre_token_generation ? 1 : 0
|
|
184
|
+
name = "thinkwork-${var.stage}-cognito-pre-token-role"
|
|
185
|
+
|
|
186
|
+
assume_role_policy = jsonencode({
|
|
187
|
+
Version = "2012-10-17"
|
|
188
|
+
Statement = [{
|
|
189
|
+
Effect = "Allow"
|
|
190
|
+
Principal = { Service = "lambda.amazonaws.com" }
|
|
191
|
+
Action = "sts:AssumeRole"
|
|
192
|
+
}]
|
|
193
|
+
})
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
resource "aws_iam_role_policy_attachment" "pre_token_generation_basic" {
|
|
197
|
+
count = local.create_pre_token_generation ? 1 : 0
|
|
198
|
+
role = aws_iam_role.pre_token_generation[0].name
|
|
199
|
+
policy_arn = "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
resource "aws_lambda_function" "pre_token_generation" {
|
|
203
|
+
count = local.create_pre_token_generation ? 1 : 0
|
|
204
|
+
function_name = "thinkwork-${var.stage}-cognito-pre-token-client-deny"
|
|
205
|
+
s3_bucket = var.pre_token_generation_lambda_s3_bucket
|
|
206
|
+
s3_key = var.pre_token_generation_lambda_s3_key
|
|
207
|
+
handler = "index.handler"
|
|
208
|
+
runtime = "nodejs20.x"
|
|
209
|
+
timeout = 5
|
|
210
|
+
role = aws_iam_role.pre_token_generation[0].arn
|
|
211
|
+
|
|
212
|
+
environment {
|
|
213
|
+
variables = {
|
|
214
|
+
COGNITO_DENIED_APP_CLIENT_IDS = join(",", var.denied_app_client_ids)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
resource "aws_lambda_permission" "cognito_pre_token_generation" {
|
|
220
|
+
count = local.create_pre_token_generation ? 1 : 0
|
|
221
|
+
statement_id = "AllowCognitoInvoke"
|
|
222
|
+
action = "lambda:InvokeFunction"
|
|
223
|
+
function_name = aws_lambda_function.pre_token_generation[0].function_name
|
|
224
|
+
principal = "cognito-idp.amazonaws.com"
|
|
225
|
+
source_arn = aws_cognito_user_pool.main[0].arn
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
################################################################################
|
|
229
|
+
# Legacy WorkOS Custom Auth Challenge Lambda (rollback runtime only)
|
|
115
230
|
################################################################################
|
|
116
231
|
|
|
117
232
|
resource "aws_iam_role" "custom_auth" {
|
|
118
233
|
count = local.create_custom_auth ? 1 : 0
|
|
119
|
-
|
|
120
|
-
# apply does not collide with custom-auth Lambdas created during the legacy
|
|
121
|
-
# manual rollout. Local source deployments retain the original name.
|
|
122
|
-
name = local.use_remote_custom_auth_artifact ? "thinkwork-${var.stage}-cognito-custom-auth-release-role" : "thinkwork-${var.stage}-cognito-custom-auth-role"
|
|
234
|
+
name = local.use_remote_custom_auth_artifact ? "thinkwork-${var.stage}-cognito-custom-auth-release-role" : "thinkwork-${var.stage}-cognito-custom-auth-role"
|
|
123
235
|
|
|
124
236
|
assume_role_policy = jsonencode({
|
|
125
237
|
Version = "2012-10-17"
|
|
@@ -155,13 +267,6 @@ resource "aws_lambda_function" "custom_auth" {
|
|
|
155
267
|
}
|
|
156
268
|
|
|
157
269
|
source_code_hash = local.use_local_custom_auth_artifact ? filebase64sha256(var.custom_auth_lambda_zip) : null
|
|
158
|
-
|
|
159
|
-
lifecycle {
|
|
160
|
-
precondition {
|
|
161
|
-
condition = var.api_auth_secret != ""
|
|
162
|
-
error_message = "A Cognito custom-auth Lambda artifact requires api_auth_secret so custom-auth challenges can be verified."
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
270
|
}
|
|
166
271
|
|
|
167
272
|
resource "aws_lambda_permission" "cognito_custom_auth" {
|
|
@@ -213,6 +318,30 @@ resource "aws_cognito_user_pool" "main" {
|
|
|
213
318
|
}
|
|
214
319
|
}
|
|
215
320
|
|
|
321
|
+
schema {
|
|
322
|
+
name = "entra_tenant_id"
|
|
323
|
+
attribute_data_type = "String"
|
|
324
|
+
required = false
|
|
325
|
+
mutable = true
|
|
326
|
+
|
|
327
|
+
string_attribute_constraints {
|
|
328
|
+
min_length = 0
|
|
329
|
+
max_length = 36
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
schema {
|
|
334
|
+
name = "entra_object_id"
|
|
335
|
+
attribute_data_type = "String"
|
|
336
|
+
required = false
|
|
337
|
+
mutable = true
|
|
338
|
+
|
|
339
|
+
string_attribute_constraints {
|
|
340
|
+
min_length = 0
|
|
341
|
+
max_length = 36
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
216
345
|
schema {
|
|
217
346
|
name = "tenant_id"
|
|
218
347
|
attribute_data_type = "String"
|
|
@@ -242,12 +371,19 @@ resource "aws_cognito_user_pool" "main" {
|
|
|
242
371
|
}
|
|
243
372
|
|
|
244
373
|
dynamic "lambda_config" {
|
|
245
|
-
for_each = local.create_pre_signup || local.create_custom_auth ? [1] : []
|
|
374
|
+
for_each = local.create_pre_signup || local.create_pre_token_generation || local.create_custom_auth ? [1] : []
|
|
246
375
|
content {
|
|
247
376
|
pre_sign_up = local.create_pre_signup ? aws_lambda_function.pre_signup[0].arn : null
|
|
248
377
|
define_auth_challenge = local.create_custom_auth ? aws_lambda_function.custom_auth[0].arn : null
|
|
249
378
|
create_auth_challenge = local.create_custom_auth ? aws_lambda_function.custom_auth[0].arn : null
|
|
250
379
|
verify_auth_challenge_response = local.create_custom_auth ? aws_lambda_function.custom_auth[0].arn : null
|
|
380
|
+
dynamic "pre_token_generation_config" {
|
|
381
|
+
for_each = local.create_pre_token_generation ? [1] : []
|
|
382
|
+
content {
|
|
383
|
+
lambda_arn = aws_lambda_function.pre_token_generation[0].arn
|
|
384
|
+
lambda_version = "V2_0"
|
|
385
|
+
}
|
|
386
|
+
}
|
|
251
387
|
}
|
|
252
388
|
}
|
|
253
389
|
|
|
@@ -298,21 +434,107 @@ resource "aws_cognito_identity_provider" "google" {
|
|
|
298
434
|
}
|
|
299
435
|
|
|
300
436
|
attribute_mapping = {
|
|
301
|
-
email
|
|
302
|
-
|
|
303
|
-
|
|
437
|
+
email = "email"
|
|
438
|
+
email_verified = "email_verified"
|
|
439
|
+
name = "name"
|
|
440
|
+
username = "sub"
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
resource "aws_cognito_identity_provider" "microsoft_organizations" {
|
|
445
|
+
count = local.create && var.microsoft_oauth_client_id != "" ? 1 : 0
|
|
446
|
+
user_pool_id = aws_cognito_user_pool.main[0].id
|
|
447
|
+
provider_name = "MicrosoftOrganizations"
|
|
448
|
+
provider_type = "OIDC"
|
|
449
|
+
|
|
450
|
+
provider_details = {
|
|
451
|
+
client_id = var.microsoft_oauth_client_id
|
|
452
|
+
client_secret = var.microsoft_oauth_client_secret
|
|
453
|
+
authorize_scopes = "openid email profile"
|
|
454
|
+
oidc_issuer = "https://login.microsoftonline.com/${lower(var.microsoft_oauth_tenant)}/v2.0"
|
|
455
|
+
attributes_request_method = "GET"
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
attribute_mapping = {
|
|
459
|
+
# Entra v2 does not guarantee an `email` claim for every work/school
|
|
460
|
+
# account. `preferred_username` is the supported sign-in hint and keeps
|
|
461
|
+
# Cognito's required email attribute populated as a stable normalized
|
|
462
|
+
# correlation value. ThinkWork only consults it after
|
|
463
|
+
# Cognito validates this exact Entra route; ongoing admission uses the
|
|
464
|
+
# immutable Cognito issuer/subject binding created by that first login.
|
|
465
|
+
email = "preferred_username"
|
|
466
|
+
name = "name"
|
|
467
|
+
username = "sub"
|
|
468
|
+
"custom:entra_tenant_id" = "tid"
|
|
469
|
+
"custom:entra_object_id" = "oid"
|
|
304
470
|
}
|
|
305
471
|
}
|
|
306
472
|
|
|
307
473
|
locals {
|
|
308
474
|
identity_providers = concat(
|
|
309
475
|
var.google_oauth_client_id != "" ? ["Google"] : [],
|
|
476
|
+
var.microsoft_oauth_client_id != "" ? ["MicrosoftOrganizations"] : [],
|
|
310
477
|
keys(local.oidc_identity_providers),
|
|
311
478
|
keys(local.saml_identity_providers),
|
|
312
479
|
["COGNITO"]
|
|
313
480
|
)
|
|
314
481
|
}
|
|
315
482
|
|
|
483
|
+
################################################################################
|
|
484
|
+
# Route-specific public app clients
|
|
485
|
+
################################################################################
|
|
486
|
+
|
|
487
|
+
resource "aws_cognito_user_pool_client" "auth_route" {
|
|
488
|
+
for_each = local.create ? local.auth_routes : {}
|
|
489
|
+
|
|
490
|
+
name = "Thinkwork-${title(each.value.client_family)}-${title(each.value.route_key)}"
|
|
491
|
+
user_pool_id = aws_cognito_user_pool.main[0].id
|
|
492
|
+
|
|
493
|
+
generate_secret = false
|
|
494
|
+
allowed_oauth_flows_user_pool_client = true
|
|
495
|
+
allowed_oauth_flows = ["code"]
|
|
496
|
+
allowed_oauth_scopes = ["openid", "email", "profile"]
|
|
497
|
+
explicit_auth_flows = each.value.explicit_auth_flows
|
|
498
|
+
supported_identity_providers = each.value.provider_names
|
|
499
|
+
callback_urls = distinct(each.value.callback_urls)
|
|
500
|
+
logout_urls = distinct(each.value.logout_urls)
|
|
501
|
+
enable_token_revocation = true
|
|
502
|
+
prevent_user_existence_errors = "ENABLED"
|
|
503
|
+
access_token_validity = 1
|
|
504
|
+
id_token_validity = 1
|
|
505
|
+
refresh_token_validity = each.value.refresh_token_days
|
|
506
|
+
|
|
507
|
+
token_validity_units {
|
|
508
|
+
access_token = "hours"
|
|
509
|
+
id_token = "hours"
|
|
510
|
+
refresh_token = "days"
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
read_attributes = [
|
|
514
|
+
"email",
|
|
515
|
+
"email_verified",
|
|
516
|
+
"name",
|
|
517
|
+
"custom:tenant_id",
|
|
518
|
+
"custom:entra_tenant_id",
|
|
519
|
+
"custom:entra_object_id",
|
|
520
|
+
]
|
|
521
|
+
|
|
522
|
+
write_attributes = [
|
|
523
|
+
"email",
|
|
524
|
+
"name",
|
|
525
|
+
"custom:tenant_id",
|
|
526
|
+
"custom:entra_tenant_id",
|
|
527
|
+
"custom:entra_object_id",
|
|
528
|
+
]
|
|
529
|
+
|
|
530
|
+
depends_on = [
|
|
531
|
+
aws_cognito_identity_provider.google,
|
|
532
|
+
aws_cognito_identity_provider.microsoft_organizations,
|
|
533
|
+
aws_cognito_identity_provider.oidc,
|
|
534
|
+
aws_cognito_identity_provider.saml,
|
|
535
|
+
]
|
|
536
|
+
}
|
|
537
|
+
|
|
316
538
|
resource "aws_cognito_identity_provider" "oidc" {
|
|
317
539
|
for_each = local.create ? local.oidc_identity_providers : {}
|
|
318
540
|
|
|
@@ -363,8 +585,8 @@ resource "aws_cognito_identity_provider" "saml" {
|
|
|
363
585
|
################################################################################
|
|
364
586
|
|
|
365
587
|
resource "aws_cognito_user_pool_client" "admin" {
|
|
366
|
-
count = local.create ? 1 : 0
|
|
367
|
-
name = "
|
|
588
|
+
count = local.create && local.workos_rollback_enabled ? 1 : 0
|
|
589
|
+
name = "ThinkworkAdminLegacy"
|
|
368
590
|
user_pool_id = aws_cognito_user_pool.main[0].id
|
|
369
591
|
|
|
370
592
|
allowed_oauth_flows_user_pool_client = true
|
|
@@ -380,8 +602,8 @@ resource "aws_cognito_user_pool_client" "admin" {
|
|
|
380
602
|
|
|
381
603
|
supported_identity_providers = local.identity_providers
|
|
382
604
|
|
|
383
|
-
callback_urls = distinct(concat(var.admin_callback_urls, var.
|
|
384
|
-
logout_urls = distinct(concat(var.admin_logout_urls, var.
|
|
605
|
+
callback_urls = distinct(concat(var.admin_callback_urls, var.cli_callback_urls))
|
|
606
|
+
logout_urls = distinct(concat(var.admin_logout_urls, var.cli_logout_urls))
|
|
385
607
|
|
|
386
608
|
access_token_validity = 1
|
|
387
609
|
id_token_validity = 1
|
|
@@ -418,8 +640,8 @@ resource "aws_cognito_user_pool_client" "admin" {
|
|
|
418
640
|
################################################################################
|
|
419
641
|
|
|
420
642
|
resource "aws_cognito_user_pool_client" "mobile" {
|
|
421
|
-
count = local.create ? 1 : 0
|
|
422
|
-
name = "
|
|
643
|
+
count = local.create && local.workos_rollback_enabled ? 1 : 0
|
|
644
|
+
name = "ThinkworkMobileLegacy"
|
|
423
645
|
user_pool_id = aws_cognito_user_pool.main[0].id
|
|
424
646
|
|
|
425
647
|
explicit_auth_flows = [
|
|
@@ -468,6 +690,76 @@ resource "aws_cognito_user_pool_client" "mobile" {
|
|
|
468
690
|
]
|
|
469
691
|
}
|
|
470
692
|
|
|
693
|
+
################################################################################
|
|
694
|
+
# App Client — Company Brain console (U13, optional; ship-inert default off)
|
|
695
|
+
#
|
|
696
|
+
# Same OAuth flows/scopes/providers as the web client family. Gated on
|
|
697
|
+
# console_client_enabled so merging this creates nothing; enablement requires
|
|
698
|
+
# the console's callback URLs to be registered here FIRST (redirect_mismatch
|
|
699
|
+
# otherwise).
|
|
700
|
+
################################################################################
|
|
701
|
+
|
|
702
|
+
resource "aws_cognito_user_pool_client" "console" {
|
|
703
|
+
count = local.create && var.console_client_enabled ? 1 : 0
|
|
704
|
+
name = "ThinkworkConsole"
|
|
705
|
+
user_pool_id = aws_cognito_user_pool.main[0].id
|
|
706
|
+
|
|
707
|
+
generate_secret = false
|
|
708
|
+
allowed_oauth_flows_user_pool_client = true
|
|
709
|
+
allowed_oauth_flows = ["code"]
|
|
710
|
+
allowed_oauth_scopes = ["openid", "email", "profile"]
|
|
711
|
+
|
|
712
|
+
explicit_auth_flows = [
|
|
713
|
+
"ALLOW_USER_PASSWORD_AUTH",
|
|
714
|
+
"ALLOW_USER_SRP_AUTH",
|
|
715
|
+
"ALLOW_REFRESH_TOKEN_AUTH",
|
|
716
|
+
]
|
|
717
|
+
|
|
718
|
+
supported_identity_providers = local.identity_providers
|
|
719
|
+
|
|
720
|
+
callback_urls = distinct(var.console_callback_urls)
|
|
721
|
+
logout_urls = distinct(var.console_logout_urls)
|
|
722
|
+
|
|
723
|
+
enable_token_revocation = true
|
|
724
|
+
prevent_user_existence_errors = "ENABLED"
|
|
725
|
+
access_token_validity = 1
|
|
726
|
+
id_token_validity = 1
|
|
727
|
+
refresh_token_validity = 30
|
|
728
|
+
|
|
729
|
+
token_validity_units {
|
|
730
|
+
access_token = "hours"
|
|
731
|
+
id_token = "hours"
|
|
732
|
+
refresh_token = "days"
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
read_attributes = [
|
|
736
|
+
"email",
|
|
737
|
+
"email_verified",
|
|
738
|
+
"name",
|
|
739
|
+
"custom:tenant_id",
|
|
740
|
+
]
|
|
741
|
+
|
|
742
|
+
write_attributes = [
|
|
743
|
+
"email",
|
|
744
|
+
"name",
|
|
745
|
+
"custom:tenant_id",
|
|
746
|
+
]
|
|
747
|
+
|
|
748
|
+
lifecycle {
|
|
749
|
+
precondition {
|
|
750
|
+
condition = length(var.console_callback_urls) > 0
|
|
751
|
+
error_message = "console_callback_urls must be non-empty when console_client_enabled — register the console URL before first login or Cognito fails with redirect_mismatch."
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
depends_on = [
|
|
756
|
+
aws_cognito_identity_provider.google,
|
|
757
|
+
aws_cognito_identity_provider.microsoft_organizations,
|
|
758
|
+
aws_cognito_identity_provider.oidc,
|
|
759
|
+
aws_cognito_identity_provider.saml,
|
|
760
|
+
]
|
|
761
|
+
}
|
|
762
|
+
|
|
471
763
|
################################################################################
|
|
472
764
|
# Identity Pool
|
|
473
765
|
################################################################################
|
|
@@ -477,16 +769,34 @@ resource "aws_cognito_identity_pool" "main" {
|
|
|
477
769
|
identity_pool_name = var.identity_pool_name != "" ? var.identity_pool_name : "thinkwork-${var.stage}-identity-pool"
|
|
478
770
|
allow_unauthenticated_identities = false
|
|
479
771
|
|
|
480
|
-
cognito_identity_providers {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
772
|
+
dynamic "cognito_identity_providers" {
|
|
773
|
+
for_each = local.workos_rollback_enabled ? {
|
|
774
|
+
admin = aws_cognito_user_pool_client.admin[0].id
|
|
775
|
+
mobile = aws_cognito_user_pool_client.mobile[0].id
|
|
776
|
+
} : {}
|
|
777
|
+
content {
|
|
778
|
+
client_id = cognito_identity_providers.value
|
|
779
|
+
provider_name = "cognito-idp.${var.region}.amazonaws.com/${aws_cognito_user_pool.main[0].id}"
|
|
780
|
+
server_side_token_check = false
|
|
781
|
+
}
|
|
484
782
|
}
|
|
485
783
|
|
|
486
|
-
cognito_identity_providers {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
784
|
+
dynamic "cognito_identity_providers" {
|
|
785
|
+
for_each = aws_cognito_user_pool_client.auth_route
|
|
786
|
+
content {
|
|
787
|
+
client_id = cognito_identity_providers.value.id
|
|
788
|
+
provider_name = "cognito-idp.${var.region}.amazonaws.com/${aws_cognito_user_pool.main[0].id}"
|
|
789
|
+
server_side_token_check = true
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
dynamic "cognito_identity_providers" {
|
|
794
|
+
for_each = aws_cognito_user_pool_client.console
|
|
795
|
+
content {
|
|
796
|
+
client_id = cognito_identity_providers.value.id
|
|
797
|
+
provider_name = "cognito-idp.${var.region}.amazonaws.com/${aws_cognito_user_pool.main[0].id}"
|
|
798
|
+
server_side_token_check = true
|
|
799
|
+
}
|
|
490
800
|
}
|
|
491
801
|
|
|
492
802
|
tags = {
|
|
@@ -520,21 +830,6 @@ resource "aws_iam_role" "authenticated" {
|
|
|
520
830
|
})
|
|
521
831
|
}
|
|
522
832
|
|
|
523
|
-
resource "aws_iam_role_policy" "authenticated_appsync" {
|
|
524
|
-
count = local.create ? 1 : 0
|
|
525
|
-
name = "appsync-access"
|
|
526
|
-
role = aws_iam_role.authenticated[0].id
|
|
527
|
-
|
|
528
|
-
policy = jsonencode({
|
|
529
|
-
Version = "2012-10-17"
|
|
530
|
-
Statement = [{
|
|
531
|
-
Effect = "Allow"
|
|
532
|
-
Action = "appsync:GraphQL"
|
|
533
|
-
Resource = "*"
|
|
534
|
-
}]
|
|
535
|
-
})
|
|
536
|
-
}
|
|
537
|
-
|
|
538
833
|
resource "aws_cognito_identity_pool_roles_attachment" "main" {
|
|
539
834
|
count = local.create ? 1 : 0
|
|
540
835
|
identity_pool_id = aws_cognito_identity_pool.main[0].id
|
|
@@ -18,6 +18,11 @@ output "mobile_client_id" {
|
|
|
18
18
|
value = local.mobile_client_id
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
output "console_client_id" {
|
|
22
|
+
description = "App client ID for the optional Company Brain console client (null while console_client_enabled = false)"
|
|
23
|
+
value = one(aws_cognito_user_pool_client.console[*].id)
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
output "identity_pool_id" {
|
|
22
27
|
description = "Identity pool ID (created or existing)"
|
|
23
28
|
value = local.identity_pool_id
|
|
@@ -32,3 +37,45 @@ output "identity_provider_names" {
|
|
|
32
37
|
description = "Supported Cognito identity providers for created app clients."
|
|
33
38
|
value = local.identity_providers
|
|
34
39
|
}
|
|
40
|
+
|
|
41
|
+
output "auth_route_clients" {
|
|
42
|
+
description = "Safe app-client-to-route manifest. Contains no upstream provider secrets."
|
|
43
|
+
value = local.create ? {
|
|
44
|
+
for key, client in aws_cognito_user_pool_client.auth_route : key => {
|
|
45
|
+
client_id = client.id
|
|
46
|
+
route_key = local.auth_routes[key].route_key
|
|
47
|
+
client_family = local.auth_routes[key].client_family
|
|
48
|
+
provider_names = local.auth_routes[key].provider_names
|
|
49
|
+
explicit_auth_flows = local.auth_routes[key].explicit_auth_flows
|
|
50
|
+
callback_urls = distinct(local.auth_routes[key].callback_urls)
|
|
51
|
+
logout_urls = distinct(local.auth_routes[key].logout_urls)
|
|
52
|
+
lifecycle_state = "native"
|
|
53
|
+
}
|
|
54
|
+
} : var.existing_auth_route_clients
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
output "auth_retirement_phase" {
|
|
58
|
+
description = "Applied authentication retirement phase used for safe controller upgrades."
|
|
59
|
+
value = var.auth_retirement_phase
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
output "web_local_client_id" {
|
|
63
|
+
description = "Local-password-only Cognito app client for the web client family."
|
|
64
|
+
value = local.create ? aws_cognito_user_pool_client.auth_route["web:local"].id : try(
|
|
65
|
+
var.existing_auth_route_clients["web:local"].client_id,
|
|
66
|
+
null,
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
output "mobile_local_client_id" {
|
|
71
|
+
description = "Local-password-only Cognito app client for the mobile client family."
|
|
72
|
+
value = local.create ? aws_cognito_user_pool_client.auth_route["mobile:local"].id : try(
|
|
73
|
+
var.existing_auth_route_clients["mobile:local"].client_id,
|
|
74
|
+
null,
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
output "microsoft_identity_provider_name" {
|
|
79
|
+
description = "Default tenant-specific Microsoft Cognito provider name, or null when not configured."
|
|
80
|
+
value = var.microsoft_oauth_client_id != "" ? "MicrosoftOrganizations" : null
|
|
81
|
+
}
|