keycloak_oauth 0.1.1 → 0.1.6
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/README.md +66 -0
- data/Rakefile +29 -1
- data/app/controllers/keycloak_oauth/callbacks_controller.rb +43 -0
- data/app/services/keycloak_oauth/authentication_service.rb +59 -0
- data/app/services/keycloak_oauth/authorizable_service.rb +24 -0
- data/app/services/keycloak_oauth/logout_service.rb +44 -0
- data/app/services/keycloak_oauth/user_info_retrieval_service.rb +30 -0
- data/config/routes.rb +3 -0
- data/lib/keycloak_oauth.rb +3 -1
- data/lib/keycloak_oauth/configuration.rb +1 -1
- data/lib/keycloak_oauth/connection.rb +18 -6
- data/lib/keycloak_oauth/endpoints.rb +24 -0
- data/lib/keycloak_oauth/engine.rb +5 -0
- data/lib/keycloak_oauth/version.rb +1 -1
- metadata +59 -12
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -34
- data/LICENSE.txt +0 -21
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/keycloak_oauth.gemspec +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5372c486b89d09a51766f5ae6420c926f23d26d3f83ed30a9cd8b62c0c100a9
|
4
|
+
data.tar.gz: fcc3d36bbcdcd9d3fda6d51ebfb74e227cbb1f3eb234dfabd98531362c0be8e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea374a1c1d6fa04d4473cc645be6af6bfe0d9bb3468924a238cae97ee990c339bbd16d99c8c0173c736b48f0cb5d3c8758cae059dd3d12713f872d6a12ca2dfd
|
7
|
+
data.tar.gz: 95eb399aac689d154fb942521da92a557a0b5fc7f035c7798fb48b3c2e3e1c1a44a2548724cfcb5c96d689d8e6b491f75ca028fb6ad3e356174ae76a8b8562da
|
data/README.md
CHANGED
@@ -38,6 +38,72 @@ end
|
|
38
38
|
This then allows you to access the `KeycloakOauth` APIs:
|
39
39
|
`KeycloakOauth.connection.authorization_endpoint`
|
40
40
|
|
41
|
+
You can allow the user to log in with Keycloak by adding adding a link that points to `KeycloakOauth.connection.authorization_endpoint`:
|
42
|
+
e.g.
|
43
|
+
`<%= link_to 'Login with Keycloak', KeycloakOauth.connection.authorization_endpoint %>`
|
44
|
+
|
45
|
+
Once authentication is performed, the access and refresh tokens are stored in the session and can be used in your app as wished.
|
46
|
+
|
47
|
+
***Customising redirect URIs***
|
48
|
+
There are situations where you would want to customise the oauth2 route (e.g. to use a localised version of the callback URL).
|
49
|
+
In this case, you can do the following:
|
50
|
+
- add a controller to your app: e.g. `CallbackOverrides`
|
51
|
+
- add the following to your routes.rb file: `get 'oauth2', to: 'callback_overrides#oauth2'`
|
52
|
+
- add whatever logic you need in the controller, e.g. a `skip_before_action`; it can also be blank
|
53
|
+
- add redirect URI to the authorization link:
|
54
|
+
e.g.
|
55
|
+
`<%= link_to 'Login with Keycloak', KeycloakOauth.connection.authorization_endpoint(options: {redirect_uri: 'http://myapp.com/en/oauth2'}) %>`
|
56
|
+
|
57
|
+
**Keycloak callback URL**
|
58
|
+
Keycloak needs a callback URL to send the authorization code to once a user logs in.
|
59
|
+
By default, once authentication is performed, we redirect to the `/` path (i.e. whatever the root path is set to in the host app).
|
60
|
+
If you need the user to be redirected to something other than the root path, you can achieve that in the following way:
|
61
|
+
|
62
|
+
1. Add a new module (could be a controller concern) e.g. `KeycloakOauthCallbacks`
|
63
|
+
2. In this module, define a method `after_sign_in_path`
|
64
|
+
3. In the method, perform whatever logic you need to return the right path e.g.
|
65
|
+
```ruby
|
66
|
+
def after_sign_in_path
|
67
|
+
my_custom_path
|
68
|
+
end
|
69
|
+
```
|
70
|
+
4. Tell the gem where you've overridden the paths by setting the following config in your configuration initializer file:
|
71
|
+
```ruby
|
72
|
+
KeycloakOauth.configure do |config|
|
73
|
+
...
|
74
|
+
config.callback_module = KeycloakOauthCallbacks
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
**User mapping**
|
79
|
+
The host app is responsible for mapping a Keycloak session with a Rails user session. This can be achieved
|
80
|
+
by implementing the `map_authenticatable` method in the module configured above (e.g. `KeycloakOauthCallbacks` in our example).
|
81
|
+
You can get the user information by making a call to `KeycloakOauth.connection.get_user_information` to which you pass in the access token.
|
82
|
+
See here an example of retrieving the user information and saving the email address in the Rails session:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
def map_authenticatable(_request)
|
86
|
+
service = KeycloakOauth.connection.get_user_information(access_token: session[:access_token])
|
87
|
+
session[:user_email_address] = service.user_information['email']
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
**Logging out**
|
92
|
+
In order to log out, you can use the following API call:
|
93
|
+
`KeycloakOauth.connection.logout(session: session)`
|
94
|
+
|
95
|
+
Note that you need to pass in the session, as the gem needs to remove the Keycloak tokens from there.
|
96
|
+
|
97
|
+
e.g.
|
98
|
+
```ruby
|
99
|
+
class SessionsController < ApplicationController
|
100
|
+
def destroy
|
101
|
+
KeycloakOauth.connection.logout(session: session)
|
102
|
+
redirect_to new_session_path
|
103
|
+
end
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
41
107
|
## Development
|
42
108
|
|
43
109
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/Rakefile
CHANGED
@@ -3,4 +3,32 @@ require "rspec/core/rake_task"
|
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
|
6
|
+
begin
|
7
|
+
require 'bundler/setup'
|
8
|
+
rescue LoadError
|
9
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'rdoc/task'
|
13
|
+
|
14
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
15
|
+
rdoc.rdoc_dir = 'rdoc'
|
16
|
+
rdoc.title = 'KeycloakOauth'
|
17
|
+
rdoc.options << '--line-numbers'
|
18
|
+
rdoc.rdoc_files.include('README.md')
|
19
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
23
|
+
|
24
|
+
require 'bundler/gem_tasks'
|
25
|
+
|
26
|
+
require 'rake/testtask'
|
27
|
+
|
28
|
+
Rake::TestTask.new(:test) do |t|
|
29
|
+
t.libs << 'test'
|
30
|
+
t.pattern = 'test/**/*_test.rb'
|
31
|
+
t.verbose = false
|
32
|
+
end
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module KeycloakOauth
|
2
|
+
class CallbacksController < ::ApplicationController
|
3
|
+
if KeycloakOauth.connection.callback_module.present?
|
4
|
+
include KeycloakOauth.connection.callback_module
|
5
|
+
end
|
6
|
+
|
7
|
+
def oauth2
|
8
|
+
authentication_service = KeycloakOauth::AuthenticationService.new(
|
9
|
+
authentication_params: authentication_params,
|
10
|
+
session: session,
|
11
|
+
redirect_uri: current_uri_without_params
|
12
|
+
)
|
13
|
+
authentication_service.authenticate
|
14
|
+
map_authenticatable_if_implemented(session)
|
15
|
+
|
16
|
+
redirect_to self.class.method_defined?(:after_sign_in_path) ? after_sign_in_path(request) : '/'
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def authentication_params
|
22
|
+
params.permit(:code)
|
23
|
+
end
|
24
|
+
|
25
|
+
def map_authenticatable_if_implemented(request)
|
26
|
+
if self.class.method_defined?(:map_authenticatable)
|
27
|
+
map_authenticatable(request)
|
28
|
+
else
|
29
|
+
raise NotImplementedError.new('User mapping must be handled by the host app. See README for more information.')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_uri_without_params
|
34
|
+
# If the host app has overwritten the route (e.g. to enable localised
|
35
|
+
# callbacks), this ensures we are using the path coming from the host app
|
36
|
+
# instead of the one coming from the engine.
|
37
|
+
main_app.url_for(only_path: false, overwrite_params: nil)
|
38
|
+
rescue ActionController::UrlGenerationError
|
39
|
+
# If the host app does not override the oauth2 path, use the engine's path.
|
40
|
+
oauth2_path
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module KeycloakOauth
|
4
|
+
class AuthenticationError < StandardError; end
|
5
|
+
|
6
|
+
class AuthenticationService
|
7
|
+
GRANT_TYPE = 'authorization_code'.freeze
|
8
|
+
CONTENT_TYPE = 'application/x-www-form-urlencoded'.freeze
|
9
|
+
ACCESS_TOKEN_KEY = 'access_token'.freeze
|
10
|
+
REFRESH_TOKEN_KEY = 'refresh_token'.freeze
|
11
|
+
|
12
|
+
attr_reader :session
|
13
|
+
|
14
|
+
def initialize(authentication_params:, session:, redirect_uri:)
|
15
|
+
@code = authentication_params[:code]
|
16
|
+
@session = session
|
17
|
+
@redirect_uri = redirect_uri
|
18
|
+
end
|
19
|
+
|
20
|
+
def authenticate
|
21
|
+
store_credentials(get_tokens)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :code, :redirect_uri
|
27
|
+
|
28
|
+
def get_tokens
|
29
|
+
uri = URI.parse(KeycloakOauth.connection.authentication_endpoint)
|
30
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
31
|
+
request = Net::HTTP::Post.new(uri)
|
32
|
+
request.set_content_type(CONTENT_TYPE)
|
33
|
+
request.set_form_data(token_request_params)
|
34
|
+
http.request(request)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def token_request_params
|
39
|
+
{
|
40
|
+
client_id: KeycloakOauth.connection.client_id,
|
41
|
+
client_secret: KeycloakOauth.connection.client_secret,
|
42
|
+
grant_type: GRANT_TYPE,
|
43
|
+
code: code,
|
44
|
+
redirect_uri: redirect_uri
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def store_credentials(http_response)
|
49
|
+
response_hash = JSON.parse(http_response.body)
|
50
|
+
|
51
|
+
if http_response.code_type == Net::HTTPOK
|
52
|
+
session[:access_token] = response_hash[ACCESS_TOKEN_KEY]
|
53
|
+
session[:refresh_token] = response_hash[REFRESH_TOKEN_KEY]
|
54
|
+
else
|
55
|
+
raise KeycloakOauth::AuthenticationError.new(response_hash)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module KeycloakOauth
|
4
|
+
class AuthorizableError < StandardError; end
|
5
|
+
|
6
|
+
class AuthorizableService
|
7
|
+
HTTP_SUCCESS_CODES = [Net::HTTPOK, Net::HTTPNoContent]
|
8
|
+
DEFAULT_CONTENT_TYPE = 'application/x-www-form-urlencoded'.freeze
|
9
|
+
AUTHORIZATION_HEADER = 'Authorization'.freeze
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def parsed_response(http_response)
|
14
|
+
response = http_response.body.present? ? JSON.parse(http_response.body) : http_response.body
|
15
|
+
|
16
|
+
return response if HTTP_SUCCESS_CODES.include?(http_response.code_type)
|
17
|
+
|
18
|
+
# TODO: For now, we assume that the access token is always valid.
|
19
|
+
# We do not yet handle the case where a refresh token is passed in and
|
20
|
+
# used if the access token has expired.
|
21
|
+
raise KeycloakOauth::AuthorizableError.new(response)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module KeycloakOauth
|
4
|
+
class LogoutService < KeycloakOauth::AuthorizableService
|
5
|
+
def initialize(session)
|
6
|
+
@session = session
|
7
|
+
end
|
8
|
+
|
9
|
+
def logout
|
10
|
+
parsed_response(post_logout)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_accessor :session
|
16
|
+
|
17
|
+
def post_logout
|
18
|
+
uri = URI.parse(KeycloakOauth.connection.logout_endpoint)
|
19
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
20
|
+
request = Net::HTTP::Post.new(uri)
|
21
|
+
request.set_content_type(DEFAULT_CONTENT_TYPE)
|
22
|
+
request.set_form_data(logout_request_params)
|
23
|
+
request[AUTHORIZATION_HEADER] = "Bearer #{access_token}"
|
24
|
+
http.request(request)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def logout_request_params
|
29
|
+
{
|
30
|
+
client_id: KeycloakOauth.connection.client_id,
|
31
|
+
client_secret: KeycloakOauth.connection.client_secret,
|
32
|
+
refresh_token: refresh_token
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def access_token
|
37
|
+
session[:access_token]
|
38
|
+
end
|
39
|
+
|
40
|
+
def refresh_token
|
41
|
+
session[:refresh_token]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module KeycloakOauth
|
4
|
+
class UserInfoRetrievalService < KeycloakOauth::AuthorizableService
|
5
|
+
attr_reader :user_information
|
6
|
+
|
7
|
+
def initialize(access_token:, refresh_token:)
|
8
|
+
@access_token = access_token
|
9
|
+
@refresh_token = refresh_token
|
10
|
+
end
|
11
|
+
|
12
|
+
def retrieve
|
13
|
+
@user_information = parsed_response(get_user)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_accessor :access_token, :refresh_token
|
19
|
+
|
20
|
+
def get_user
|
21
|
+
uri = URI.parse(KeycloakOauth.connection.user_info_endpoint)
|
22
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
23
|
+
request = Net::HTTP::Get.new(uri)
|
24
|
+
request.set_content_type(DEFAULT_CONTENT_TYPE)
|
25
|
+
request[AUTHORIZATION_HEADER] = "Bearer #{access_token}"
|
26
|
+
http.request(request)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/config/routes.rb
ADDED
data/lib/keycloak_oauth.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'keycloak_oauth/version'
|
2
2
|
require 'keycloak_oauth/configuration'
|
3
3
|
require 'keycloak_oauth/connection'
|
4
|
+
require 'keycloak_oauth/engine'
|
4
5
|
|
5
6
|
module KeycloakOauth
|
6
7
|
def self.configure
|
@@ -16,7 +17,8 @@ module KeycloakOauth
|
|
16
17
|
auth_url: configuration.auth_url,
|
17
18
|
realm: configuration.realm,
|
18
19
|
client_id: configuration.client_id,
|
19
|
-
client_secret: configuration.client_secret
|
20
|
+
client_secret: configuration.client_secret,
|
21
|
+
callback_module: configuration.callback_module
|
20
22
|
)
|
21
23
|
end
|
22
24
|
end
|
@@ -1,19 +1,31 @@
|
|
1
|
+
require 'keycloak_oauth/endpoints'
|
2
|
+
|
1
3
|
module KeycloakOauth
|
2
4
|
class Connection
|
3
|
-
|
5
|
+
include KeycloakOauth::Endpoints
|
4
6
|
|
5
|
-
|
7
|
+
attr_reader :auth_url, :realm, :client_id, :client_secret, :callback_module
|
6
8
|
|
7
|
-
def initialize(auth_url:, realm:, client_id:, client_secret:)
|
9
|
+
def initialize(auth_url:, realm:, client_id:, client_secret:, callback_module: nil)
|
8
10
|
@auth_url = auth_url
|
9
11
|
@realm = realm
|
10
12
|
@client_id = client_id
|
11
13
|
@client_secret = client_secret
|
14
|
+
@callback_module = callback_module
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_user_information(access_token:, refresh_token:)
|
18
|
+
service = KeycloakOauth::UserInfoRetrievalService.new(
|
19
|
+
access_token: access_token,
|
20
|
+
refresh_token: refresh_token
|
21
|
+
)
|
22
|
+
service.retrieve
|
23
|
+
service.user_information
|
12
24
|
end
|
13
25
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
26
|
+
def logout(session:)
|
27
|
+
service = KeycloakOauth::LogoutService.new(session)
|
28
|
+
service.logout
|
17
29
|
end
|
18
30
|
end
|
19
31
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module KeycloakOauth
|
2
|
+
module Endpoints
|
3
|
+
DEFAULT_RESPONSE_TYPE = 'code'.freeze
|
4
|
+
|
5
|
+
def authorization_endpoint(options: {})
|
6
|
+
endpoint = "#{auth_url}/realms/#{realm}/protocol/openid-connect/auth?client_id=#{client_id}"
|
7
|
+
endpoint += "&response_type=#{options[:response_type] || DEFAULT_RESPONSE_TYPE}"
|
8
|
+
endpoint += "&redirect_uri=#{options[:redirect_uri]}" if options[:redirect_uri].present?
|
9
|
+
endpoint
|
10
|
+
end
|
11
|
+
|
12
|
+
def authentication_endpoint
|
13
|
+
"#{auth_url}/realms/#{realm}/protocol/openid-connect/token"
|
14
|
+
end
|
15
|
+
|
16
|
+
def user_info_endpoint
|
17
|
+
"#{auth_url}/realms/#{realm}/protocol/openid-connect/userinfo"
|
18
|
+
end
|
19
|
+
|
20
|
+
def logout_endpoint
|
21
|
+
"#{auth_url}/realms/#{realm}/protocol/openid-connect/logout"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keycloak_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- simplificator
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
12
|
-
dependencies:
|
11
|
+
date: 2020-11-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.3
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 6.0.3.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 6.0.3
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 6.0.3.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec-rails
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sqlite3
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
13
61
|
description:
|
14
62
|
email:
|
15
63
|
- dev@simplificator.com
|
@@ -17,20 +65,19 @@ executables: []
|
|
17
65
|
extensions: []
|
18
66
|
extra_rdoc_files: []
|
19
67
|
files:
|
20
|
-
- ".gitignore"
|
21
|
-
- ".rspec"
|
22
|
-
- CODE_OF_CONDUCT.md
|
23
|
-
- Gemfile
|
24
|
-
- Gemfile.lock
|
25
|
-
- LICENSE.txt
|
26
68
|
- README.md
|
27
69
|
- Rakefile
|
28
|
-
-
|
29
|
-
-
|
30
|
-
- keycloak_oauth.
|
70
|
+
- app/controllers/keycloak_oauth/callbacks_controller.rb
|
71
|
+
- app/services/keycloak_oauth/authentication_service.rb
|
72
|
+
- app/services/keycloak_oauth/authorizable_service.rb
|
73
|
+
- app/services/keycloak_oauth/logout_service.rb
|
74
|
+
- app/services/keycloak_oauth/user_info_retrieval_service.rb
|
75
|
+
- config/routes.rb
|
31
76
|
- lib/keycloak_oauth.rb
|
32
77
|
- lib/keycloak_oauth/configuration.rb
|
33
78
|
- lib/keycloak_oauth/connection.rb
|
79
|
+
- lib/keycloak_oauth/endpoints.rb
|
80
|
+
- lib/keycloak_oauth/engine.rb
|
34
81
|
- lib/keycloak_oauth/version.rb
|
35
82
|
homepage: https://rubygems.org/gems/keycloak_oauth
|
36
83
|
licenses:
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at dev@simplificator.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: https://contributor-covenant.org
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
keycloak_oauth (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
diff-lcs (1.4.4)
|
10
|
-
rake (12.3.3)
|
11
|
-
rspec (3.9.0)
|
12
|
-
rspec-core (~> 3.9.0)
|
13
|
-
rspec-expectations (~> 3.9.0)
|
14
|
-
rspec-mocks (~> 3.9.0)
|
15
|
-
rspec-core (3.9.3)
|
16
|
-
rspec-support (~> 3.9.3)
|
17
|
-
rspec-expectations (3.9.2)
|
18
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.9.0)
|
20
|
-
rspec-mocks (3.9.1)
|
21
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.9.0)
|
23
|
-
rspec-support (3.9.3)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
keycloak_oauth!
|
30
|
-
rake (~> 12.0)
|
31
|
-
rspec (~> 3.0)
|
32
|
-
|
33
|
-
BUNDLED WITH
|
34
|
-
2.1.4
|
data/LICENSE.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2020 simplificator
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
13
|
-
all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
THE SOFTWARE.
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "keycloak_oauth"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
data/keycloak_oauth.gemspec
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require_relative 'lib/keycloak_oauth/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "keycloak_oauth"
|
5
|
-
spec.version = KeycloakOauth::VERSION
|
6
|
-
spec.authors = ["simplificator"]
|
7
|
-
spec.email = ["dev@simplificator.com"]
|
8
|
-
|
9
|
-
spec.summary = %q{Implementing OAuth with Keycloak in Ruby}
|
10
|
-
spec.homepage = "https://rubygems.org/gems/keycloak_oauth"
|
11
|
-
spec.license = "MIT"
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
-
|
14
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
-
spec.metadata["source_code_uri"] = "https://github.com/simplificator/keycloak_oauth"
|
16
|
-
spec.metadata["changelog_uri"] = "https://github.com/simplificator/keycloak_oauth"
|
17
|
-
|
18
|
-
# Specify which files should be added to the gem when it is released.
|
19
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
-
end
|
23
|
-
spec.bindir = "exe"
|
24
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
-
spec.require_paths = ["lib"]
|
26
|
-
end
|