Sha256: 8134dd09a2b254bec9bced9013dfbad6acb6b653de121cb95b9de7ee1d994b54

Contents?: true

Size: 1.01 KB

Versions: 13

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require "rodauth/oauth"

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

    def oauth_grant_types_supported
      super | %w[client_credentials]
    end

    private

    def create_token(grant_type)
      return super unless supported_grant_type?(grant_type, "client_credentials")

      grant_scopes = scopes

      grant_scopes = if grant_scopes
                       redirect_response_error("invalid_scope") unless check_valid_scopes?
                       grant_scopes.join(oauth_scope_separator)
                     else
                       oauth_application[oauth_applications_scopes_column]
                     end

      grant_params = {
        oauth_grants_type_column => "client_credentials",
        oauth_grants_oauth_application_id_column => oauth_application[oauth_applications_id_column],
        oauth_grants_scopes_column => grant_scopes
      }
      generate_token(grant_params, false)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rodauth-oauth-1.6.3 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.6.2 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.6.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.5.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.4.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.3.2 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.3.1 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.3.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.2.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.1.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.0.0 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.0.0.pre.beta2 lib/rodauth/features/oauth_client_credentials_grant.rb
rodauth-oauth-1.0.0.pre.beta1 lib/rodauth/features/oauth_client_credentials_grant.rb