microsoft_kiota_authentication_oauth 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f49ff1a865cc86dc2ebd9a925d5ba9ac014c1e1b83515914d3a6baf92ea5f7f
4
- data.tar.gz: e0add8d9df6e81895e77493e7125b84604a6a021c269315076fe1b0cc7e5a416
3
+ metadata.gz: 902714067fe546a76f525e981f431a9742080faa68f3cb1f82acee3e35a653d3
4
+ data.tar.gz: baf5b2ae57890e1a98430eb814cb7ffbf4f5dc24b9315d1c31c95aa03b1661a0
5
5
  SHA512:
6
- metadata.gz: 5f44f1eb63e0b13b7454fde399ed6a52a87c569c456c7ff598d1cc62698904c159633d79bc0a3fe2c721348ff6498afc54c3f0dcfd834cbc2c5e878cfcaaf9be
7
- data.tar.gz: 4a9ce2aa365181f4c90d805338b6b53f7f63f2aeee54e05e44cf308adc64790b3ecd3817c8f86c8f88dd733f7e60319456e54e45d0fcd3048b351922ace6cb2a
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.5.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.5.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
- # This function forces to default since gradual consent is not supported
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
- scope_str = 'https://graph.microsoft.com/.default'
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(['graph.microsoft.com', 'graph.microsoft.us', 'dod-graph.microsoft.us',
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
- @token_request_context.initialize_scopes(scopes)
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
- return nil if !uri || !@host_validator.url_host_valid?(uri)
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
- return token.token if !token.nil? && !token.expired?
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
- return token.token
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
- @cached_token = token.to_hash unless token.nil?
70
- return token.token unless token.nil?
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MicrosoftKiotaAuthenticationOAuth
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
@@ -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', '>= 0.12', '< 0.14'
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.6.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-16 00:00:00.000000000 Z
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: '0.12'
20
- - - "<"
19
+ version: 0.13.0
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '0.14'
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: '0.12'
30
- - - "<"
29
+ version: 0.13.0
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0.14'
32
+ version: 0.13.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: oauth2
35
35
  requirement: !ruby/object:Gem::Requirement