@@ -22,6 +22,12 @@ resource "ory_oauth2_client" "api_service" {
2222 grant_types = ["client_credentials"]
2323 token_endpoint_auth_method = "client_secret_post"
2424 scope = "read write admin"
25+ audience = ["https://api.example.com"]
26+ access_token_strategy = "jwt"
27+ contacts = ["api-team@example.com"]
28+
29+ # Custom token lifespans for this client
30+ client_credentials_grant_access_token_lifespan = "30m"
2531}
2632
2733# Web application (Authorization Code flow) with OIDC logout and metadata
@@ -37,21 +43,43 @@ resource "ory_oauth2_client" "web_app" {
3743 token_endpoint_auth_method = "client_secret_basic"
3844 scope = "openid profile email offline_access"
3945
46+ # First-party app: skip consent and logout consent screens
47+ skip_consent = true
48+ skip_logout_consent = true
49+ subject_type = "pairwise"
50+ contacts = ["web-team@example.com"]
51+
4052 # Client metadata URIs
4153 client_uri = "https://app.example.com"
4254 logo_uri = "https://app.example.com/logo.png"
4355 policy_uri = "https://app.example.com/privacy"
4456 tos_uri = "https://app.example.com/terms"
4557
46- # OIDC logout
47- frontchannel_logout_uri = "https://app.example.com/logout/frontchannel"
48- backchannel_logout_uri = "https://app.example.com/logout/backchannel"
58+ # OIDC logout with session notifications
59+ frontchannel_logout_uri = "https://app.example.com/logout/frontchannel"
60+ frontchannel_logout_session_required = true
61+ backchannel_logout_uri = "https://app.example.com/logout/backchannel"
62+ backchannel_logout_session_required = true
4963
5064 # Per-client CORS
5165 allowed_cors_origins = [
5266 "https://app.example.com",
5367 "https://admin.example.com"
5468 ]
69+
70+ # Per-grant token lifespans
71+ authorization_code_grant_access_token_lifespan = "1h"
72+ authorization_code_grant_id_token_lifespan = "1h"
73+ authorization_code_grant_refresh_token_lifespan = "720h"
74+ refresh_token_grant_access_token_lifespan = "1h"
75+ refresh_token_grant_id_token_lifespan = "1h"
76+ refresh_token_grant_refresh_token_lifespan = "720h"
77+
78+ # Custom metadata
79+ metadata = jsonencode({
80+ department = "engineering"
81+ tier = "internal"
82+ })
5583}
5684
5785# Client with custom token lifespans
@@ -81,6 +109,15 @@ resource "ory_oauth2_client" "spa" {
81109 scope = "openid profile email"
82110}
83111
112+ # Device Authorization flow (CLI tools, IoT devices)
113+ resource "ory_oauth2_client" "cli_tool" {
114+ client_name = "CLI Tool"
115+ grant_types = ["urn:ietf:params:oauth:grant-type:device_code", "refresh_token"]
116+ response_types = ["code"]
117+ token_endpoint_auth_method = "none"
118+ scope = "openid offline_access"
119+ }
120+
84121output "api_service_client_id" {
85122 value = ory_oauth2_client.api_service.client_id
86123}
0 commit comments