parameters:
  simple_oauth.openid.scope: 'openid'
  simple_oauth.openid.claims:
    - sub
    - name
    - preferred_username
    - email
    - email_verified
    - locale
    - profile
    - updated_at
    - zoneinfo
services:
  simple_oauth.authentication.simple_oauth:
    class: Drupal\simple_oauth\Authentication\Provider\SimpleOauthAuthenticationProvider
    arguments:
      - '@simple_oauth.server.resource_server'
      - '@entity_type.manager'
      - '@simple_oauth.page_cache_request_policy.disallow_oauth2_token_requests'
    tags:
      - { name: authentication_provider, provider_id: oauth2, global: TRUE, priority: 35 }
  simple_oauth.page_cache_request_policy.disallow_oauth2_token_requests:
    class: Drupal\simple_oauth\PageCache\DisallowSimpleOauthRequests
    public: false
    tags:
      - { name: page_cache_request_policy }

  simple_oauth.normalizer.oauth2_token:
    class: Drupal\simple_oauth\Normalizer\TokenEntityNormalizer
    arguments: [ '@entity_type.manager' ]
    tags:
      - { name: normalizer, priority: 21 }
  simple_oauth.normalizer.oauth2_refresh_token:
    class: Drupal\simple_oauth\Normalizer\RefreshTokenEntityNormalizer
    tags:
      - { name: normalizer, priority: 20 }
  simple_oauth.server.resource_server:
    class: Drupal\simple_oauth\Server\ResourceServer
    arguments:
      - '@simple_oauth.repositories.access_token'
      - '@config.factory'
      - '@psr7.http_message_factory'
      - '@psr7.http_foundation_factory'
  simple_oauth.repositories.client:
    class: Drupal\simple_oauth\Repositories\ClientRepository
    arguments: [ '@entity_type.manager', '@password' ]
  simple_oauth.repositories.scope:
    class: Drupal\simple_oauth\Repositories\ScopeRepository
    arguments: [ '@entity_type.manager' ]
  simple_oauth.repositories.user:
    class: Drupal\simple_oauth\Repositories\UserRepository
    arguments: [ '@user.auth' ]
  simple_oauth.repositories.access_token:
    class: Drupal\simple_oauth\Repositories\AccessTokenRepository
    arguments: [ '@entity_type.manager', '@serializer' ]
  simple_oauth.repositories.refresh_token:
    class: Drupal\simple_oauth\Repositories\RefreshTokenRepository
    arguments: [ '@entity_type.manager', '@serializer' ]
  simple_oauth.repositories.auth_code:
    class: Drupal\simple_oauth\Repositories\AuthCodeRepository
    arguments: [ '@entity_type.manager', '@serializer' ]
  simple_oauth.server.response_type:
    class: \OpenIDConnectServer\IdTokenResponse
    arguments:
      - '@Drupal\simple_oauth\OpenIdConnect\UserIdentityProvider'
      - '@OpenIDConnectServer\ClaimExtractor'
  plugin.manager.oauth2_grant.processor:
    class: Drupal\simple_oauth\Plugin\Oauth2GrantManager
    parent: default_plugin_manager
    arguments:
      - '@simple_oauth.repositories.client'
      - '@simple_oauth.repositories.scope'
      - '@simple_oauth.repositories.access_token'
      - '@simple_oauth.repositories.refresh_token'
      - '@config.factory'
      - '@simple_oauth.server.response_type'
  simple_oauth.expired_collector:
    class: Drupal\simple_oauth\ExpiredCollector
    arguments: [ '@entity_type.manager', '@datetime.time' ]
  simple_oauth.http_middleware.basic_auth_swap:
    class: Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap
    tags:
      - { name: http_middleware }
  # Keys Generator Services
  simple_oauth.filesystem_checker:
    class: Drupal\simple_oauth\Service\Filesystem\FileSystemChecker
    arguments: [ '@file_system' ]
  simple_oauth.key.generator:
    class: Drupal\simple_oauth\Service\KeyGeneratorService
    arguments: [ '@simple_oauth.filesystem_checker', '@file_system' ]
  simple_oauth.known_clients:
    class: \Drupal\simple_oauth\KnownClientsRepository
    arguments: [ '@user.data' ]

  # Services for OpenID Connect.
  Drupal\simple_oauth\OpenIdConnect\UserIdentityProvider:
    arguments: [ '@entity_type.manager' ]
  OpenIDConnectServer\Entities\ClaimSetEntity:
    arguments: [ '%simple_oauth.openid.scope%', '%simple_oauth.openid.claims%' ]
    private: true
  OpenIDConnectServer\ClaimExtractor:
    arguments: [ [ '@OpenIDConnectServer\Entities\ClaimSetEntity' ] ]
  Drupal\simple_oauth\OpenIdConnect\OpenIdConnectScopeRepository:
    public: false
    decorates: simple_oauth.repositories.scope
    arguments: [ '@Drupal\simple_oauth\OpenIdConnect\OpenIdConnectScopeRepository.inner' ]
  simple_oauth.openid_connect.user_claims_normalizer:
    class: Drupal\simple_oauth\Normalizer\UserClaimsNormalizer
    arguments: [ '@entity_type.manager', '%simple_oauth.openid.claims%', '@module_handler' ]
    tags:
      - { name: normalizer, priority: 21 }
