omniauth-azure-devops 1.2.0 → 1.2.1

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: 1371aaeba34d0fdb8a1254358ab1a72cfd2e204cd042a3b7fd0395d8299e04f7
4
- data.tar.gz: 38225a347250640a66ca6c1ccecddbf0c1bbae6e24f3bd9a8b363685ef22dced
3
+ metadata.gz: 9aab1424ede35a6caa2ef3736b0dc39e9784d7bd89971e86a687233664ecae16
4
+ data.tar.gz: 20773abee955e922d92047b7ba0425cfff02d12a3233681cf3ed7a2f04a297aa
5
5
  SHA512:
6
- metadata.gz: 10db990de46c448121adbc0873ae5fe8cae0b4d8920015a4c516f134bc6027c41c613ad1f17650a46eef8b77550d73cb0d827d7cf5ae6b91dda3153042496d6a
7
- data.tar.gz: 8f8c865fc1e4d56970eb21c77232a019492bf40b358963565bdef7ac99b1cd30cfe3a3f3af92339c1093aea67e275f4eb1e3f9a525ba709c44f22d154380ddca
6
+ metadata.gz: e23d4ca268794faddfd3048dcc2ee491873f4587f11ec9d3c21b7768e852d230be69fbc14cf8f759f18a66bb0dc25adcb78963139615ecc745276dc46dba25c6
7
+ data.tar.gz: cd70bcd1e3b8a34e1d71bb52243f59b35991dd6b714530996b5027a698f170d9c98e16ee1c1166eed3497cdbca66a83e99e7304e542930af41657c3dd6cc5a43
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.2.1]
4
+
5
+ - Retry the `azure_devops_entra` tenant name lookup up to three times, waiting 1, 2 and 4 seconds. Consent granted during the sign-in can take a few seconds to reach the Graph token exchange, which Entra refuses meanwhile with `AADSTS65001` `consent_required`, so `extra.tenant_name` came back `nil` for a user who had just consented. Each failed attempt is logged with its attempt number.
6
+
3
7
  ## [1.2.0]
4
8
 
5
9
  - Add `extra.tenant_name` to the `azure_devops_entra` strategy: the Microsoft Entra tenant's display name, read from Microsoft Graph `/organization` with a `User.Read` token redeemed from the sign-in's refresh token. It is `nil` when Graph can't be reached or `User.Read` isn't consented, and never fails the sign-in.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-azure-devops (1.2.0)
4
+ omniauth-azure-devops (1.2.1)
5
5
  jwt (>= 2.10, < 4)
6
6
  oauth2 (~> 2.0)
7
7
  omniauth (>= 1, < 3)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module AzureDevops
5
- VERSION = '1.2.0'
5
+ VERSION = '1.2.1'
6
6
  end
7
7
  end
@@ -14,6 +14,7 @@ module OmniAuth
14
14
  CLIENT_ASSERTION_LIFETIME_SECONDS = 120
15
15
  GRAPH_SCOPE = 'https://graph.microsoft.com/User.Read'
16
16
  GRAPH_ORGANIZATION_URL = 'https://graph.microsoft.com/v1.0/organization'
17
+ TENANT_NAME_RETRY_DELAYS = [1, 2, 4].freeze
17
18
 
18
19
  option :name, :azure_devops_entra
19
20
  option :pkce, true
@@ -58,14 +59,26 @@ module OmniAuth
58
59
  @tenant_id ||= JWT.decode(access_token.token, nil, false).first['tid']
59
60
  end
60
61
 
62
+ # Consent granted during this sign-in can take a few seconds to reach the Graph token exchange, which Entra refuses
63
+ # meanwhile with AADSTS65001 consent_required, so failed lookups are retried after a short wait.
61
64
  def tenant_name
62
65
  return @tenant_name if defined?(@tenant_name)
63
66
 
64
- @tenant_name = JSON.parse(graph_access_token.get(GRAPH_ORGANIZATION_URL).body).dig('value', 0, 'displayName')
65
- rescue StandardError => e
66
- status = e.response&.status if e.is_a?(::OAuth2::Error)
67
- log :warn, "Could not read the Entra tenant name for tenant #{tenant_id}: #{e.class} (status #{status.inspect}): #{e.message}"
68
- @tenant_name = nil
67
+ attempts = TENANT_NAME_RETRY_DELAYS.size + 1
68
+ attempt = 0
69
+ begin
70
+ attempt += 1
71
+ @tenant_name = JSON.parse(graph_access_token.get(GRAPH_ORGANIZATION_URL).body).dig('value', 0, 'displayName')
72
+ rescue StandardError => e
73
+ status = e.response&.status if e.is_a?(::OAuth2::Error)
74
+ log :warn, "Could not read the Entra tenant name for tenant #{tenant_id} (attempt #{attempt} of #{attempts}): " \
75
+ "#{e.class} (status #{status.inspect}): #{e.message}"
76
+ if attempt < attempts
77
+ sleep TENANT_NAME_RETRY_DELAYS[attempt - 1]
78
+ retry
79
+ end
80
+ @tenant_name = nil
81
+ end
69
82
  end
70
83
 
71
84
  def token_params
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-azure-devops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rewind Software Inc. | Parth Chandgadhiya