omniauth-nitro-id 0.1.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/CHANGELOG.md +24 -0
- data/lib/extensions/discovery.rb +24 -0
- data/lib/omniauth/nitro_id/version.rb +1 -1
- data/lib/omniauth/nitro_id.rb +1 -0
- data/lib/omniauth/strategies/base_strategy.rb +55 -0
- data/lib/omniauth/strategies/nitro_id.rb +5 -9
- data/lib/omniauth/strategies/tempo_id.rb +14 -0
- data/omniauth-nitro-id.gemspec +1 -1
- data/spec/omniauth/strategies/tempo_id_spec.rb +55 -0
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3fcfd3453a65729b3e8f7a24c6741c14cacc74d88547e24cb120fdeda0f55c3
|
4
|
+
data.tar.gz: 2a6b81428854f8eb43b5be273aff890d9caf2cdf48cbb9154fd7d4eecab7d09b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 386e8ba55776a76e8905e58420dc897261011083adc935005c806944a48ec20ed772adef07d82571fbaa34903934ee4ed9d3d1063324b1047c072a56863f526f
|
7
|
+
data.tar.gz: 3e9aa553a7de06ccbb143da81061c87489b3412ccc8ac15e6aaa10edbdf046e2ab0c261aebb203e2e5fb4358de546b7e391925f1e3ea91975a7627b7f78c16a3
|
data/docs/CHANGELOG.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
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
|
+
|
16
|
+
## [1.0.0] - 2022-12-05
|
17
|
+
|
18
|
+
### Added
|
19
|
+
|
20
|
+
* Initial release
|
21
|
+
|
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
|
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
|
data/lib/omniauth/nitro_id.rb
CHANGED
@@ -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
|
-
|
3
|
+
require_relative "base_strategy"
|
4
4
|
|
5
5
|
module OmniAuth
|
6
6
|
module Strategies
|
7
|
-
class NitroId <
|
8
|
-
|
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,
|
15
|
-
option :client_options, 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
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base_strategy"
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class TempoId < BaseStrategy
|
8
|
+
option :name, "tempo_id"
|
9
|
+
option :discovery, true
|
10
|
+
option :issuer, "https://id.streamfinancial.io/"
|
11
|
+
option :client_options, host: "id.streamfinancial.io"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/omniauth-nitro-id.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.required_ruby_version = ">= 2.7.0"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split("\n")
|
17
|
-
spec.executables =
|
17
|
+
spec.executables = []
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "omniauth_openid_connect", "~> 0.4.0"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe OmniAuth::Strategies::TempoId do
|
6
|
+
let(:access_token) { instance_double("AccessToken", :options => {}, :[] => "user") }
|
7
|
+
let(:custom_client) do
|
8
|
+
OmniAuth::Strategies::TempoId.new(:test_app,
|
9
|
+
issuer: "https://example-host.com/",
|
10
|
+
discovery: false,
|
11
|
+
client_options: {
|
12
|
+
host: "example-host.com",
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
subject do
|
17
|
+
OmniAuth::Strategies::TempoId.new({})
|
18
|
+
end
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
allow(subject).to receive(:access_token).and_return(access_token)
|
22
|
+
end
|
23
|
+
|
24
|
+
context "options" do
|
25
|
+
it "should have correct name" do
|
26
|
+
expect(subject.options.name).to eq "tempo_id"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have correct host" do
|
30
|
+
expect(subject.options.client_options.host).to eq "id.streamfinancial.io"
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have correct issuer" do
|
34
|
+
expect(subject.options.issuer).to eq "https://id.streamfinancial.io/"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have the correct discovery setting" do
|
38
|
+
expect(subject.options.discovery).to eq true
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "should be overrideable" do
|
42
|
+
it "for host" do
|
43
|
+
expect(custom_client.options.client_options.host).to eq "example-host.com"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "for issuer" do
|
47
|
+
expect(custom_client.options.issuer).to eq "https://example-host.com/"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "for discovery" do
|
51
|
+
expect(custom_client.options.discovery).to eq false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
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:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Greer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
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
|
@@ -139,9 +139,7 @@ dependencies:
|
|
139
139
|
description: NitroID Strategy for OmniAuth.
|
140
140
|
email:
|
141
141
|
- stephen.greer@powerhrg.com
|
142
|
-
executables:
|
143
|
-
- console
|
144
|
-
- setup
|
142
|
+
executables: []
|
145
143
|
extensions: []
|
146
144
|
extra_rdoc_files: []
|
147
145
|
files:
|
@@ -156,22 +154,27 @@ files:
|
|
156
154
|
- Rakefile
|
157
155
|
- bin/console
|
158
156
|
- bin/setup
|
157
|
+
- docs/CHANGELOG.md
|
159
158
|
- docs/README.md
|
159
|
+
- lib/extensions/discovery.rb
|
160
160
|
- lib/omniauth-nitro-id.rb
|
161
161
|
- lib/omniauth/nitro_id.rb
|
162
162
|
- lib/omniauth/nitro_id/version.rb
|
163
|
+
- lib/omniauth/strategies/base_strategy.rb
|
163
164
|
- lib/omniauth/strategies/nitro_id.rb
|
165
|
+
- lib/omniauth/strategies/tempo_id.rb
|
164
166
|
- mkdocs.yml
|
165
167
|
- omniauth-nitro-id.gemspec
|
166
168
|
- portal.yml
|
167
169
|
- renovate.json
|
168
170
|
- spec/omniauth/strategies/nitro_id_spec.rb
|
171
|
+
- spec/omniauth/strategies/tempo_id_spec.rb
|
169
172
|
- spec/spec_helper.rb
|
170
173
|
homepage: https://github.com/powerhome/omniauth-nitro-id
|
171
174
|
licenses:
|
172
175
|
- MIT
|
173
176
|
metadata: {}
|
174
|
-
post_install_message:
|
177
|
+
post_install_message:
|
175
178
|
rdoc_options: []
|
176
179
|
require_paths:
|
177
180
|
- lib
|
@@ -186,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
189
|
- !ruby/object:Gem::Version
|
187
190
|
version: '0'
|
188
191
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
190
|
-
signing_key:
|
192
|
+
rubygems_version: 3.1.6
|
193
|
+
signing_key:
|
191
194
|
specification_version: 4
|
192
195
|
summary: NitroID Strategy for OmniAuth.
|
193
196
|
test_files: []
|