@@ -149,28 +149,6 @@ impl SinglePurposeToken {
149
149
}
150
150
}
151
151
152
- // TODO: This has to be removed once single purpose token is used as a intermediate token
153
- #[ derive( Clone , Debug ) ]
154
- pub struct UserWithoutMerchantFromToken {
155
- pub user_id : String ,
156
- }
157
-
158
- #[ derive( serde:: Serialize , serde:: Deserialize ) ]
159
- pub struct UserAuthToken {
160
- pub user_id : String ,
161
- pub exp : u64 ,
162
- }
163
-
164
- #[ cfg( feature = "olap" ) ]
165
- impl UserAuthToken {
166
- pub async fn new_token ( user_id : String , settings : & Settings ) -> UserResult < String > {
167
- let exp_duration = std:: time:: Duration :: from_secs ( consts:: JWT_TOKEN_TIME_IN_SECS ) ;
168
- let exp = jwt:: generate_exp ( exp_duration) ?. as_secs ( ) ;
169
- let token_payload = Self { user_id, exp } ;
170
- jwt:: generate_jwt ( & token_payload, settings) . await
171
- }
172
- }
173
-
174
152
#[ derive( serde:: Serialize , serde:: Deserialize ) ]
175
153
pub struct AuthToken {
176
154
pub user_id : String ,
@@ -330,37 +308,6 @@ where
330
308
}
331
309
}
332
310
333
- #[ derive( Debug ) ]
334
- pub struct UserWithoutMerchantJWTAuth ;
335
-
336
- #[ cfg( feature = "olap" ) ]
337
- #[ async_trait]
338
- impl < A > AuthenticateAndFetch < UserWithoutMerchantFromToken , A > for UserWithoutMerchantJWTAuth
339
- where
340
- A : AppStateInfo + Sync ,
341
- {
342
- async fn authenticate_and_fetch (
343
- & self ,
344
- request_headers : & HeaderMap ,
345
- state : & A ,
346
- ) -> RouterResult < ( UserWithoutMerchantFromToken , AuthenticationType ) > {
347
- let payload = parse_jwt_payload :: < A , UserAuthToken > ( request_headers, state) . await ?;
348
- if payload. check_in_blacklist ( state) . await ? {
349
- return Err ( errors:: ApiErrorResponse :: InvalidJwtToken . into ( ) ) ;
350
- }
351
-
352
- Ok ( (
353
- UserWithoutMerchantFromToken {
354
- user_id : payload. user_id . clone ( ) ,
355
- } ,
356
- AuthenticationType :: UserJwt {
357
- user_id : payload. user_id ,
358
- } ,
359
- ) )
360
- }
361
- }
362
-
363
- #[ allow( dead_code) ]
364
311
#[ derive( Debug ) ]
365
312
pub ( crate ) struct SinglePurposeJWTAuth ( pub Purpose ) ;
366
313
0 commit comments