omniauth-keycloak 1.0.1 → 1.3.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 +4 -4
- data/CHANGELOG.md +44 -0
- data/Gemfile.lock +48 -36
- data/README.md +41 -0
- data/lib/keycloak/version.rb +1 -1
- data/lib/omniauth/strategies/keycloak-openid.rb +51 -11
- data/omniauth-keycloak.gemspec +7 -6
- data/spec/omniauth/strategies/keycloak_spec.rb +47 -1
- metadata +16 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c9982a0ec26f3a29c6e8a2ff4563c45ec0c3944c69b8e3d853a5a9641fab529
|
|
4
|
+
data.tar.gz: 7bf4b42a30813bb0dd7a67866b051e9a5802970d1e1754aeaf393140b10d2e4e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d04d5c18554fdb152fb00bc961615a2d08c320237fa85e1e1118a82616ff7ba5cf65c0b0da8d857ae0243119100c12a192547c7a9fadc3b658146470dc07db7
|
|
7
|
+
data.tar.gz: 1ca221dedc1468014e5761596612aac041d8da7acb3edda25b35ea211c2a4b30c533894a506b3dd480cecde2c43eff4fd63884bd969dfde55779728bb87dea99
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [v1.2.1](https://github.com/ccrockett/omniauth-keycloak/tree/v1.2.1) (2020-12-19)
|
|
4
|
+
|
|
5
|
+
[Full Changelog](https://github.com/ccrockett/omniauth-keycloak/compare/v1.2.0...v1.2.1)
|
|
6
|
+
|
|
7
|
+
**Closed issues:**
|
|
8
|
+
|
|
9
|
+
- Dynamically load Client and Realm [\#11](https://github.com/ccrockett/omniauth-keycloak/issues/11)
|
|
10
|
+
- cannot load such file -- /Library/Ruby/Gems/2.6.0/gems/omniauth-keycloak-1.2.0/lib/omniauth-keycloak.rb \(LoadError\) [\#8](https://github.com/ccrockett/omniauth-keycloak/issues/8)
|
|
11
|
+
- Release json-jwt version restriction change [\#5](https://github.com/ccrockett/omniauth-keycloak/issues/5)
|
|
12
|
+
|
|
13
|
+
**Merged pull requests:**
|
|
14
|
+
|
|
15
|
+
- Raise errors on setup failure and logging with OmniAuth::Strategy::log method [\#10](https://github.com/ccrockett/omniauth-keycloak/pull/10) ([alexpetrov](https://github.com/alexpetrov))
|
|
16
|
+
- Bump json from 2.1.0 to 2.3.1 [\#9](https://github.com/ccrockett/omniauth-keycloak/pull/9) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
17
|
+
|
|
18
|
+
## [v1.2.0](https://github.com/ccrockett/omniauth-keycloak/tree/v1.2.0) (2020-05-28)
|
|
19
|
+
|
|
20
|
+
[Full Changelog](https://github.com/ccrockett/omniauth-keycloak/compare/v1.1.0...v1.2.0)
|
|
21
|
+
|
|
22
|
+
**Merged pull requests:**
|
|
23
|
+
|
|
24
|
+
- Bump rack from 2.2.2 to 2.2.3 [\#7](https://github.com/ccrockett/omniauth-keycloak/pull/7) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
25
|
+
- Bump activesupport from 6.0.1 to 6.0.3.1 [\#6](https://github.com/ccrockett/omniauth-keycloak/pull/6) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
26
|
+
- Update rake requirement from ~\> 10.0 to ~\> 13.0 [\#4](https://github.com/ccrockett/omniauth-keycloak/pull/4) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
27
|
+
- Bump rack from 2.0.7 to 2.0.8 [\#2](https://github.com/ccrockett/omniauth-keycloak/pull/2) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
28
|
+
- Adding Devise Documentation [\#1](https://github.com/ccrockett/omniauth-keycloak/pull/1) ([masonhensley](https://github.com/masonhensley))
|
|
29
|
+
|
|
30
|
+
## [v1.1.0](https://github.com/ccrockett/omniauth-keycloak/tree/v1.1.0) (2018-12-16)
|
|
31
|
+
|
|
32
|
+
[Full Changelog](https://github.com/ccrockett/omniauth-keycloak/compare/v1.0.1...v1.1.0)
|
|
33
|
+
|
|
34
|
+
## [v1.0.1](https://github.com/ccrockett/omniauth-keycloak/tree/v1.0.1) (2018-12-16)
|
|
35
|
+
|
|
36
|
+
[Full Changelog](https://github.com/ccrockett/omniauth-keycloak/compare/v1.0.0...v1.0.1)
|
|
37
|
+
|
|
38
|
+
## [v1.0.0](https://github.com/ccrockett/omniauth-keycloak/tree/v1.0.0) (2018-12-16)
|
|
39
|
+
|
|
40
|
+
[Full Changelog](https://github.com/ccrockett/omniauth-keycloak/compare/7877c8a75f9e3f342b49bf808fa69965377d60b5...v1.0.0)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile.lock
CHANGED
|
@@ -1,59 +1,70 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
omniauth-keycloak (1.0
|
|
5
|
-
json-jwt (~> 1.
|
|
6
|
-
omniauth (~>
|
|
7
|
-
omniauth-oauth2 (~> 1.
|
|
4
|
+
omniauth-keycloak (1.3.0)
|
|
5
|
+
json-jwt (~> 1.13.0)
|
|
6
|
+
omniauth (~> 2.0.4)
|
|
7
|
+
omniauth-oauth2 (~> 1.7.1)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (
|
|
12
|
+
activesupport (6.1.3.2)
|
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
|
-
i18n (>=
|
|
15
|
-
minitest (
|
|
16
|
-
tzinfo (~>
|
|
14
|
+
i18n (>= 1.6, < 2)
|
|
15
|
+
minitest (>= 5.1)
|
|
16
|
+
tzinfo (~> 2.0)
|
|
17
|
+
zeitwerk (~> 2.3)
|
|
17
18
|
addressable (2.5.2)
|
|
18
19
|
public_suffix (>= 2.0.2, < 4.0)
|
|
19
|
-
aes_key_wrap (1.0
|
|
20
|
-
bindata (2.4.
|
|
21
|
-
concurrent-ruby (1.1.
|
|
20
|
+
aes_key_wrap (1.1.0)
|
|
21
|
+
bindata (2.4.9)
|
|
22
|
+
concurrent-ruby (1.1.8)
|
|
22
23
|
crack (0.4.3)
|
|
23
24
|
safe_yaml (~> 1.0.0)
|
|
24
25
|
diff-lcs (1.3)
|
|
25
26
|
docile (1.3.1)
|
|
26
|
-
faraday (
|
|
27
|
+
faraday (1.4.1)
|
|
28
|
+
faraday-excon (~> 1.1)
|
|
29
|
+
faraday-net_http (~> 1.0)
|
|
30
|
+
faraday-net_http_persistent (~> 1.1)
|
|
27
31
|
multipart-post (>= 1.2, < 3)
|
|
32
|
+
ruby2_keywords (>= 0.0.4)
|
|
33
|
+
faraday-excon (1.1.0)
|
|
34
|
+
faraday-net_http (1.0.1)
|
|
35
|
+
faraday-net_http_persistent (1.1.0)
|
|
28
36
|
hashdiff (0.3.7)
|
|
29
|
-
hashie (
|
|
30
|
-
i18n (1.
|
|
37
|
+
hashie (4.1.0)
|
|
38
|
+
i18n (1.8.10)
|
|
31
39
|
concurrent-ruby (~> 1.0)
|
|
32
|
-
json (2.1
|
|
33
|
-
json-jwt (1.
|
|
34
|
-
activesupport
|
|
40
|
+
json (2.3.1)
|
|
41
|
+
json-jwt (1.13.0)
|
|
42
|
+
activesupport (>= 4.2)
|
|
35
43
|
aes_key_wrap
|
|
36
44
|
bindata
|
|
37
|
-
jwt (2.
|
|
38
|
-
minitest (5.
|
|
39
|
-
multi_json (1.
|
|
45
|
+
jwt (2.2.3)
|
|
46
|
+
minitest (5.14.4)
|
|
47
|
+
multi_json (1.15.0)
|
|
40
48
|
multi_xml (0.6.0)
|
|
41
|
-
multipart-post (2.
|
|
42
|
-
oauth2 (1.4.
|
|
43
|
-
faraday (>= 0.8, <
|
|
49
|
+
multipart-post (2.1.1)
|
|
50
|
+
oauth2 (1.4.7)
|
|
51
|
+
faraday (>= 0.8, < 2.0)
|
|
44
52
|
jwt (>= 1.0, < 3.0)
|
|
45
53
|
multi_json (~> 1.3)
|
|
46
54
|
multi_xml (~> 0.5)
|
|
47
55
|
rack (>= 1.2, < 3)
|
|
48
|
-
omniauth (
|
|
49
|
-
hashie (>= 3.4.6
|
|
56
|
+
omniauth (2.0.4)
|
|
57
|
+
hashie (>= 3.4.6)
|
|
50
58
|
rack (>= 1.6.2, < 3)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
rack-protection
|
|
60
|
+
omniauth-oauth2 (1.7.1)
|
|
61
|
+
oauth2 (~> 1.4)
|
|
62
|
+
omniauth (>= 1.9, < 3)
|
|
54
63
|
public_suffix (3.0.3)
|
|
55
|
-
rack (2.
|
|
56
|
-
|
|
64
|
+
rack (2.2.3)
|
|
65
|
+
rack-protection (2.1.0)
|
|
66
|
+
rack
|
|
67
|
+
rake (13.0.1)
|
|
57
68
|
rspec (3.8.0)
|
|
58
69
|
rspec-core (~> 3.8.0)
|
|
59
70
|
rspec-expectations (~> 3.8.0)
|
|
@@ -67,30 +78,31 @@ GEM
|
|
|
67
78
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
68
79
|
rspec-support (~> 3.8.0)
|
|
69
80
|
rspec-support (3.8.0)
|
|
81
|
+
ruby2_keywords (0.0.4)
|
|
70
82
|
safe_yaml (1.0.4)
|
|
71
83
|
simplecov (0.16.1)
|
|
72
84
|
docile (~> 1.1)
|
|
73
85
|
json (>= 1.8, < 3)
|
|
74
86
|
simplecov-html (~> 0.10.0)
|
|
75
87
|
simplecov-html (0.10.2)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
thread_safe (~> 0.1)
|
|
88
|
+
tzinfo (2.0.4)
|
|
89
|
+
concurrent-ruby (~> 1.0)
|
|
79
90
|
webmock (3.4.2)
|
|
80
91
|
addressable (>= 2.3.6)
|
|
81
92
|
crack (>= 0.3.2)
|
|
82
93
|
hashdiff
|
|
94
|
+
zeitwerk (2.4.2)
|
|
83
95
|
|
|
84
96
|
PLATFORMS
|
|
85
97
|
ruby
|
|
86
98
|
|
|
87
99
|
DEPENDENCIES
|
|
88
|
-
bundler (~>
|
|
100
|
+
bundler (~> 2.2)
|
|
89
101
|
omniauth-keycloak!
|
|
90
|
-
rake (~>
|
|
102
|
+
rake (~> 13.0)
|
|
91
103
|
rspec (~> 3.0)
|
|
92
104
|
simplecov (~> 0.16.1)
|
|
93
105
|
webmock (~> 3.4.2)
|
|
94
106
|
|
|
95
107
|
BUNDLED WITH
|
|
96
|
-
|
|
108
|
+
2.2.17
|
data/README.md
CHANGED
|
@@ -29,6 +29,47 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
|
29
29
|
end
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
+
## Devise Usage
|
|
33
|
+
Adapted from [Devise OmniAuth Instructions](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview)
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
# app/models/user.rb
|
|
37
|
+
class User < ApplicationRecord
|
|
38
|
+
#...
|
|
39
|
+
devise :omniauthable, omniauth_providers: %i[keycloakopenid]
|
|
40
|
+
#...
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# config/initializers/devise.rb
|
|
44
|
+
config.omniauth :keycloak_openid, "Example-Client-Name", "example-secret-if-configured", client_options: { site: "https://example.keycloak-url.com", realm: "example-realm" }, :strategy_class => OmniAuth::Strategies::KeycloakOpenId
|
|
45
|
+
|
|
46
|
+
# Below controller assumes callback route configuration following
|
|
47
|
+
# in config/routes.rb
|
|
48
|
+
Devise.setup do |config|
|
|
49
|
+
# ...
|
|
50
|
+
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# app/controllers/users/omniauth_callbacks_controller.rb
|
|
54
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
55
|
+
def keycloakopenid
|
|
56
|
+
Rails.logger.debug(request.env["omniauth.auth"])
|
|
57
|
+
@user = User.from_omniauth(request.env["omniauth.auth"])
|
|
58
|
+
if @user.persisted?
|
|
59
|
+
sign_in_and_redirect @user, event: :authentication
|
|
60
|
+
else
|
|
61
|
+
session["devise.keycloakopenid_data"] = request.env["omniauth.auth"]
|
|
62
|
+
redirect_to new_user_registration_url
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def failure
|
|
67
|
+
redirect_to root_path
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
|
|
32
73
|
## Contributing
|
|
33
74
|
|
|
34
75
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ccrockett/omniauth-keycloak. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/keycloak/version.rb
CHANGED
|
@@ -1,44 +1,84 @@
|
|
|
1
1
|
require 'omniauth'
|
|
2
2
|
require 'omniauth-oauth2'
|
|
3
3
|
require 'json/jwt'
|
|
4
|
+
require 'uri'
|
|
4
5
|
|
|
5
6
|
module OmniAuth
|
|
6
7
|
module Strategies
|
|
7
8
|
class KeycloakOpenId < OmniAuth::Strategies::OAuth2
|
|
9
|
+
|
|
10
|
+
class Error < RuntimeError; end
|
|
11
|
+
class ConfigurationError < Error; end
|
|
12
|
+
class IntegrationError < Error; end
|
|
13
|
+
|
|
8
14
|
attr_reader :authorize_url
|
|
9
15
|
attr_reader :token_url
|
|
10
16
|
attr_reader :cert
|
|
11
17
|
|
|
12
18
|
def setup_phase
|
|
13
19
|
if @authorize_url.nil? || @token_url.nil?
|
|
20
|
+
prevent_site_option_mistake
|
|
21
|
+
|
|
14
22
|
realm = options.client_options[:realm].nil? ? options.client_id : options.client_options[:realm]
|
|
15
23
|
site = options.client_options[:site]
|
|
16
|
-
|
|
24
|
+
|
|
25
|
+
raise_on_failure = options.client_options.fetch(:raise_on_failure, false)
|
|
26
|
+
|
|
27
|
+
config_url = URI.join(site, "/auth/realms/#{realm}/.well-known/openid-configuration")
|
|
28
|
+
|
|
29
|
+
log :debug, "Going to get Keycloak configuration. URL: #{config_url}"
|
|
30
|
+
response = Faraday.get config_url
|
|
17
31
|
if (response.status == 200)
|
|
18
32
|
json = MultiJson.load(response.body)
|
|
33
|
+
|
|
19
34
|
@certs_endpoint = json["jwks_uri"]
|
|
20
35
|
@userinfo_endpoint = json["userinfo_endpoint"]
|
|
21
|
-
@authorize_url = json["authorization_endpoint"].
|
|
22
|
-
@token_url = json["token_endpoint"].
|
|
36
|
+
@authorize_url = URI(json["authorization_endpoint"]).path
|
|
37
|
+
@token_url = URI(json["token_endpoint"]).path
|
|
38
|
+
|
|
39
|
+
log_config(json)
|
|
40
|
+
|
|
23
41
|
options.client_options.merge!({
|
|
24
42
|
authorize_url: @authorize_url,
|
|
25
43
|
token_url: @token_url
|
|
26
|
-
|
|
44
|
+
})
|
|
45
|
+
log :debug, "Going to get certificates. URL: #{@certs_endpoint}"
|
|
27
46
|
certs = Faraday.get @certs_endpoint
|
|
28
47
|
if (certs.status == 200)
|
|
29
48
|
json = MultiJson.load(certs.body)
|
|
30
49
|
@cert = json["keys"][0]
|
|
50
|
+
log :debug, "Successfully got certificate. Certificate length: #{@cert.length}"
|
|
31
51
|
else
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
message = "Coundn't get certificate. URL: #{@certs_endpoint}"
|
|
53
|
+
log :error, message
|
|
54
|
+
raise IntegrationError, message if raise_on_failure
|
|
55
|
+
end
|
|
35
56
|
else
|
|
36
|
-
|
|
37
|
-
|
|
57
|
+
message = "Keycloak configuration request failed with status: #{response.status}. " \
|
|
58
|
+
"URL: #{config_url}"
|
|
59
|
+
log :error, message
|
|
60
|
+
raise IntegrationError, message if raise_on_failure
|
|
38
61
|
end
|
|
39
62
|
end
|
|
40
63
|
end
|
|
41
|
-
|
|
64
|
+
|
|
65
|
+
def prevent_site_option_mistake
|
|
66
|
+
site = options.client_options[:site]
|
|
67
|
+
return unless site =~ /\/auth$/
|
|
68
|
+
|
|
69
|
+
raise ConfigurationError, "Keycloak site parameter should not include /auth part, only domain. Current value: #{site}"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def log_config(config_json)
|
|
73
|
+
log_keycloak_config = options.client_options.fetch(:log_keycloak_config, false)
|
|
74
|
+
log :debug, "Successfully got Keycloak config"
|
|
75
|
+
log :debug, "Keycloak config: #{config_json}" if log_keycloak_config
|
|
76
|
+
log :debug, "Certs endpoint: #{@certs_endpoint}"
|
|
77
|
+
log :debug, "Userinfo endpoint: #{@userinfo_endpoint}"
|
|
78
|
+
log :debug, "Authorize url: #{@authorize_url}"
|
|
79
|
+
log :debug, "Token url: #{@token_url}"
|
|
80
|
+
end
|
|
81
|
+
|
|
42
82
|
def build_access_token
|
|
43
83
|
verifier = request.params["code"]
|
|
44
84
|
client.auth_code.get_token(verifier,
|
|
@@ -74,4 +114,4 @@ module OmniAuth
|
|
|
74
114
|
OmniAuth.config.add_camelization('keycloak_openid', 'KeycloakOpenId')
|
|
75
115
|
end
|
|
76
116
|
end
|
|
77
|
-
end
|
|
117
|
+
end
|
data/omniauth-keycloak.gemspec
CHANGED
|
@@ -5,7 +5,7 @@ Gem::Specification.new do |spec|
|
|
|
5
5
|
spec.authors = ["Cameron Crockett"]
|
|
6
6
|
spec.email = ["cameron.crockett@ccrockett.com"]
|
|
7
7
|
|
|
8
|
-
spec.description = %q{
|
|
8
|
+
spec.description = %q{Omniauth strategy for Keycloak}
|
|
9
9
|
spec.summary = spec.description
|
|
10
10
|
spec.homepage = "https://github.com/ccrockett/omniauth-keycloak"
|
|
11
11
|
spec.license = "MIT"
|
|
@@ -23,11 +23,12 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.require_paths = ["lib"]
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
spec.add_dependency "omniauth", "~>
|
|
27
|
-
spec.add_dependency "omniauth-oauth2", "~> 1.
|
|
28
|
-
spec.add_dependency "json-jwt", "~> 1.
|
|
29
|
-
|
|
30
|
-
spec.add_development_dependency "
|
|
26
|
+
spec.add_dependency "omniauth", "~> 2.0.4"
|
|
27
|
+
spec.add_dependency "omniauth-oauth2", "~> 1.7.1"
|
|
28
|
+
spec.add_dependency "json-jwt", "~> 1.13.0"
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.2"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
31
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
32
33
|
spec.add_development_dependency 'simplecov', '~> 0.16.1'
|
|
33
34
|
spec.add_development_dependency 'webmock', '~> 3.4.2'
|
|
@@ -33,7 +33,7 @@ RSpec.describe OmniAuth::Strategies::KeycloakOpenId do
|
|
|
33
33
|
stub_request(:get, "http://localhost:8080/auth/realms/example-realm/protocol/openid-connect/certs")
|
|
34
34
|
.to_return(status: 404, body: "", headers: {})
|
|
35
35
|
OmniAuth::Strategies::KeycloakOpenId.new('keycloak-openid', 'Example-Client', 'b53c572b-9f3b-4e79-bf8b-f03c799ba6ec',
|
|
36
|
-
client_options: {site: 'http://localhost:8080', realm: 'example-realm'})
|
|
36
|
+
client_options: {site: 'http://localhost:8080/', realm: 'example-realm'})
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it 'should have the correct keycloak token url' do
|
|
@@ -46,4 +46,50 @@ RSpec.describe OmniAuth::Strategies::KeycloakOpenId do
|
|
|
46
46
|
expect(subject.authorize_url).to eq('/auth/realms/example-realm/protocol/openid-connect/auth')
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
|
+
|
|
50
|
+
describe 'errors processing' do
|
|
51
|
+
context 'when site contains /auth part' do
|
|
52
|
+
subject do
|
|
53
|
+
OmniAuth::Strategies::KeycloakOpenId.new('keycloak-openid', 'Example-Client', 'b53c572b-9f3b-4e79-bf8b-f03c799ba6ec',
|
|
54
|
+
client_options: {site: 'http://localhost:8080/auth', realm: 'example-realm', raise_on_failure: true})
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'raises Configuration Error' do
|
|
58
|
+
expect{ subject.setup_phase }
|
|
59
|
+
.to raise_error(OmniAuth::Strategies::KeycloakOpenId::ConfigurationError)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
context 'when raise_on_failure option is true' do
|
|
64
|
+
context 'when openid configuration endpoint returns error response' do
|
|
65
|
+
subject do
|
|
66
|
+
stub_request(:get, "http://localhost:8080/auth/realms/example-realm/.well-known/openid-configuration")
|
|
67
|
+
.to_return(status: 404, body: "", headers: {})
|
|
68
|
+
OmniAuth::Strategies::KeycloakOpenId.new('keycloak-openid', 'Example-Client', 'b53c572b-9f3b-4e79-bf8b-f03c799ba6ec',
|
|
69
|
+
client_options: {site: 'http://localhost:8080', realm: 'example-realm', raise_on_failure: true})
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'raises Integration Error' do
|
|
73
|
+
expect{ subject.setup_phase }
|
|
74
|
+
.to raise_error(OmniAuth::Strategies::KeycloakOpenId::IntegrationError)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context 'when certificates endpoint returns error response' do
|
|
79
|
+
subject do
|
|
80
|
+
stub_request(:get, "http://localhost:8080/auth/realms/example-realm/.well-known/openid-configuration")
|
|
81
|
+
.to_return(status: 200, body: body, headers: {})
|
|
82
|
+
stub_request(:get, "http://localhost:8080/auth/realms/example-realm/protocol/openid-connect/certs")
|
|
83
|
+
.to_return(status: 404, body: "", headers: {})
|
|
84
|
+
OmniAuth::Strategies::KeycloakOpenId.new('keycloak-openid', 'Example-Client', 'b53c572b-9f3b-4e79-bf8b-f03c799ba6ec',
|
|
85
|
+
client_options: {site: 'http://localhost:8080', realm: 'example-realm', raise_on_failure: true})
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'raises Integration Error' do
|
|
89
|
+
expect{ subject.setup_phase }
|
|
90
|
+
.to raise_error(OmniAuth::Strategies::KeycloakOpenId::IntegrationError)
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
49
95
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-keycloak
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cameron Crockett
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: omniauth
|
|
@@ -16,70 +16,70 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 2.0.4
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 2.0.4
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: omniauth-oauth2
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 1.
|
|
33
|
+
version: 1.7.1
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.
|
|
40
|
+
version: 1.7.1
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: json-jwt
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.
|
|
47
|
+
version: 1.13.0
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 1.
|
|
54
|
+
version: 1.13.0
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: bundler
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '2.2'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '2.2'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rake
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
75
|
+
version: '13.0'
|
|
76
76
|
type: :development
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
82
|
+
version: '13.0'
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: rspec
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -122,7 +122,7 @@ dependencies:
|
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: 3.4.2
|
|
125
|
-
description:
|
|
125
|
+
description: Omniauth strategy for Keycloak
|
|
126
126
|
email:
|
|
127
127
|
- cameron.crockett@ccrockett.com
|
|
128
128
|
executables: []
|
|
@@ -133,6 +133,7 @@ files:
|
|
|
133
133
|
- ".rspec"
|
|
134
134
|
- ".travis.yml"
|
|
135
135
|
- ".vscode/settings.json"
|
|
136
|
+
- CHANGELOG.md
|
|
136
137
|
- CODE_OF_CONDUCT.md
|
|
137
138
|
- Gemfile
|
|
138
139
|
- Gemfile.lock
|
|
@@ -166,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
166
167
|
- !ruby/object:Gem::Version
|
|
167
168
|
version: 1.3.5
|
|
168
169
|
requirements: []
|
|
169
|
-
|
|
170
|
-
rubygems_version: 2.7.4
|
|
170
|
+
rubygems_version: 3.1.6
|
|
171
171
|
signing_key:
|
|
172
172
|
specification_version: 4
|
|
173
|
-
summary:
|
|
173
|
+
summary: Omniauth strategy for Keycloak
|
|
174
174
|
test_files: []
|