standard_id 0.4.0 → 0.5.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: 6f6c0f3655d0ae20c828fa745d3c600bcf9b0b11521c1c498eb601d35e24e3e2
4
- data.tar.gz: 1f3cca500ec2bf46a4e92b9d8d4a14c7c5fff2d898567a616094b47fd7af5312
3
+ metadata.gz: 956fc621df693ec184f7d65482d96c4f25d99ae55274b68681c9c6b892bde095
4
+ data.tar.gz: 0d5c39a196c8c9e8c99adb24fa61552698672f3df4a5bcf3d06d03b2b61e6a46
5
5
  SHA512:
6
- metadata.gz: d9cb2f2cafa4ddfb0af5839168db2566769b968689a3386c5519b0dc0e06bf0a5cd1a1434df57885549000c85e5eabb2b2608b276338f969625833d09de0c118
7
- data.tar.gz: 4a382d6268709dfe42bac61e60f969153e5054831345250ada9c08436f0681fe5a4b58454ffbf3c00f506ec40308f031e28ac65acd52c8484f7c1adbd0c88738
6
+ metadata.gz: 584c37aa6aa46abe4a576297d6d754e5632c4b710c59dd1bd2b6f8d7c5c17ac86a8aef109df15fe3de720a7d1be405af31441f833a914b3bc8bfea264b296da5
7
+ data.tar.gz: 1733a94c80aba6290cc5eabbe7df67f4ff145c5af18e8cb9202cd3d598b5e5569039fc729cdfed3eacfee55908fe36bf4801e706da7c0e8b544666383b7b6863
@@ -5,6 +5,7 @@ module StandardId
5
5
  include StandardId::ApiAuthentication
6
6
  include StandardId::SetCurrentRequestDetails
7
7
 
8
+ before_action -> { Current.scope = :api if defined?(::Current) }
8
9
  before_action :validate_content_type!
9
10
 
10
11
  after_action :set_no_store_headers
@@ -10,6 +10,7 @@ module StandardId
10
10
 
11
11
  layout -> { StandardId.config.web_layout.presence || "application" }
12
12
 
13
+ before_action -> { Current.scope = :web if defined?(::Current) }
13
14
  before_action :require_browser_session!
14
15
  end
15
16
  end
@@ -16,7 +16,7 @@ module StandardId
16
16
 
17
17
  before_validation :set_issued_and_expiry, on: :create
18
18
 
19
- def self.issue!(plaintext_code:, client_id:, redirect_uri:, scope: nil, audience: nil, account: nil, code_challenge: nil, code_challenge_method: nil, metadata: {})
19
+ def self.issue!(plaintext_code:, client_id:, redirect_uri:, scope: nil, audience: nil, account: nil, code_challenge: nil, code_challenge_method: nil, nonce: nil, metadata: {})
20
20
  create!(
21
21
  account: account,
22
22
  code_hash: hash_for(plaintext_code),
@@ -26,6 +26,7 @@ module StandardId
26
26
  audience: audience,
27
27
  code_challenge: code_challenge,
28
28
  code_challenge_method: code_challenge_method,
29
+ nonce: nonce,
29
30
  issued_at: Time.current,
30
31
  expires_at: Time.current + default_ttl,
31
32
  metadata: metadata || {}
@@ -3,7 +3,7 @@ module StandardId
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- attribute :session, :account, :request_id, :ip_address, :user_agent
6
+ attribute :session, :account, :request_id, :ip_address, :user_agent, :scope
7
7
  end
8
8
  end
9
9
  end
@@ -129,6 +129,7 @@ module StandardId
129
129
  enriched[:ip_address] ||= ::Current.ip_address if ::Current.respond_to?(:ip_address) && ::Current.ip_address.present?
130
130
  enriched[:user_agent] ||= ::Current.user_agent if ::Current.respond_to?(:user_agent) && ::Current.user_agent.present?
131
131
  enriched[:current_account] ||= ::Current.account if ::Current.respond_to?(:account) && ::Current.account.present?
132
+ enriched[:scope] ||= ::Current.scope if ::Current.respond_to?(:scope) && ::Current.scope.present?
132
133
  end
133
134
 
134
135
  enriched.merge(payload)
@@ -2,7 +2,7 @@ module StandardId
2
2
  module Oauth
3
3
  class AuthorizationCodeAuthorizationFlow < AuthorizationFlow
4
4
  expect_params :client_id, :audience
5
- permit_params :scope, :redirect_uri, :state, :connection, :prompt, :organization, :invitation, :code_challenge, :code_challenge_method
5
+ permit_params :scope, :redirect_uri, :state, :connection, :prompt, :organization, :invitation, :code_challenge, :code_challenge_method, :nonce
6
6
 
7
7
  private
8
8
 
@@ -39,7 +39,8 @@ module StandardId
39
39
  audience: audience,
40
40
  state: state,
41
41
  code_challenge: flow_params[:code_challenge],
42
- code_challenge_method: flow_params[:code_challenge_method]
42
+ code_challenge_method: flow_params[:code_challenge_method],
43
+ nonce: flow_params[:nonce]
43
44
  }
44
45
  end
45
46
  end
@@ -70,6 +70,10 @@ module StandardId
70
70
  def audience
71
71
  @authorization_code&.audience
72
72
  end
73
+
74
+ def nonce
75
+ @authorization_code&.nonce
76
+ end
73
77
  end
74
78
  end
75
79
  end
@@ -31,7 +31,8 @@ module StandardId
31
31
  audience: params[:audience],
32
32
  state: params[:state],
33
33
  code_challenge: params[:code_challenge],
34
- code_challenge_method: params[:code_challenge_method]
34
+ code_challenge_method: params[:code_challenge_method],
35
+ nonce: params[:nonce]
35
36
  }.compact
36
37
 
37
38
  # Remove code_challenge_method if code_challenge is not present
@@ -31,6 +31,7 @@ module StandardId
31
31
  account: params[:current_account],
32
32
  code_challenge: params[:code_challenge],
33
33
  code_challenge_method: params[:code_challenge_method],
34
+ nonce: params[:nonce],
34
35
  metadata: { state: params[:state] }.compact
35
36
  )
36
37
  end
@@ -1,3 +1,3 @@
1
1
  module StandardId
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaryl Sim