omniauth-nitro-id 1.0.0 → 1.1.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: b3b09237f96562c54df18acc4a2974ee10c321d587bd2c0878865c30aa57a0ed
4
- data.tar.gz: 7bf933d671741411f8184693d372ccddadc64d74158b8177eb7d7cc68bccf7a1
3
+ metadata.gz: c3fcfd3453a65729b3e8f7a24c6741c14cacc74d88547e24cb120fdeda0f55c3
4
+ data.tar.gz: 2a6b81428854f8eb43b5be273aff890d9caf2cdf48cbb9154fd7d4eecab7d09b
5
5
  SHA512:
6
- metadata.gz: ba8f9dcf267a4c63ba805f7fa7cca57e798534b070cd81fd40890a3b7f0b475a142a4f626bf8c93e78ce18ae54d227fc5187e98415bf1a516d16e58832813192
7
- data.tar.gz: 43bf42fcd09e559514a7e16376d0f9b5c2686eb67119daeaaf7620094464acbdb891e0cad2cbd268749653d473bf7292f61b8e0bd39933d400a8dcdcf3f8ab0d
6
+ metadata.gz: 386e8ba55776a76e8905e58420dc897261011083adc935005c806944a48ec20ed772adef07d82571fbaa34903934ee4ed9d3d1063324b1047c072a56863f526f
7
+ data.tar.gz: 3e9aa553a7de06ccbb143da81061c87489b3412ccc8ac15e6aaa10edbdf046e2ab0c261aebb203e2e5fb4358de546b7e391925f1e3ea91975a7627b7f78c16a3
data/docs/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2022-12-14
11
+
12
+ ### Added
13
+
14
+ * Add support for `id_token_hint`. PR [#8](https://github.com/powerhome/omniauth-nitro-id/pull/8)
15
+
10
16
  ## [1.0.0] - 2022-12-05
11
17
 
12
18
  ### Added
@@ -14,4 +20,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
20
  * Initial release
15
21
 
16
22
  [Unreleased]: https://github.com/powerhome/omniauth-nitro-id/compare/v1.0.0...HEAD
23
+ [1.1.0]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.1.0
17
24
  [1.0.0]: https://github.com/powerhome/omniauth-nitro-id/releases/tag/v1.0.0
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Extensions
4
+ module Discovery
5
+ Module.new do
6
+ # Monkey patch allow HTTP instead of forcing HTTPS for discovery.
7
+
8
+ attr_reader :scheme
9
+
10
+ def initialize(uri)
11
+ @scheme = uri.scheme
12
+ super
13
+ end
14
+
15
+ def endpoint
16
+ URI::Generic.build(scheme: scheme, host: host, port: port, path: path)
17
+ rescue URI::Error => e
18
+ raise SWD::Exception, e.message
19
+ end
20
+
21
+ prepend_features(::OpenIDConnect::Discovery::Provider::Config::Resource)
22
+ end
23
+ end
24
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAuth
4
4
  module NitroId
5
- VERSION = "1.0.0"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omniauth_openid_connect"
4
+ require_relative "../../extensions/discovery"
5
+
6
+ module OmniAuth
7
+ module Strategies
8
+ class BaseStrategy < OmniAuth::Strategies::OpenIDConnect
9
+ def public_key
10
+ @public_key ||= if options.discovery
11
+ config.jwks
12
+ elsif key_or_secret
13
+ key_or_secret
14
+ elsif client_options.jwks_uri
15
+ fetch_key
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def fetch_key
22
+ @fetch_key ||= parse_jwk_key(::OpenIDConnect.http_client.get_content(client_options.jwks_uri))
23
+ end
24
+
25
+ def key_or_secret
26
+ @key_or_secret ||=
27
+ case options.client_signing_alg&.to_sym
28
+ when :HS256, :HS384, :HS512
29
+ client_options.secret
30
+ when :RS256, :RS384, :RS512
31
+ parse_key
32
+ end
33
+ end
34
+
35
+ def encoded_post_logout_redirect_uri
36
+ return unless options.post_logout_redirect_uri
37
+
38
+ query = {
39
+ post_logout_redirect_uri: options.post_logout_redirect_uri,
40
+ }
41
+ query = query.merge({ id_token_hint: params["id_token_hint"] }) if params["id_token_hint"]
42
+
43
+ URI.encode_www_form(query)
44
+ end
45
+
46
+ def parse_key
47
+ if options.client_jwk_signing_key
48
+ parse_jwk_key(options.client_jwk_signing_key)
49
+ elsif options.client_x509_signing_key
50
+ parse_x509_key(options.client_x509_signing_key)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -1,18 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "omniauth_openid_connect"
3
+ require_relative "base_strategy"
4
4
 
5
5
  module OmniAuth
6
6
  module Strategies
7
- class NitroId < OmniAuth::Strategies::OpenIDConnect
8
- DEFAULT_STRATEGY_NAME = "nitro_id"
9
- DEFAULT_ISSUER = "https://id.powerhrg.com/"
10
- DEFAULT_HOST = "id.powerhrg.com"
11
-
12
- option :name, DEFAULT_STRATEGY_NAME
7
+ class NitroId < BaseStrategy
8
+ option :name, "nitro_id"
13
9
  option :discovery, true
14
- option :issuer, DEFAULT_ISSUER
15
- option :client_options, host: DEFAULT_HOST
10
+ option :issuer, "https://id.powerhrg.com/"
11
+ option :client_options, host: "id.powerhrg.com"
16
12
  end
17
13
  end
18
14
  end
@@ -1,18 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "omniauth_openid_connect"
3
+ require_relative "base_strategy"
4
4
 
5
5
  module OmniAuth
6
6
  module Strategies
7
- class TempoId < OmniAuth::Strategies::OpenIDConnect
8
- DEFAULT_STRATEGY_NAME = "tempo_id"
9
- DEFAULT_ISSUER = "https://id.streamfinancial.io/"
10
- DEFAULT_HOST = "id.streamfinancial.io"
11
-
12
- option :name, DEFAULT_STRATEGY_NAME
7
+ class TempoId < BaseStrategy
8
+ option :name, "tempo_id"
13
9
  option :discovery, true
14
- option :issuer, DEFAULT_ISSUER
15
- option :client_options, host: DEFAULT_HOST
10
+ option :issuer, "https://id.streamfinancial.io/"
11
+ option :client_options, host: "id.streamfinancial.io"
16
12
  end
17
13
  end
18
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-nitro-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Greer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-05 00:00:00.000000000 Z
11
+ date: 2022-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth_openid_connect
@@ -156,9 +156,11 @@ files:
156
156
  - bin/setup
157
157
  - docs/CHANGELOG.md
158
158
  - docs/README.md
159
+ - lib/extensions/discovery.rb
159
160
  - lib/omniauth-nitro-id.rb
160
161
  - lib/omniauth/nitro_id.rb
161
162
  - lib/omniauth/nitro_id/version.rb
163
+ - lib/omniauth/strategies/base_strategy.rb
162
164
  - lib/omniauth/strategies/nitro_id.rb
163
165
  - lib/omniauth/strategies/tempo_id.rb
164
166
  - mkdocs.yml