@@ -31,6 +31,7 @@ use ulid::Ulid;
31
31
use url:: Url ;
32
32
33
33
use crate :: {
34
+ handlers:: { COOKIE_AGE_DAYS , OIDC_SCOPE , SESSION_COOKIE_NAME , USER_COOKIE_NAME } ,
34
35
oidc:: { Claims , DiscoveredClient } ,
35
36
option:: CONFIG ,
36
37
rbac:: {
@@ -42,10 +43,6 @@ use crate::{
42
43
utils:: actix:: extract_session_key_from_req,
43
44
} ;
44
45
45
- // fetch common personalization scope to determine username.
46
- const SCOPE : & str = "openid profile email" ;
47
- const COOKIE_AGE_DAYS : usize = 7 ;
48
-
49
46
/// Struct representing query params returned from oidc provider
50
47
#[ derive( Deserialize , Debug ) ]
51
48
pub struct Login {
@@ -182,7 +179,7 @@ fn redirect_to_oidc(
182
179
) -> HttpResponse {
183
180
let redirect = query. into_inner ( ) . redirect . to_string ( ) ;
184
181
let auth_url = oidc_client. auth_url ( & Options {
185
- scope : Some ( SCOPE . into ( ) ) ,
182
+ scope : Some ( OIDC_SCOPE . into ( ) ) ,
186
183
state : Some ( redirect) ,
187
184
..Default :: default ( )
188
185
} ) ;
@@ -222,7 +219,7 @@ fn redirect_no_oauth_setup(mut url: Url) -> HttpResponse {
222
219
}
223
220
224
221
fn cookie_session ( id : Ulid ) -> Cookie < ' static > {
225
- let authorization_cookie = Cookie :: build ( "session" , id. to_string ( ) )
222
+ let authorization_cookie = Cookie :: build ( SESSION_COOKIE_NAME , id. to_string ( ) )
226
223
. max_age ( time:: Duration :: days ( COOKIE_AGE_DAYS as i64 ) )
227
224
. same_site ( SameSite :: Strict )
228
225
. path ( "/" )
@@ -231,7 +228,7 @@ fn cookie_session(id: Ulid) -> Cookie<'static> {
231
228
}
232
229
233
230
fn cookie_username ( username : & str ) -> Cookie < ' static > {
234
- let authorization_cookie = Cookie :: build ( "username" , username. to_string ( ) )
231
+ let authorization_cookie = Cookie :: build ( USER_COOKIE_NAME , username. to_string ( ) )
235
232
. max_age ( time:: Duration :: days ( COOKIE_AGE_DAYS as i64 ) )
236
233
. same_site ( SameSite :: Strict )
237
234
. path ( "/" )
0 commit comments