@@ -4,22 +4,20 @@ module ForestLiana
4
4
class OidcClientManager
5
5
def self . get_client_for_callback_url ( callback_url )
6
6
begin
7
- client_data = Rails . cache . read ( callback_url ) || nil
8
- if client_data . nil?
9
- configuration = ForestLiana ::OidcConfigurationRetriever . retrieve ( )
10
-
11
- if ForestLiana . forest_client_id . nil?
7
+ configuration = ForestLiana ::OidcConfigurationRetriever . retrieve ( )
8
+ if ForestLiana . forest_client_id . nil?
9
+ client_data = Rails . cache . read ( "#{ callback_url } -#{ ForestLiana . env_secret } -client-data" ) || nil
10
+ if client_data . nil?
12
11
client_credentials = ForestLiana ::OidcDynamicClientRegistrator . register ( {
13
12
token_endpoint_auth_method : 'none' ,
14
13
redirect_uris : [ callback_url ] ,
15
14
registration_endpoint : configuration [ 'registration_endpoint' ]
16
15
} )
17
- else
18
- client_credentials = { 'client_id' => ForestLiana . forest_client_id }
16
+ client_data = { :client_id => client_credentials [ 'client_id' ] , :issuer => configuration [ 'issuer' ] }
17
+ Rails . cache . write ( " #{ callback_url } - #{ ForestLiana . env_secret } -client-data" , client_data )
19
18
end
20
-
21
- client_data = { :client_id => client_credentials [ 'client_id' ] , :issuer => configuration [ 'issuer' ] }
22
- Rails . cache . write ( callback_url , client_data )
19
+ else
20
+ client_data = { :client_id => ForestLiana . forest_client_id , :issuer => configuration [ 'issuer' ] }
23
21
end
24
22
25
23
OpenIDConnect ::Client . new (
@@ -30,7 +28,7 @@ def self.get_client_for_callback_url(callback_url)
30
28
token_endpoint : '/oidc/token' ,
31
29
)
32
30
rescue => error
33
- Rails . cache . delete ( callback_url )
31
+ Rails . cache . delete ( " #{ callback_url } - #{ ForestLiana . env_secret } -client-data" )
34
32
raise error
35
33
end
36
34
end
0 commit comments