microsoft_kiota_authentication_oauth 0.9.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/Rakefile +0 -1
- data/lib/microsoft_kiota_authentication_oauth/contexts/authorization_code_context.rb +11 -11
- data/lib/microsoft_kiota_authentication_oauth/contexts/client_credential_context.rb +10 -12
- data/lib/microsoft_kiota_authentication_oauth/contexts/oauth_context.rb +19 -19
- data/lib/microsoft_kiota_authentication_oauth/contexts/oauth_custom_flow.rb +19 -19
- data/lib/microsoft_kiota_authentication_oauth/contexts/on_behalf_of_context.rb +57 -58
- data/lib/microsoft_kiota_authentication_oauth/extensions/oauth2_ext.rb +2 -2
- data/lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb +16 -20
- data/lib/microsoft_kiota_authentication_oauth/oauth_authentication_provider.rb +5 -2
- data/lib/microsoft_kiota_authentication_oauth/version.rb +1 -1
- data/lib/microsoft_kiota_authentication_oauth.rb +9 -9
- data/microsoft_kiota_authentication_oauth.gemspec +16 -19
- metadata +12 -39
- data/.github/CODEOWNERS +0 -1
- data/.github/copilot-instructions.md +0 -25
- data/.github/dependabot.yml +0 -12
- data/.github/policies/kiota-authentication-oauth-ruby-branch-protection.yml +0 -40
- data/.github/policies/resourceManagement.yml +0 -101
- data/.github/release-please.yml +0 -3
- data/.github/workflows/auto-merge-dependabot.yml +0 -33
- data/.github/workflows/code-ql.yml +0 -77
- data/.github/workflows/conflicting-pr-label.yml +0 -39
- data/.github/workflows/release-please-gha.yml +0 -49
- data/.github/workflows/release.yml +0 -36
- data/.github/workflows/ruby.yml +0 -48
- data/.gitignore +0 -58
- data/.release-please-manifest.json +0 -3
- data/CHANGELOG.md +0 -52
- data/CODE_OF_CONDUCT.md +0 -10
- data/CONTRIBUTING.md +0 -56
- data/LICENSE +0 -21
- data/README.md +0 -53
- data/SECURITY.md +0 -41
- data/SUPPORT.md +0 -25
- data/release-please-config.json +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82ed630929535ee9d3706aae735558670c1b4d021c2af0effa3491950463565e
|
|
4
|
+
data.tar.gz: 15585325c7c5e147d46b0983560e8be79bbf5aef076c5b82c6dd23b958c84600
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55e80e5c595826808ed5c61e03a8cc46444a543a964fb59dce834f3bc252f2f1865af955dd797fc9135eed9b4beeacec6c25d23942b502292ac922d6398cee21
|
|
7
|
+
data.tar.gz: 68d000b833158b6c3237a12a42eca6270196182a3a9ffcdcf525e99f0a99b47b106aa7abd0513f00d5361be7afc5b6b2e572826ae1236429b03ecfa39ee81e75
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'oauth2'
|
|
4
|
-
require_relative '
|
|
4
|
+
require_relative 'oauth_context'
|
|
5
5
|
|
|
6
6
|
module MicrosoftKiotaAuthenticationOAuth
|
|
7
7
|
# Token request context class for the authorization code grant type.
|
|
@@ -11,10 +11,10 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
11
11
|
attr_writer :scopes
|
|
12
12
|
|
|
13
13
|
# This is the initializer for AuthorizationCodeContext, the token request context when
|
|
14
|
-
# using the authorization code grant flow.
|
|
14
|
+
# using the authorization code grant flow.
|
|
15
15
|
# :params
|
|
16
|
-
# tenant_id: a string containing the tenant id
|
|
17
|
-
# client_id: a string containing the client id
|
|
16
|
+
# tenant_id: a string containing the tenant id
|
|
17
|
+
# client_id: a string containing the client id
|
|
18
18
|
# client_secret: a string containing the client secret
|
|
19
19
|
# redirect_uri: a string containing redirect_uri
|
|
20
20
|
# auth_code: a string containting the auth code; default is nil, can be updated post-initialization
|
|
@@ -49,11 +49,11 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
49
49
|
# default is empty hash
|
|
50
50
|
def generate_authorize_url(scopes, additional_params = {})
|
|
51
51
|
@additional_params = additional_params
|
|
52
|
-
|
|
53
|
-
self.initialize_scopes(scopes)
|
|
54
|
-
self.initialize_oauth_provider
|
|
55
52
|
|
|
56
|
-
|
|
53
|
+
initialize_scopes(scopes)
|
|
54
|
+
initialize_oauth_provider
|
|
55
|
+
|
|
56
|
+
parameters = { scope: @scopes, redirect_uri: @redirect_uri, access_type: 'offline', prompt: 'consent' }
|
|
57
57
|
parameters = parameters.merge(additional_params)
|
|
58
58
|
@oauth_provider.auth_code.authorize_url(parameters)
|
|
59
59
|
end
|
|
@@ -71,10 +71,10 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
71
71
|
|
|
72
72
|
def initialize_scopes(scopes)
|
|
73
73
|
scope_str = ''
|
|
74
|
-
scopes.each { |scope| scope_str += scope
|
|
74
|
+
scopes.each { |scope| scope_str += "#{scope} " }
|
|
75
75
|
raise StandardError, 'scopes cannot be empty/nil.' if scope_str.empty?
|
|
76
|
-
|
|
77
|
-
scope_str =
|
|
76
|
+
|
|
77
|
+
scope_str = "offline_access #{scope_str}"
|
|
78
78
|
|
|
79
79
|
@scopes = scope_str
|
|
80
80
|
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'oauth2'
|
|
4
|
-
require_relative '
|
|
4
|
+
require_relative 'oauth_context'
|
|
5
5
|
|
|
6
6
|
module MicrosoftKiotaAuthenticationOAuth
|
|
7
7
|
# Token request context class for the client credential grant type.
|
|
8
8
|
class ClientCredentialContext < MicrosoftKiotaAuthenticationOAuth::OAuthContext
|
|
9
9
|
attr_reader :grant_type, :additional_params, :tenant_id, :client_id, :client_secret, :oauth_provider
|
|
10
|
-
attr_writer :scopes
|
|
10
|
+
attr_writer :scopes
|
|
11
11
|
|
|
12
12
|
# This is the initializer for ClientCredentialContext, the token request context when
|
|
13
|
-
# using the client credential grant flow.
|
|
13
|
+
# using the client credential grant flow.
|
|
14
14
|
# :params
|
|
15
|
-
# tenant_id: a string containing the tenant id
|
|
16
|
-
# client_id: a string containing the client id
|
|
15
|
+
# tenant_id: a string containing the tenant id
|
|
16
|
+
# client_id: a string containing the client id
|
|
17
17
|
# client_secret: a string containing the client secret
|
|
18
18
|
# additional_params: hash of symbols to string values, ie { response_mode: 'fragment', prompt: 'login' }
|
|
19
19
|
# default is empty hash
|
|
@@ -26,7 +26,6 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
26
26
|
@oauth_provider = nil
|
|
27
27
|
@grant_type = 'client credential'
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
if @tenant_id.nil? || @client_id.nil? || @client_secret.nil? || @tenant_id.empty? || @client_id.empty? || @client_secret.empty?
|
|
31
30
|
raise StandardError, 'tenant_id, client_id and client_secret cannot be empty'
|
|
32
31
|
end
|
|
@@ -38,20 +37,19 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
38
37
|
|
|
39
38
|
def initialize_oauth_provider
|
|
40
39
|
@oauth_provider = OAuth2::Client.new(@client_id, @client_secret,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
site: 'https://login.microsoftonline.com',
|
|
41
|
+
authorize_url: "/#{@tenant_id}/oauth2/v2.0/authorize",
|
|
42
|
+
token_url: "/#{@tenant_id}/oauth2/v2.0/token")
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
# Function to initialize the scope for the client credential context object.
|
|
47
46
|
# Only a single scope is supported for this flow and it's expected to be schme://service/.default
|
|
48
|
-
def initialize_scopes(scopes = [])
|
|
47
|
+
def initialize_scopes(scopes = [])
|
|
49
48
|
@scopes = scopes[0] unless scopes.empty?
|
|
50
49
|
end
|
|
51
50
|
|
|
52
|
-
|
|
53
51
|
private
|
|
54
|
-
|
|
52
|
+
|
|
55
53
|
attr_writer :grant_type, :additional_params, :tenant_id, :client_id, :client_secret, :oauth_provider
|
|
56
54
|
end
|
|
57
55
|
end
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'oauth2'
|
|
4
|
-
require_relative '
|
|
4
|
+
require_relative 'oauth_custom_flow'
|
|
5
5
|
|
|
6
6
|
module MicrosoftKiotaAuthenticationOAuth
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
include MicrosoftKiotaAuthenticationOAuth::OAuthCustomFlow
|
|
7
|
+
# Base class for token request contexs.
|
|
8
|
+
class OAuthContext
|
|
9
|
+
attr_accessor :scopes
|
|
10
|
+
attr_reader :oauth_provider
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
OAuthCustomFlow.get_token
|
|
15
|
-
end
|
|
12
|
+
include MicrosoftKiotaAuthenticationOAuth::OAuthCustomFlow
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
def get_token
|
|
15
|
+
OAuthCustomFlow.get_token
|
|
16
|
+
end
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
def initialize_scopes(_scopes = [])
|
|
19
|
+
@scopes = OAuthCustomFlow.get_scopes
|
|
20
|
+
end
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
def initialize_oauth_provider
|
|
23
|
+
@oauth_provider = OAuthCustomFlow.get_oauth_provider
|
|
24
|
+
end
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
private
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
end
|
|
28
|
+
attr_writer :oauth_provider
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
require 'oauth2'
|
|
4
4
|
|
|
5
5
|
module MicrosoftKiotaAuthenticationOAuth
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
# Module that can be optionally implemented for supporting custom token grant flows.
|
|
7
|
+
# To use a cutsom token grant flow, implement the functions below and
|
|
8
|
+
# use MicrosoftKiotaAuthenticationOAuth::OAuthContext.new as your token_request_context
|
|
9
|
+
# object for the use by the MicrosoftKiotaAuthenticationOAuth::OAuthAccessTokenProvider
|
|
10
|
+
module OAuthCustomFlow
|
|
11
|
+
# Function that returns an oauth client using the oauth2 gem
|
|
12
|
+
def self.get_oauth_provider
|
|
13
|
+
raise NotImplementedError
|
|
14
|
+
end
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
# Function that returns a space seperated string of scopes, beginning with
|
|
17
|
+
# the offline_access scope if relevant
|
|
18
|
+
def self.get_scopes
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
end
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
22
|
+
# Function that returns the access token
|
|
23
|
+
def self.get_token
|
|
24
|
+
raise NotImplementedError
|
|
26
25
|
end
|
|
27
|
-
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'oauth2'
|
|
4
|
-
require_relative '
|
|
4
|
+
require_relative 'oauth_context'
|
|
5
5
|
|
|
6
6
|
module MicrosoftKiotaAuthenticationOAuth
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
# Token request context class for the on behlaf of grant type.
|
|
8
|
+
class OnBehalfOfContext < MicrosoftKiotaAuthenticationOAuth::OAuthContext
|
|
9
|
+
attr_reader :grant_type, :additional_params, :tenant_id, :client_id, :client_secret, :oauth_provider
|
|
10
|
+
attr_writer :scopes
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
# This is the initializer for OnBehalfOfContext, the token request context when
|
|
13
|
+
# using the client credential grant flow.
|
|
14
|
+
# :params
|
|
15
|
+
# tenant_id: a string containing the tenant id
|
|
16
|
+
# client_id: a string containing the client id
|
|
17
|
+
# client_secret: a string containing the client secret
|
|
18
|
+
# assertion: string containing assertion (access token used in the request)
|
|
19
|
+
# additional_params: hash of symbols to string values, ie { response_mode: 'fragment', prompt: 'login' }
|
|
20
|
+
# default is empty hash
|
|
21
|
+
def initialize(tenant_id, client_id, client_secret, assertion, additional_params = {})
|
|
22
|
+
raise StandardError, 'assertion cannot be empty' if assertion.nil? || assertion.empty?
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if @tenant_id.nil? || @client_id.nil? || @client_secret.nil? || @client_secret.empty? || @tenant_id.empty? || @client_id.empty?
|
|
34
|
-
raise StandardError, 'tenant_id, client_secret, and client_id cannot be empty'
|
|
35
|
-
end
|
|
36
|
-
end
|
|
24
|
+
@tenant_id = tenant_id
|
|
25
|
+
@client_id = client_id
|
|
26
|
+
@client_secret = client_secret
|
|
27
|
+
@assertion = assertion
|
|
28
|
+
@additional_params = additional_params
|
|
29
|
+
@scopes = nil
|
|
30
|
+
@oauth_provider = nil
|
|
31
|
+
@grant_type = 'urn:ietf:params:Oauth:grant-type:jwt-bearer'
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
if @tenant_id.nil? || @client_id.nil? || @client_secret.nil? || @client_secret.empty? || @tenant_id.empty? || @client_id.empty?
|
|
34
|
+
raise StandardError, 'tenant_id, client_secret, and client_id cannot be empty'
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get_token
|
|
39
|
+
params = {
|
|
40
|
+
grant_type: @grant_type,
|
|
41
|
+
assertion: @assertion,
|
|
42
|
+
scope: @scopes,
|
|
43
|
+
requested_token_use: 'on_behalf_of'
|
|
44
|
+
}
|
|
45
|
+
@oauth_provider.on_behalf_of.get_token(params)
|
|
46
|
+
end
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
def initialize_oauth_provider
|
|
49
|
+
@oauth_provider = OAuth2::Client.new(@client_id, @client_secret,
|
|
50
|
+
site: 'https://login.microsoftonline.com',
|
|
51
|
+
authorize_url: "/#{@tenant_id}/oauth2/v2.0/authorize",
|
|
52
|
+
token_url: "/#{@tenant_id}/oauth2/v2.0/token")
|
|
53
|
+
end
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
raise StandardError, 'scopes cannot be empty/nil.' if scope_str.empty?
|
|
60
|
-
|
|
61
|
-
scope_str = 'offline_access ' + scope_str
|
|
62
|
-
|
|
63
|
-
@scopes = scope_str
|
|
64
|
-
end
|
|
55
|
+
def initialize_scopes(scopes)
|
|
56
|
+
scope_str = ''
|
|
57
|
+
scopes.each { |scope| scope_str += "#{scope} " }
|
|
65
58
|
|
|
66
|
-
|
|
59
|
+
raise StandardError, 'scopes cannot be empty/nil.' if scope_str.empty?
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
scope_str = "offline_access #{scope_str}"
|
|
62
|
+
|
|
63
|
+
@scopes = scope_str
|
|
71
64
|
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
attr_writer :grant_type, :additional_params, :tenant_id, :client_id,
|
|
69
|
+
:client_secret, :oauth_provider
|
|
70
|
+
end
|
|
72
71
|
end
|
|
@@ -5,7 +5,7 @@ require 'oauth2'
|
|
|
5
5
|
# Extension of Oauth2 Library to Include On Behalf Of Grant Type
|
|
6
6
|
module OAuth2
|
|
7
7
|
module Strategy
|
|
8
|
-
class OnBehalfOf < Base
|
|
8
|
+
class OnBehalfOf < Base
|
|
9
9
|
def get_token(params, response_opts = {})
|
|
10
10
|
@client.get_token(params, response_opts)
|
|
11
11
|
end
|
|
@@ -19,4 +19,4 @@ module OAuth2
|
|
|
19
19
|
@on_behalf_of ||= OAuth2::Strategy::OnBehalfOf.new(self)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
-
end
|
|
22
|
+
end
|
|
@@ -16,50 +16,49 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
16
16
|
# :params
|
|
17
17
|
# token_request_context: a instance of one of our token request context or a custom implementation
|
|
18
18
|
# allowed_hosts: an array of strings, where each string is an allowed host, default is empty
|
|
19
|
-
# scopes: an array of strings, where each string is a scope, default is empty array
|
|
19
|
+
# scopes: an array of strings, where each string is a scope, default is empty array
|
|
20
20
|
def initialize(token_request_context, allowed_hosts = [], scopes = [])
|
|
21
21
|
raise StandardError, 'Parameter token_request_context cannot be nil.' if token_request_context.nil?
|
|
22
22
|
|
|
23
23
|
@token_request_context = token_request_context
|
|
24
24
|
|
|
25
25
|
unless @token_request_context.is_a?(MicrosoftKiotaAuthenticationOAuth::OAuthContext)
|
|
26
|
-
raise StandardError,
|
|
26
|
+
raise StandardError,
|
|
27
|
+
'Parameter token_request_context must be an instance of one of our grant flow context classes.'
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
@cached_token = nil
|
|
30
31
|
|
|
31
|
-
@host_validator = if allowed_hosts.nil? || allowed_hosts.
|
|
32
|
+
@host_validator = if allowed_hosts.nil? || allowed_hosts.empty?
|
|
32
33
|
MicrosoftKiotaAbstractions::AllowedHostsValidator.new([])
|
|
33
34
|
else
|
|
34
35
|
MicrosoftKiotaAbstractions::AllowedHostsValidator.new(allowed_hosts)
|
|
35
36
|
end
|
|
36
37
|
@token_request_context.initialize_oauth_provider
|
|
37
|
-
if scopes.nil?
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
@scopes = if scopes.nil?
|
|
39
|
+
[]
|
|
40
|
+
else
|
|
41
|
+
scopes
|
|
42
|
+
end
|
|
42
43
|
end
|
|
43
44
|
|
|
44
45
|
# This function obtains the authorization token.
|
|
45
46
|
# :params
|
|
46
|
-
# uri: a string containing the uri
|
|
47
|
+
# uri: a string containing the uri
|
|
47
48
|
# additional_params: hash of symbols to string values, ie { response_mode: 'fragment', prompt: 'login' }
|
|
48
49
|
# default is empty hash
|
|
49
|
-
def get_authorization_token(uri,
|
|
50
|
+
def get_authorization_token(uri, _additional_properties = {})
|
|
50
51
|
nil if !uri || !@host_validator.url_host_valid?(uri)
|
|
51
52
|
|
|
52
53
|
parsed_url = URI(uri)
|
|
53
54
|
|
|
54
55
|
raise StandardError, 'Only https is supported' if parsed_url.scheme != 'https'
|
|
55
56
|
|
|
56
|
-
if @scopes.empty?
|
|
57
|
-
@scopes << "#{parsed_url.scheme}://#{parsed_url.host}/.default"
|
|
58
|
-
end
|
|
57
|
+
@scopes << "#{parsed_url.scheme}://#{parsed_url.host}/.default" if @scopes.empty?
|
|
59
58
|
@token_request_context.initialize_scopes(@scopes)
|
|
60
59
|
Fiber.new do
|
|
61
60
|
if @cached_token
|
|
62
|
-
token = OAuth2::AccessToken.from_hash(@token_request_context.oauth_provider, @cached_token)
|
|
61
|
+
token = OAuth2::AccessToken.from_hash(@token_request_context.oauth_provider, @cached_token)
|
|
63
62
|
token.token unless token.nil? || token.expired?
|
|
64
63
|
|
|
65
64
|
if token.expired?
|
|
@@ -69,23 +68,20 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
|
69
68
|
end
|
|
70
69
|
end
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
nil
|
|
73
72
|
token = @token_request_context.get_token
|
|
74
73
|
|
|
75
|
-
|
|
74
|
+
unless token.nil?
|
|
76
75
|
@cached_token = token.to_hash
|
|
77
76
|
token.token
|
|
78
|
-
else
|
|
79
|
-
nil
|
|
80
77
|
end
|
|
81
78
|
end
|
|
82
79
|
end
|
|
83
80
|
|
|
84
81
|
attr_reader :scopes, :host_validator
|
|
85
|
-
|
|
82
|
+
|
|
86
83
|
protected
|
|
87
84
|
|
|
88
85
|
attr_writer :host_validator, :token_credential, :scopes, :cached_token
|
|
89
|
-
|
|
90
86
|
end
|
|
91
87
|
end
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'microsoft_kiota_abstractions'
|
|
2
|
-
require_relative '
|
|
4
|
+
require_relative 'oauth_access_token_provider'
|
|
3
5
|
|
|
4
6
|
module MicrosoftKiotaAuthenticationOAuth
|
|
5
7
|
class OAuthAuthenticationProvider < MicrosoftKiotaAbstractions::BaseBearerTokenAuthenticationProvider
|
|
6
8
|
def initialize(token_request_context, allowed_hosts, scopes)
|
|
7
|
-
super(MicrosoftKiotaAuthenticationOAuth::OAuthAccessTokenProvider.new(token_request_context, allowed_hosts,
|
|
9
|
+
super(MicrosoftKiotaAuthenticationOAuth::OAuthAccessTokenProvider.new(token_request_context, allowed_hosts,
|
|
10
|
+
scopes))
|
|
8
11
|
end
|
|
9
12
|
end
|
|
10
13
|
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
3
|
+
require_relative 'microsoft_kiota_authentication_oauth/version'
|
|
4
|
+
require_relative 'microsoft_kiota_authentication_oauth/contexts/authorization_code_context'
|
|
5
|
+
require_relative 'microsoft_kiota_authentication_oauth/contexts/client_credential_context'
|
|
6
|
+
require_relative 'microsoft_kiota_authentication_oauth/contexts/on_behalf_of_context'
|
|
7
|
+
require_relative 'microsoft_kiota_authentication_oauth/contexts/oauth_context'
|
|
8
|
+
require_relative 'microsoft_kiota_authentication_oauth/contexts/oauth_custom_flow'
|
|
9
|
+
require_relative 'microsoft_kiota_authentication_oauth/extensions/oauth2_ext'
|
|
10
|
+
require_relative 'microsoft_kiota_authentication_oauth/oauth_access_token_provider'
|
|
11
|
+
require_relative 'microsoft_kiota_authentication_oauth/oauth_authentication_provider'
|
|
12
12
|
|
|
13
13
|
module MicrosoftKiotaAuthenticationOAuth
|
|
14
14
|
end
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative 'lib/microsoft_kiota_authentication_oauth/version'
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name
|
|
7
|
-
spec.version
|
|
8
|
-
spec.authors
|
|
9
|
-
spec.email
|
|
6
|
+
spec.name = 'microsoft_kiota_authentication_oauth'
|
|
7
|
+
spec.version = MicrosoftKiotaAuthenticationOAuth::VERSION
|
|
8
|
+
spec.authors = 'Microsoft Corporation'
|
|
9
|
+
spec.email = 'graphsdkpub+ruby@microsoft.com'
|
|
10
10
|
spec.description = 'Kiota Authentication implementation with oauth2'
|
|
11
11
|
spec.summary = 'Microsoft Kiota Authentication OAuth - Kiota Ruby Authentication OAuth library'
|
|
12
|
-
spec.homepage = 'https://microsoft.
|
|
12
|
+
spec.homepage = 'https://learn.microsoft.com/openapi/kiota/'
|
|
13
13
|
spec.license = 'MIT'
|
|
14
14
|
spec.metadata = {
|
|
15
|
-
'bug_tracker_uri' => 'https://github.com/microsoft/kiota-
|
|
16
|
-
'changelog_uri'
|
|
17
|
-
'homepage_uri'
|
|
18
|
-
'source_code_uri' => 'https://github.com/microsoft/kiota-authentication
|
|
19
|
-
'github_repo'
|
|
15
|
+
'bug_tracker_uri' => 'https://github.com/microsoft/kiota-ruby/issues',
|
|
16
|
+
'changelog_uri' => 'https://github.com/microsoft/kiota-ruby/blob/main/CHANGELOG.md',
|
|
17
|
+
'homepage_uri' => spec.homepage,
|
|
18
|
+
'source_code_uri' => 'https://github.com/microsoft/kiota-ruby/tree/main/components/authentication/oauth',
|
|
19
|
+
'github_repo' => 'ssh://github.com/microsoft/kiota-ruby',
|
|
20
|
+
'rubygems_mfa_required' => 'true'
|
|
20
21
|
}
|
|
21
|
-
spec.required_ruby_version =
|
|
22
|
+
spec.required_ruby_version = '>= 3.3.0'
|
|
22
23
|
|
|
23
|
-
# Specify which files should be added to the gem when it is released.
|
|
24
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
25
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
26
25
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
27
26
|
end
|
|
28
|
-
|
|
29
|
-
spec.bindir = 'bin'
|
|
27
|
+
spec.bindir = 'bin'
|
|
30
28
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
31
29
|
spec.require_paths = ['lib']
|
|
32
|
-
|
|
33
|
-
spec.
|
|
34
|
-
spec.add_runtime_dependency 'oauth2', '~> 2.0'
|
|
30
|
+
spec.add_dependency 'microsoft_kiota_abstractions', MicrosoftKiotaAuthenticationOAuth::VERSION
|
|
31
|
+
spec.add_dependency 'oauth2', '~> 2.0'
|
|
35
32
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
36
33
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
37
34
|
spec.add_development_dependency 'rubocop'
|