░▒▓████████████████████████████████▓▒░ ░▒▓█ ▓▒░ ░▒▓█ ~ S W A M P ~ ▓▒░ ░▒▓█ ▓▒░ ░▒▓████████████████████████████████▓▒░
pplmvsvm
LOCATION:
/var/www/canvas/lib/canvas/oauth/grant_types
☗ ROOT
↻ REFRESH
✎ CARVE FLESH
EDITING: client_credentials.rb
# frozen_string_literal: true # # Copyright (C) 2018 - present Instructure, Inc. # # This file is part of Canvas. # # Canvas is free software: you can redistribute it and/or modify it under # the terms of the GNU Affero General Public License as published by the Free # Software Foundation, version 3 of the License. # # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more # details. # # You should have received a copy of the GNU Affero General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. require_relative "../client_credentials_provider" module Canvas::OAuth module GrantTypes class ClientCredentials < BaseType def initialize(opts, host, protocol = nil) # rubocop:disable Lint/MissingSuper if opts[:client_assertion_type] == "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" raw_jwt = opts.fetch(:client_assertion) @provider = Canvas::OAuth::AsymmetricClientCredentialsProvider.new(raw_jwt, host, scopes_from_opts(opts), protocol) @secret = @provider.key&.api_key else client_id = opts.fetch(:client_id) @provider = Canvas::OAuth::SymmetricClientCredentialsProvider.new(client_id, host, scopes_from_opts(opts), protocol) if @provider.key&.client_credentials_audience != "external" raise Canvas::OAuth::InvalidRequestError, "assertion method not supported for this grant_type" end @secret = opts.fetch(:client_secret) end end def supported_type? true end private def validate_type raise Canvas::OAuth::InvalidRequestError, @provider.error_message unless @provider.valid? raise Canvas::OAuth::InvalidScopeError, @provider.missing_scopes unless @provider.valid_scopes? end def generate_token @provider.generate_token end def basic_auth?(opts) opts[:client_assertion_type] != "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" end def scopes_from_opts(opts) (opts[:scope] || opts[:scopes] || "").split end end end end
CANCEL
Name
Type
Size
Modified
Actions
↩ ..
DIR
—
—
📄 authorization_code.rb
RB
827 B
2023-09-24 03:36
EDIT
📄 base_type.rb
RB
836 B
2023-09-24 03:36
EDIT
📄 client_credentials.rb
RB
2.3 KB
2023-09-24 03:36
EDIT
📄 refresh_token.rb
RB
709 B
2023-09-24 03:36
EDIT