Sha256: 31e97b2e30e607be93238b451d8ac21a90553f0965da2c03172bc70cfa3065c5

Contents?: true

Size: 998 Bytes

Versions: 9

Compression:

Stored size: 998 Bytes

Contents

# frozen_string_literal: true

module Rodauth
  Feature.define(:oauth_client_credentials_grant, :OauthClientCredentialsGrant) do
    depends :oauth_base

    auth_value_method :use_oauth_client_credentials_grant_type?, false

    private

    def create_oauth_token(grant_type)
      return super unless grant_type == "client_credentials" && use_oauth_client_credentials_grant_type?

      create_params = {
        oauth_tokens_oauth_application_id_column => oauth_application[oauth_applications_id_column],
        oauth_tokens_scopes_column => scopes.join(oauth_scope_separator)
      }
      generate_oauth_token(create_params, false)
    end

    def oauth_server_metadata_body(*)
      super.tap do |data|
        data[:grant_types_supported] << "client_credentials" if use_oauth_client_credentials_grant_type?
      end
    end

    def check_valid_response_type?
      return true if use_oauth_implicit_grant_type? && param_or_nil("response_type") == "token"

      super
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rodauth-oauth-0.10.4 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.10.3 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.10.2 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.10.1 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.10.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.9.3 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.9.2 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.9.1 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-0.9.0 lib/rodauth/features/oauth_client_credentials_grant.rb