You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-23 11:02:35 +03:00
Refactor token generation a bit
This commit is contained in:
@@ -62,7 +62,7 @@ use crate::{
|
||||
SessionInfo,
|
||||
},
|
||||
templates::{FormPostContext, Templates},
|
||||
tokens,
|
||||
tokens::{AccessToken, RefreshToken},
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
@@ -428,8 +428,8 @@ async fn step(
|
||||
let (access_token, refresh_token) = {
|
||||
let mut rng = thread_rng();
|
||||
(
|
||||
tokens::generate(&mut rng, tokens::TokenType::AccessToken),
|
||||
tokens::generate(&mut rng, tokens::TokenType::RefreshToken),
|
||||
AccessToken.generate(&mut rng),
|
||||
RefreshToken.generate(&mut rng),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::{
|
||||
database::connection,
|
||||
},
|
||||
storage::oauth2::{access_token::lookup_access_token, refresh_token::lookup_refresh_token},
|
||||
tokens,
|
||||
tokens::{self, TokenType},
|
||||
};
|
||||
|
||||
pub fn filter(
|
||||
@@ -70,7 +70,7 @@ async fn introspect(
|
||||
}
|
||||
|
||||
let token = ¶ms.token;
|
||||
let token_type = tokens::check(token).wrap_error()?;
|
||||
let token_type = TokenType::check(token).wrap_error()?;
|
||||
if let Some(hint) = params.token_type_hint {
|
||||
if token_type != hint {
|
||||
info!("Token type hint did not match");
|
||||
|
||||
@@ -50,7 +50,7 @@ use crate::{
|
||||
authorization_code::{consume_code, lookup_code},
|
||||
refresh_token::{add_refresh_token, lookup_refresh_token, replace_refresh_token},
|
||||
},
|
||||
tokens,
|
||||
tokens::{AccessToken, RefreshToken},
|
||||
};
|
||||
|
||||
#[skip_serializing_none]
|
||||
@@ -164,8 +164,8 @@ async fn authorization_code_grant(
|
||||
let (access_token, refresh_token) = {
|
||||
let mut rng = thread_rng();
|
||||
(
|
||||
tokens::generate(&mut rng, tokens::TokenType::AccessToken),
|
||||
tokens::generate(&mut rng, tokens::TokenType::RefreshToken),
|
||||
AccessToken.generate(&mut rng),
|
||||
RefreshToken.generate(&mut rng),
|
||||
)
|
||||
};
|
||||
|
||||
@@ -234,8 +234,8 @@ async fn refresh_token_grant(
|
||||
let (access_token, refresh_token) = {
|
||||
let mut rng = thread_rng();
|
||||
(
|
||||
tokens::generate(&mut rng, tokens::TokenType::AccessToken),
|
||||
tokens::generate(&mut rng, tokens::TokenType::RefreshToken),
|
||||
AccessToken.generate(&mut rng),
|
||||
RefreshToken.generate(&mut rng),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ use warp::{Filter, Rejection, Reply};
|
||||
|
||||
use crate::{
|
||||
config::OAuth2Config,
|
||||
filters::authenticate::{recover_unauthorized, authentication},
|
||||
filters::authenticate::{authentication, recover_unauthorized},
|
||||
storage::oauth2::access_token::OAuth2AccessTokenLookup,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user