# Completed Identity + AI Gateway walkthrough state.
# Apply only after the separate adoption/enablement steps for existing default.
# Requires local public files and the environment described in the lessons.
_defaults:
  kongctl:
    namespace: identity-guide

identity:
  directories:
    - ref: default-directory
      name: default
      kongctl:
        namespace: identity-guide-directory
      vault:
        enabled: true
        keys:
          - ref: support-encryption-key
            name: identity-guide-encryption
            public_key: !file ./vault-public.pem
        providers:
          - ref: support-ticketing
            name: identity-guide-ticketing
            template_name: static_secret
            credential_type: shared
            enabled: true
            shared_credentials:
              - ref: support-ticketing-token
                secret: !secret { source: !env SUPPORT_TICKETING_TOKEN }
      trusted_idps:
        - ref: guide-trust
          issuer_url: !env IDENTITY_GUIDE_ISSUER
          display_name: Identity guide issuer
          jwks_uri: !env IDENTITY_GUIDE_JWKS_URI
          jit_provisioning_enabled: false
          vault_access_enabled: true

  principals:
    - ref: support-worker
      directory: default-directory
      type: agent
      display_name: Guide support automation
      description: Automation principal for the Identity guide
      api_keys:
        - ref: support-worker-primary
          type: v1
          name: Guide support automation key
          expires_at: null
      metadata:
        department: support
        role: assistant
      labels:
        application: identity-guide
      identities:
        - ref: support-worker-number
          type: custom
          key: employee_id
          value: identity-guide-worker-001
    - ref: support-operator
      directory: default-directory
      type: user
      display_name: Guide support operator
      description: Human principal for the Identity guide
      metadata:
        department: support
        role: operator
      labels:
        application: identity-guide

  auth_servers:
    - ref: guide-issuer
      name: identity-guide-issuer
      description: Demonstration issuer for the Identity guide
      audience: https://support.example.test
      signing_algorithm: RS256

ai_gateways:
  - ref: guide-gateway
    name: identity-guide-gateway
    display_name: Identity Guide Gateway
    description: AI Gateway using principals from the default Identity directory
    deployment_type: hybrid
    min_runtime_version: "2.3"
    runtime_auto_upgrade: false
    proxy_urls:
      - host: localhost
        port: 8000
        protocol: http
    labels:
      application: identity-guide
    auth_strategies:
      - ref: directory-key-auth
        name: directory-key-auth
        display_name: Default directory API keys
        type: key-auth
        config:
          key_names:
            - apikey
          hide_credentials: true
          identity_realms: []
          principals:
            enabled: true
            directory: default
            error_on_miss: true
    policies:
      - ref: guide-mock-response
        name: guide-mock-response
        display_name: Guide mock response
        type: mocking
        enabled: false
        global: false
        config:
          api_specification: |
            openapi: 3.0.0
            info:
              title: Support demo
              version: 1.0.0
            paths:
              /v1/chat/completions:
                post:
                  responses:
                    '200':
                      description: Synthetic support response
                      content:
                        application/json:
                          example:
                            id: chatcmpl-identity-guide
                            object: chat.completion
                            model: identity-guide
                            choices:
                              - index: 0
                                finish_reason: stop
                                message:
                                  role: assistant
                                  content: "Hello from the authenticated support demo."
    model_providers:
      - ref: guide-provider
        name: guide-provider
        display_name: Guide model provider
        type: openai
        config:
          auth:
            type: basic
            headers: []
        datastores:
          - name: !ref guide-token-storage#name
        token_vault:
          provider: identity-guide-ticketing
          subject_token_type: api_key
          credential:
            inbound:
              location: header
              name: Authorization
              prefix: "Bearer "
            outbound:
              location: header
              name: Authorization
              prefix: "Bearer "
    models:
      - ref: identity-guide-model
        name: identity-guide-model
        display_name: Guide model
        type: model
        formats:
          - type: openai
        config:
          route:
            paths:
              - /v1
            model:
              body_param: model
              values:
                - identity-guide
        targets:
          - name: gpt-4o
            provider: !ref guide-provider#name
            config:
              type: openai
              upstream_url: http://127.0.0.1:18080/v1/chat/completions
        policies:
          - !ref guide-mock-response#name
        access:
          auth_strategies:
            - !ref directory-key-auth#name
          acls:
            allow_when:
              - "has(principal.metadata.role) && principal.metadata.role == 'assistant'"
        capabilities:
          - generate
    data_plane_certificates:
      - ref: identity-guide-data-plane
        title: identity-guide-data-plane
        description: Local guide runtime
        cert: !file ./certs/data-plane.crt
    vaults:
      - ref: guide-private-keys
        name: guide-private-keys
        type: env
        description: Resolve the local runtime encryption key
        config:
          prefix: IDENTITY_GUIDE_VAULT_
    datastores:
      - ref: guide-token-storage
        name: guide-token-storage
        display_name: Guide Token Vault storage
        type: token-vault
        config:
          directory: default
          current_version: v1
          keys:
            - version: v1
              key: "{vault://guide-private-keys/private-key}"
