microsoft_kiota_authentication_oauth 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/lib/microsoft_kiota_authentication_oauth/contexts/client_credential_context.rb +2 -4
- data/lib/microsoft_kiota_authentication_oauth/oauth_access_token_provider.rb +19 -9
- data/lib/microsoft_kiota_authentication_oauth/version.rb +1 -1
- data/microsoft_kiota_authentication_oauth.gemspec +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 902714067fe546a76f525e981f431a9742080faa68f3cb1f82acee3e35a653d3
|
4
|
+
data.tar.gz: baf5b2ae57890e1a98430eb814cb7ffbf4f5dc24b9315d1c31c95aa03b1661a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e07859e61b73bfbebb575e229cc459bfa45ed49fd95db28002e92fbc7ada8c9878389fe7f8bda1c772babfeb07eb506af206c5041ed0244256df14e1a687df18
|
7
|
+
data.tar.gz: e261ed6bd9290c5f9ac4d9fc9672398dbf063e105142807d6aff77fbd1d29af8e7f564d7dba0373b605c3bec001be1afc4056dcee3776d1db91e9ab3466c2e26
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
11
11
|
|
12
12
|
### Changed
|
13
13
|
|
14
|
+
## [0.7.0] - 2023-01-17
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Removed Microsoft Graph specific defaults.
|
19
|
+
- Fixed an issue where the access token provider would fail on return.
|
20
|
+
|
14
21
|
## [0.6.0] - 2023-01-16
|
15
22
|
|
16
23
|
### Changed
|
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Read more about Kiota [here](https://github.com/microsoft/kiota/blob/main/README
|
|
15
15
|
Add this line to your application's Gemfile:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
gem "microsoft_kiota_authentication_oauth", "0.
|
18
|
+
gem "microsoft_kiota_authentication_oauth", "0.6.0"
|
19
19
|
```
|
20
20
|
|
21
21
|
And then execute:
|
@@ -27,7 +27,7 @@ bundle install
|
|
27
27
|
Or install it yourself as:
|
28
28
|
|
29
29
|
```shell
|
30
|
-
gem install microsoft_kiota_authentication_oauth --version "0.
|
30
|
+
gem install microsoft_kiota_authentication_oauth --version "0.6.0"
|
31
31
|
```
|
32
32
|
|
33
33
|
## Contributing
|
@@ -44,11 +44,9 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# Function to initialize the scope for the client credential context object.
|
47
|
-
#
|
48
|
-
# for this flow.
|
47
|
+
# Only a single scope is supported for this flow and it's expected to be schme://service/.default
|
49
48
|
def initialize_scopes(scopes = [])
|
50
|
-
|
51
|
-
@scopes = scope_str
|
49
|
+
@scopes = scopes[0] unless scopes.empty?
|
52
50
|
end
|
53
51
|
|
54
52
|
|
@@ -29,14 +29,16 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
29
29
|
@cached_token = nil
|
30
30
|
|
31
31
|
@host_validator = if allowed_hosts.nil? || allowed_hosts.size.zero?
|
32
|
-
MicrosoftKiotaAbstractions::AllowedHostsValidator.new([
|
33
|
-
'graph.microsoft.de', 'microsoftgraph.chinacloudapi.cn',
|
34
|
-
'canary.graph.microsoft.com'])
|
32
|
+
MicrosoftKiotaAbstractions::AllowedHostsValidator.new([])
|
35
33
|
else
|
36
34
|
MicrosoftKiotaAbstractions::AllowedHostsValidator.new(allowed_hosts)
|
37
35
|
end
|
38
36
|
@token_request_context.initialize_oauth_provider
|
39
|
-
|
37
|
+
if scopes.nil?
|
38
|
+
@scopes = []
|
39
|
+
else
|
40
|
+
@scopes = scopes
|
41
|
+
end
|
40
42
|
end
|
41
43
|
|
42
44
|
# This function obtains the authorization token.
|
@@ -45,29 +47,37 @@ module MicrosoftKiotaAuthenticationOAuth
|
|
45
47
|
# additional_params: hash of symbols to string values, ie { response_mode: 'fragment', prompt: 'login' }
|
46
48
|
# default is empty hash
|
47
49
|
def get_authorization_token(uri, additional_properties = {})
|
48
|
-
|
50
|
+
nil if !uri || !@host_validator.url_host_valid?(uri)
|
49
51
|
|
50
52
|
parsed_url = URI(uri)
|
51
53
|
|
52
54
|
raise StandardError, 'Only https is supported' if parsed_url.scheme != 'https'
|
53
55
|
|
56
|
+
if @scopes.empty?
|
57
|
+
@scopes << "#{parsed_url.scheme}://#{parsed_url.host}/.default"
|
58
|
+
end
|
59
|
+
@token_request_context.initialize_scopes(@scopes)
|
54
60
|
Fiber.new do
|
55
61
|
if @cached_token
|
56
62
|
token = OAuth2::AccessToken.from_hash(@token_request_context.oauth_provider, @cached_token)
|
57
|
-
|
63
|
+
token.token unless token.nil? || token.expired?
|
58
64
|
|
59
65
|
if token.expired?
|
60
66
|
token = token.refresh!
|
61
67
|
@cached_token = token.to_hash
|
62
|
-
|
68
|
+
token.token
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
66
72
|
token = nil
|
67
73
|
token = @token_request_context.get_token
|
68
74
|
|
69
|
-
|
70
|
-
|
75
|
+
if !token.nil?
|
76
|
+
@cached_token = token.to_hash
|
77
|
+
token.token
|
78
|
+
else
|
79
|
+
nil
|
80
|
+
end
|
71
81
|
end
|
72
82
|
end
|
73
83
|
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
|
-
spec.add_runtime_dependency 'microsoft_kiota_abstractions', '
|
33
|
+
spec.add_runtime_dependency 'microsoft_kiota_abstractions', '~> 0.13.0', '>= 0.13.0'
|
34
34
|
spec.add_runtime_dependency 'oauth2', '~> 2.0'
|
35
35
|
spec.add_development_dependency 'rake', '~> 13.0'
|
36
36
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
metadata
CHANGED
@@ -1,35 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microsoft_kiota_authentication_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Microsoft Corporation
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: microsoft_kiota_abstractions
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
19
|
+
version: 0.13.0
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 0.13.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "
|
29
|
+
version: 0.13.0
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 0.13.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: oauth2
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|