keycloak_oauth 2.0.0 → 2.0.2
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 +15 -1
- data/app/services/keycloak_oauth/authorizable_error.rb +3 -0
- data/app/services/keycloak_oauth/authorizable_service.rb +3 -3
- data/app/services/keycloak_oauth/duplication_error.rb +3 -0
- data/app/services/keycloak_oauth/not_found_error.rb +3 -0
- data/app/services/keycloak_oauth/post_users_service.rb +3 -2
- data/lib/keycloak_oauth/connection.rb +1 -1
- data/lib/keycloak_oauth/version.rb +1 -1
- data/lib/keycloak_oauth.rb +4 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e85ec71ff01d0bd03e893244b477090209833ee1a6e07a83b170e027ecb9810f
|
4
|
+
data.tar.gz: fd42e9c706a5851edab87f54bc152a6e48be3f53191c6275c3cba7f3d226dfd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 849611286cae02a3b568093f5289e7ddc34b72ec655b2b33f738edd120705f88a5dd730a7eebe2f9f88819d6121077568f1f00ff881fbc1d5dbebd68bb37ffce
|
7
|
+
data.tar.gz: 9f2f4e363ebdfb495be49acaf0aeb124d5c4c2f8b2d7f86d147c1f439f2c5d428d11557e1adae7af48ab035325dbff8edad5fe9a7f144e6d961554d1e462637c
|
data/README.md
CHANGED
@@ -56,6 +56,20 @@ e.g.
|
|
56
56
|
|
57
57
|
Once authentication is performed, the access and refresh tokens are stored in the session and can be used in your app as wished. As the session can become larger than we can store in a cookie (`CookieOverflow` exception), we recommend to use [activerecord-session_store](https://github.com/rails/activerecord-session_store).
|
58
58
|
|
59
|
+
If you are calling Keycloak in your `ApplicationController`, for example, as a callback:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
before_action :authenticate_with_keycloak
|
63
|
+
|
64
|
+
def authenticate_with_keycloak
|
65
|
+
unless session&.dig(:refresh_token).present? && session&.dig(:access_token).present?
|
66
|
+
redirect_to KeycloakOauth.connection.authorization_endpoint(options: { redirect_uri: keycloak_oauth.oauth2_url })
|
67
|
+
end
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
you may get into infinite loop issue, because `KeycloakOauth::CallbacksController` also inherits from the `ApplicationController` and keeps redirecting to authentication endpoint. As a workaround, create a `BaseController` from which the controllers in your application inherit and move the `authenticate` callback to it.
|
72
|
+
|
59
73
|
### Customising redirect URIs
|
60
74
|
|
61
75
|
There are situations where you would want to customise the oauth2 route (e.g. to use a localised version of the callback URL).
|
@@ -96,7 +110,7 @@ See here an example of retrieving the user information and saving the email addr
|
|
96
110
|
|
97
111
|
```ruby
|
98
112
|
def map_authenticatable(_request)
|
99
|
-
service = KeycloakOauth.connection.get_user_information(access_token: session[:access_token])
|
113
|
+
service = KeycloakOauth.connection.get_user_information(access_token: session[:access_token], refresh_token: session[:refresh_token])
|
100
114
|
session[:user_email_address] = service.user_information['email']
|
101
115
|
end
|
102
116
|
```
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
class NotFoundError < StandardError; end
|
3
|
+
require_relative "authorizable_error"
|
4
|
+
require_relative "not_found_error"
|
6
5
|
|
6
|
+
module KeycloakOauth
|
7
7
|
class AuthorizableService
|
8
8
|
HTTP_SUCCESS_CODES = [Net::HTTPOK, Net::HTTPNoContent, Net::HTTPCreated]
|
9
9
|
CONTENT_TYPE_X_WWW_FORM_URLENCODED = 'application/x-www-form-urlencoded'.freeze
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative 'authorizable_error'
|
4
|
+
require_relative 'not_found_error'
|
5
5
|
|
6
|
+
module KeycloakOauth
|
6
7
|
class PostUsersService < KeycloakOauth::AuthorizableService
|
7
8
|
attr_reader :request_params, :connection, :user_params
|
8
9
|
|
data/lib/keycloak_oauth.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'keycloak_oauth/version'
|
2
|
+
require_relative 'keycloak_oauth/configuration'
|
3
|
+
require_relative 'keycloak_oauth/connection'
|
4
|
+
require_relative 'keycloak_oauth/engine'
|
5
5
|
|
6
6
|
module KeycloakOauth
|
7
7
|
def self.configure
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keycloak_oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- simplificator
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -120,9 +120,12 @@ files:
|
|
120
120
|
- app/controllers/keycloak_oauth/callbacks_controller.rb
|
121
121
|
- app/services/keycloak_oauth/authentication_service.rb
|
122
122
|
- app/services/keycloak_oauth/authentication_service_base.rb
|
123
|
+
- app/services/keycloak_oauth/authorizable_error.rb
|
123
124
|
- app/services/keycloak_oauth/authorizable_service.rb
|
125
|
+
- app/services/keycloak_oauth/duplication_error.rb
|
124
126
|
- app/services/keycloak_oauth/get_users_service.rb
|
125
127
|
- app/services/keycloak_oauth/logout_service.rb
|
128
|
+
- app/services/keycloak_oauth/not_found_error.rb
|
126
129
|
- app/services/keycloak_oauth/post_authorization_code_service.rb
|
127
130
|
- app/services/keycloak_oauth/post_refresh_token_service.rb
|
128
131
|
- app/services/keycloak_oauth/post_users_service.rb
|