keycloak_oauth 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a10acf89945fa3d346229c6b4d079a22ff5ee60b8fa6f6cabecff413026c276
4
- data.tar.gz: ab61255f16e412efc30be2ccc14186f524831429972704f47446bc6a3be5bc07
3
+ metadata.gz: e85ec71ff01d0bd03e893244b477090209833ee1a6e07a83b170e027ecb9810f
4
+ data.tar.gz: fd42e9c706a5851edab87f54bc152a6e48be3f53191c6275c3cba7f3d226dfd2
5
5
  SHA512:
6
- metadata.gz: 99189e844270e09c12f343a58f78b58e88c4e6090fe2fef068bda9c4e2995604b1f922c1431755b20be5b9b402a61b4aa4d370e32dc6706c665d8437be1f5c09
7
- data.tar.gz: 41e331acd52cfdcd5bd979c05b40f0e9ef70c433cdfbd3ad4b586b2b5738e96b2f0f94fdf10a2093a8eca8482ef20d56462589963f9e7b7158a1da86c025103f
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,7 +1,8 @@
1
- require 'keycloak_oauth/authorizable_error'
2
- require 'keycloak_oauth/not_found_error'
3
1
  require 'net/http'
4
2
 
3
+ require_relative "authorizable_error"
4
+ require_relative "not_found_error"
5
+
5
6
  module KeycloakOauth
6
7
  class AuthorizableService
7
8
  HTTP_SUCCESS_CODES = [Net::HTTPOK, Net::HTTPNoContent, Net::HTTPCreated]
@@ -0,0 +1,3 @@
1
+ module KeycloakOauth
2
+ class DuplicationError < StandardError; end
3
+ end
@@ -1,8 +1,9 @@
1
1
  require 'net/http'
2
2
 
3
- module KeycloakOauth
4
- class DuplicationError < StandardError; end
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
 
@@ -1,4 +1,4 @@
1
- require 'keycloak_oauth/endpoints'
1
+ require_relative 'endpoints'
2
2
 
3
3
  module KeycloakOauth
4
4
  class Connection
@@ -1,3 +1,3 @@
1
1
  module KeycloakOauth
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -1,7 +1,7 @@
1
- require 'keycloak_oauth/version'
2
- require 'keycloak_oauth/configuration'
3
- require 'keycloak_oauth/connection'
4
- require 'keycloak_oauth/engine'
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.1
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: 2022-06-20 00:00:00.000000000 Z
11
+ date: 2024-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,6 +122,7 @@ files:
122
122
  - app/services/keycloak_oauth/authentication_service_base.rb
123
123
  - app/services/keycloak_oauth/authorizable_error.rb
124
124
  - app/services/keycloak_oauth/authorizable_service.rb
125
+ - app/services/keycloak_oauth/duplication_error.rb
125
126
  - app/services/keycloak_oauth/get_users_service.rb
126
127
  - app/services/keycloak_oauth/logout_service.rb
127
128
  - app/services/keycloak_oauth/not_found_error.rb