Class: Clavis::Providers::Microsoft

Inherits:
Base
  • Object
show all
Defined in:
lib/clavis/providers/microsoft.rb

Instance Attribute Summary

Attributes inherited from Base

#authorize_endpoint_url, #client_id, #client_secret, #provider_name, #redirect_uri, #scope, #token_endpoint_url, #userinfo_endpoint_url

Instance Method Summary collapse

Methods inherited from Base

#authorize_url, #get_user_info, #process_callback, #refresh_token, #token_exchange

Methods included from TokenExchangeHandler

#build_token_exchange_params, #handle_connection_error, #handle_error_response, #handle_faraday_error, #handle_parser_error, #handle_standard_error, #make_token_request, #parse_response, #skip_error_for_test?, #test_token_response, #validate_and_clean_code

Constructor Details

#initialize(config = {}) ⇒ Microsoft



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/clavis/providers/microsoft.rb', line 6

def initialize(config = {})
  @tenant = config[:tenant] || "common"

  # Set endpoints based on tenant
  config[:authorization_endpoint] = "https://login.microsoftonline.com/#{@tenant}/oauth2/v2.0/authorize"
  config[:token_endpoint] = "https://login.microsoftonline.com/#{@tenant}/oauth2/v2.0/token"
  config[:userinfo_endpoint] = "https://graph.microsoft.com/v1.0/me"
  config[:scope] = config[:scope] || "openid email profile User.Read"

  super
end

Instance Method Details

#authorization_endpointObject



18
19
20
# File 'lib/clavis/providers/microsoft.rb', line 18

def authorization_endpoint
  "https://login.microsoftonline.com/#{tenant}/oauth2/v2.0/authorize"
end

#default_scopesObject



30
31
32
# File 'lib/clavis/providers/microsoft.rb', line 30

def default_scopes
  "openid email profile User.Read"
end

#openid_provider?Boolean



34
35
36
# File 'lib/clavis/providers/microsoft.rb', line 34

def openid_provider?
  true
end

#token_endpointObject



22
23
24
# File 'lib/clavis/providers/microsoft.rb', line 22

def token_endpoint
  "https://login.microsoftonline.com/#{tenant}/oauth2/v2.0/token"
end

#userinfo_endpointObject



26
27
28
# File 'lib/clavis/providers/microsoft.rb', line 26

def userinfo_endpoint
  "https://graph.microsoft.com/v1.0/me"
end