hydra-keycloak-client 0.1.5 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +16 -0
- data/Dockerfile.test +7 -0
- data/Gemfile +0 -10
- data/Gemfile.lock +14 -14
- data/README.md +20 -9
- data/hydra-keycloak-client.gemspec +10 -0
- data/lib/hydra/keycloak/client.rb +7 -20
- data/lib/hydra/keycloak/token.rb +1 -1
- data/lib/hydra/keycloak/version.rb +1 -1
- metadata +118 -5
- data/lib/hydra/keycloak/user_data.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e7087568f245ec3f7b88cf24e7006da3e74bda757177d44ca109e914d4e7814
|
4
|
+
data.tar.gz: 2643f7fe37e38a43f9052d006a3693e335b4721d051dd66169a7c8dc99d3a1fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 847680ed2c9520cabbd720929d264fd901138aca6069b319a7a577a098a1991fe54d34714a4e1a64e1ead16ebe4b53e15c2c496c5c556930335386282792bf75
|
7
|
+
data.tar.gz: 4a6baa901c8d4fae1b2658849a459d844b585368fb587ac02e673c9442e798f8161dde3bb53b2a1e5457a8f07090150637db76a71ea6df8ada3e43530b222c31
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: self-hosted
|
8
|
+
|
9
|
+
steps:
|
10
|
+
- uses: actions/checkout@v2
|
11
|
+
|
12
|
+
- name: Build image
|
13
|
+
run: docker build -f Dockerfile.test -t hkc_test_image .
|
14
|
+
|
15
|
+
- name: Run tests
|
16
|
+
run: docker run hkc_test_image rspec
|
data/Dockerfile.test
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hydra-keycloak-client (0.1.
|
4
|
+
hydra-keycloak-client (0.1.8)
|
5
|
+
dalli
|
6
|
+
dry-auto_inject
|
7
|
+
dry-container
|
8
|
+
dry-monads
|
9
|
+
dry-schema
|
10
|
+
dry-struct
|
11
|
+
jwt
|
12
|
+
redis
|
5
13
|
|
6
14
|
GEM
|
7
15
|
remote: https://rubygems.org/
|
8
16
|
specs:
|
9
17
|
coderay (1.1.3)
|
10
18
|
concurrent-ruby (1.1.9)
|
11
|
-
dalli (3.
|
19
|
+
dalli (3.2.1)
|
12
20
|
diff-lcs (1.4.4)
|
13
|
-
dry-auto_inject (0.
|
21
|
+
dry-auto_inject (0.9.0)
|
14
22
|
dry-container (>= 0.3.4)
|
15
|
-
dry-configurable (0.
|
23
|
+
dry-configurable (0.14.0)
|
16
24
|
concurrent-ruby (~> 1.0)
|
17
25
|
dry-core (~> 0.6)
|
18
26
|
dry-container (0.9.0)
|
@@ -21,14 +29,14 @@ GEM
|
|
21
29
|
dry-core (0.7.1)
|
22
30
|
concurrent-ruby (~> 1.0)
|
23
31
|
dry-inflector (0.2.1)
|
24
|
-
dry-initializer (3.
|
32
|
+
dry-initializer (3.1.1)
|
25
33
|
dry-logic (1.2.0)
|
26
34
|
concurrent-ruby (~> 1.0)
|
27
35
|
dry-core (~> 0.5, >= 0.5)
|
28
36
|
dry-monads (1.4.0)
|
29
37
|
concurrent-ruby (~> 1.0)
|
30
38
|
dry-core (~> 0.7)
|
31
|
-
dry-schema (1.
|
39
|
+
dry-schema (1.9.1)
|
32
40
|
concurrent-ruby (~> 1.0)
|
33
41
|
dry-configurable (~> 0.13, >= 0.13.0)
|
34
42
|
dry-core (~> 0.5, >= 0.5)
|
@@ -71,17 +79,9 @@ PLATFORMS
|
|
71
79
|
ruby
|
72
80
|
|
73
81
|
DEPENDENCIES
|
74
|
-
dalli
|
75
|
-
dry-auto_inject
|
76
|
-
dry-container
|
77
|
-
dry-monads
|
78
|
-
dry-schema
|
79
|
-
dry-struct
|
80
82
|
hydra-keycloak-client!
|
81
|
-
jwt
|
82
83
|
pry
|
83
84
|
rake (~> 12.0)
|
84
|
-
redis
|
85
85
|
rspec (~> 3.0)
|
86
86
|
|
87
87
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -25,14 +25,25 @@ Create client instance for usage:
|
|
25
25
|
```
|
26
26
|
keycloack_client = Hydra::Keycloak::ClientCreator.call(
|
27
27
|
config: {
|
28
|
-
auth_server_url:
|
29
|
-
realm:
|
30
|
-
client_id:
|
31
|
-
redirect_uri:
|
32
|
-
secret:
|
33
|
-
logout_redirect:
|
34
|
-
|
35
|
-
|
36
|
-
memcached_namespace: "hoper",
|
28
|
+
auth_server_url: keycloak_config.fetch(:auth_server_url),
|
29
|
+
realm: keycloak_config.fetch(:realm),
|
30
|
+
client_id: keycloak_config.fetch(:client_id),
|
31
|
+
redirect_uri: keycloak_config.fetch(:redirect_uri),
|
32
|
+
secret: keycloak_config.fetch(:secret),
|
33
|
+
logout_redirect: keycloak_config.fetch(:logout_redirect),
|
34
|
+
store_client: 'redis',
|
35
|
+
store_client_options: {redis_host: ENV['REDIS_HOST'], redis_port: ENV['REDIS_PORT']}
|
37
36
|
})
|
38
37
|
```
|
38
|
+
|
39
|
+
or for memcached:
|
40
|
+
|
41
|
+
```
|
42
|
+
...
|
43
|
+
store_client: 'redis',
|
44
|
+
store_client_options: {
|
45
|
+
memcached_host: "localhost",
|
46
|
+
memcached_port: "11211",
|
47
|
+
memcached_namespace: "hoper",
|
48
|
+
}
|
49
|
+
```
|
@@ -25,4 +25,14 @@ Gem::Specification.new do |spec|
|
|
25
25
|
end
|
26
26
|
spec.bindir = "bin"
|
27
27
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
|
+
|
29
|
+
spec.add_dependency('jwt')
|
30
|
+
spec.add_dependency('dalli')
|
31
|
+
spec.add_dependency('redis')
|
32
|
+
|
33
|
+
spec.add_dependency('dry-monads')
|
34
|
+
spec.add_dependency('dry-auto_inject')
|
35
|
+
spec.add_dependency('dry-container')
|
36
|
+
spec.add_dependency('dry-schema')
|
37
|
+
spec.add_dependency('dry-struct')
|
28
38
|
end
|
@@ -5,7 +5,6 @@ require 'dry/container'
|
|
5
5
|
require 'dry/schema'
|
6
6
|
|
7
7
|
require 'hydra/keycloak/container'
|
8
|
-
require 'hydra/keycloak/user_data'
|
9
8
|
require 'hydra/keycloak/code_verifier'
|
10
9
|
|
11
10
|
module Hydra
|
@@ -68,13 +67,13 @@ module Hydra
|
|
68
67
|
|
69
68
|
::Hydra::Keycloak::Store::RedisClient.new
|
70
69
|
end
|
71
|
-
|
70
|
+
elsif validated_config[:store_client] == 'memcached'
|
72
71
|
container.register :dalli do
|
73
72
|
require 'dalli'
|
74
73
|
|
75
74
|
::Dalli::Client.new(
|
76
|
-
"#{validated_config[:memcached_host]}:#{validated_config[:memcached_port]}",
|
77
|
-
namespace: validated_config[:memcached_namespace]
|
75
|
+
"#{validated_config[:store_client_options][:memcached_host]}:#{validated_config[:store_client_options][:memcached_port]}",
|
76
|
+
namespace: validated_config[:store_client_options][:memcached_namespace]
|
78
77
|
)
|
79
78
|
end
|
80
79
|
|
@@ -131,22 +130,6 @@ module Hydra
|
|
131
130
|
fetch_token(session_state, 'access_token').success?
|
132
131
|
end
|
133
132
|
|
134
|
-
def user_data(session_state)
|
135
|
-
unless authenticated?(session_state)
|
136
|
-
return Failure(status: 400, code: :not_authenticated)
|
137
|
-
end
|
138
|
-
|
139
|
-
fetch_token(session_state, 'access_token').fmap do |access_token|
|
140
|
-
UserData.new(
|
141
|
-
username: access_token[:login],
|
142
|
-
base_subject_id: access_token[:base_subject_id],
|
143
|
-
subj_group_id: access_token[:subj_group_id],
|
144
|
-
firm_id: access_token[:firm_id],
|
145
|
-
base_subject_first_name: access_token[:base_subject_first_name],
|
146
|
-
jti: access_token[:jti])
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
133
|
def access_token(session_state)
|
151
134
|
unless authenticated?(session_state)
|
152
135
|
return Failure(status: 400, code: :not_authenticated)
|
@@ -188,6 +171,10 @@ module Hydra
|
|
188
171
|
end
|
189
172
|
end
|
190
173
|
|
174
|
+
def introspect_token(token)
|
175
|
+
queries.token_introspect(token)
|
176
|
+
end
|
177
|
+
|
191
178
|
private
|
192
179
|
|
193
180
|
def save_token(session_state, token_name, token)
|
data/lib/hydra/keycloak/token.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,127 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-keycloak-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fedor Kosolapov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dalli
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: redis
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dry-monads
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dry-auto_inject
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dry-container
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: dry-schema
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: dry-struct
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
13
125
|
description: Keycloak client for SSO
|
14
126
|
email:
|
15
127
|
- f.kosolapov@latera.ru
|
@@ -19,6 +131,8 @@ executables:
|
|
19
131
|
extensions: []
|
20
132
|
extra_rdoc_files: []
|
21
133
|
files:
|
134
|
+
- ".github/workflows/main.yml"
|
135
|
+
- Dockerfile.test
|
22
136
|
- Gemfile
|
23
137
|
- Gemfile.lock
|
24
138
|
- README.md
|
@@ -36,7 +150,6 @@ files:
|
|
36
150
|
- lib/hydra/keycloak/store/redis_client.rb
|
37
151
|
- lib/hydra/keycloak/token.rb
|
38
152
|
- lib/hydra/keycloak/urls.rb
|
39
|
-
- lib/hydra/keycloak/user_data.rb
|
40
153
|
- lib/hydra/keycloak/version.rb
|
41
154
|
homepage: https://github.com/latera/hydra-keycloak-client
|
42
155
|
licenses: []
|
@@ -60,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
173
|
- !ruby/object:Gem::Version
|
61
174
|
version: '0'
|
62
175
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
176
|
+
rubygems_version: 3.2.3
|
64
177
|
signing_key:
|
65
178
|
specification_version: 4
|
66
179
|
summary: Keycloak client for SSO
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'dry/struct'
|
4
|
-
|
5
|
-
module Hydra
|
6
|
-
module Keycloak
|
7
|
-
module Types
|
8
|
-
include Dry.Types()
|
9
|
-
end
|
10
|
-
|
11
|
-
class UserData < Dry::Struct
|
12
|
-
attribute :username, Types::String
|
13
|
-
attribute :base_subject_id, Types::Coercible::Integer
|
14
|
-
attribute :subj_group_id, Types::Coercible::Integer
|
15
|
-
attribute :firm_id, Types::Coercible::Integer
|
16
|
-
attribute :base_subject_first_name, Types::String
|
17
|
-
attribute :jti, Types::String
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|