# Dex configuration for SAP Cloud Identity Services - Identity Authentication (IAS), OpenID Connect
# Prerequisites in the IAS administration console:
# 1. An application with protocol type OpenID Connect, grant type Authorization Code
# 2. Redirect URI <base URL>/dex/callback
# 3. A client secret (Trust > Application APIs > Client Authentication)
# 4. User groups for the administrator and user roles

issuer: BASE_URL/dex

storage:
  type: postgres
  config:
    host: postgres
    port: 5432
    database: sap_llm_gateway
    user: admin_user
    password: admin_password
    ssl:
      mode: disable

web:
  http: 0.0.0.0:5556
  allowedOrigins: ["BASE_URL", "http://localhost:5556"]

logger:
  level: info
  format: json

oauth2:
  skipApprovalScreen: false
  responseTypes: ["code"]
  grantTypes: ["authorization_code", "refresh_token"]

staticClients:
- id: oauth2-proxy
  redirectURIs:
  - 'BASE_URL/auth/callback'
  name: 'SAP LLM Gateway OAuth2 Proxy'
  secret: __OAUTH2_PROXY_CLIENT_SECRET__
  trustedPeers:
  - oauth2-proxy

connectors:
- type: oidc
  id: sap-ias
  name: SAP Cloud Identity Services
  config:
    # The tenant's issuer, exactly as its discovery document
    # (<tenant>/.well-known/openid-configuration) states it
    issuer: IAS_ISSUER_URL

    # Client ID and secret of the IAS application
    clientID: IAS_CLIENT_ID
    clientSecret: IAS_CLIENT_SECRET

    # Callback URL (must be a redirect URI of the IAS application)
    redirectURI: BASE_URL/dex/callback

    # The "groups" scope puts the names of the user's groups into the ID token's "groups" claim
    scopes:
    - email
    - profile
    - groups
    insecureEnableGroups: true

    # IAS sends no "name" claim by default, and Dex refuses a login without its user-name claim
    userNameKey: email

    # The tenant is the authority for its users' e-mail addresses
    insecureSkipEmailVerified: true

enablePasswordDB: false
