sqsc-keycloak-ruby 1.0.0.pre.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/keycloak/version.rb +1 -1
- data/lib/sqsc-keycloak-ruby.rb +25 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bcfeb458a5b9e706a5ff2b3f52c202a116467e162baef55c37c036d26c2c24b
|
4
|
+
data.tar.gz: cfda2cdf8052ce9fa597228b50d48465475d8e273302ace857e82128da00c829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7265519c86419e2549612f872e2095cf551d2b83f6a129b28de518d8279d786ec9ffa9a45293622f34244b761138c25487e8ace5e0be3594661e3a834971afe3
|
7
|
+
data.tar.gz: c0364ca546c67df98c465d21c1bb40756ff667ce1848f90b3b6094bad6ef2a60badd4cce5d1ccef7351ed09284e2826b0718b5bb422edef2d1c27451dd0e2561
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
keycloak-ruby (1.0.0.pre)
|
4
|
+
sqsc-keycloak-ruby (1.0.0.pre.1)
|
5
5
|
json
|
6
6
|
jwt
|
7
7
|
rest-client
|
@@ -49,9 +49,9 @@ PLATFORMS
|
|
49
49
|
|
50
50
|
DEPENDENCIES
|
51
51
|
bundler (~> 1.17)
|
52
|
-
keycloak-ruby!
|
53
52
|
rake (~> 13.0)
|
54
53
|
rspec (~> 3.9)
|
54
|
+
sqsc-keycloak-ruby!
|
55
55
|
|
56
56
|
BUNDLED WITH
|
57
57
|
1.17.3
|
data/lib/keycloak/version.rb
CHANGED
data/lib/sqsc-keycloak-ruby.rb
CHANGED
@@ -43,22 +43,24 @@ module Keycloak
|
|
43
43
|
attr_reader :client_id, :secret, :configuration, :public_key
|
44
44
|
end
|
45
45
|
|
46
|
-
def self.get_token(user, password, client_id = '', secret = '')
|
46
|
+
def self.get_token(user, password, client_id = '', secret = '', scope = nil)
|
47
47
|
setup_module
|
48
48
|
|
49
49
|
client_id = @client_id if isempty?(client_id)
|
50
50
|
secret = @secret if isempty?(secret)
|
51
51
|
|
52
|
-
payload = {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
payload = { "client_id" => client_id,
|
53
|
+
"client_secret" => secret,
|
54
|
+
"username" => user,
|
55
|
+
"password" => password,
|
56
|
+
"grant_type" => "password" }
|
57
|
+
|
58
|
+
payload = fill_scope(payload, scope)
|
57
59
|
|
58
60
|
mount_request_token(payload)
|
59
61
|
end
|
60
62
|
|
61
|
-
def self.get_token_by_code(code, redirect_uri, client_id = '', secret = '')
|
63
|
+
def self.get_token_by_code(code, redirect_uri, client_id = '', secret = '', scope = nil)
|
62
64
|
verify_setup
|
63
65
|
|
64
66
|
client_id = @client_id if isempty?(client_id)
|
@@ -70,6 +72,8 @@ module Keycloak
|
|
70
72
|
'grant_type' => 'authorization_code',
|
71
73
|
'redirect_uri' => redirect_uri }
|
72
74
|
|
75
|
+
payload = fill_scope(payload, scope)
|
76
|
+
|
73
77
|
mount_request_token(payload)
|
74
78
|
end
|
75
79
|
|
@@ -171,13 +175,20 @@ module Keycloak
|
|
171
175
|
exec_request _request
|
172
176
|
end
|
173
177
|
|
174
|
-
def self.url_login_redirect(redirect_uri, response_type = 'code', client_id = '', authorization_endpoint = '')
|
178
|
+
def self.url_login_redirect(redirect_uri, response_type = 'code', client_id = '', authorization_endpoint = '', scope = nil)
|
175
179
|
verify_setup
|
176
180
|
|
177
181
|
client_id = @client_id if isempty?(client_id)
|
178
182
|
authorization_endpoint = @configuration['authorization_endpoint'] if isempty?(authorization_endpoint)
|
179
183
|
|
180
|
-
|
184
|
+
payload = {
|
185
|
+
"response_type" => response_type,
|
186
|
+
"client_id" => client_id,
|
187
|
+
"redirect_uri" => redirect_uri
|
188
|
+
}
|
189
|
+
payload = fill_scope(payload, scope)
|
190
|
+
|
191
|
+
p = URI.encode_www_form(payload)
|
181
192
|
"#{authorization_endpoint}?#{p}"
|
182
193
|
end
|
183
194
|
|
@@ -352,6 +363,11 @@ module Keycloak
|
|
352
363
|
get_installation
|
353
364
|
end
|
354
365
|
|
366
|
+
def self.fill_scope(payload, scope)
|
367
|
+
payload["scope"] = scope.join(" ") unless scope.nil? or scope.empty?
|
368
|
+
payload
|
369
|
+
end
|
370
|
+
|
355
371
|
def self.exec_request(proc_request)
|
356
372
|
if Keycloak.explode_exception
|
357
373
|
proc_request.call
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqsc-keycloak-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guilherme Portugues
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-12-
|
12
|
+
date: 2019-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -137,9 +137,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
|
-
- - "
|
140
|
+
- - ">="
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
142
|
+
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubygems_version: 3.0.6
|
145
145
|
signing_key:
|