-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PLATFORM-1195]: rfc8414 compliance #44
Conversation
match token_request { | ||
TokenRequest::ClientCredentials(request) => jwt_for_client_credentials(app_data, request).await, | ||
TokenRequest::AuthorizationCode(request) => jwt_for_authorization_code(app_data, request).await, | ||
} | ||
} | ||
|
||
impl token { | ||
pub const ENDPOINT: &str = "/oauth/token"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't like so much to have a string replicated. Can we change how routings are made and instead of using service
and #[post
macro use this kind of build pattern?
web::resource(controller::token::ENDPOINT)
.route(web::post().to(controller::token)))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like that, it's quite ugly. I don't like repeating the string either, but I prefer doing it this way
for reference, here is a cleaned up version of the #[post]
macro
struct token;
impl HttpServiceFactory for token {
fn register(self, cfg: &mut actix_web::dev::AppService) {
/// Generate a new jwt token for a given audience. For `client_credentials` the audience is found in the post body
/// and for `authorization_code` the audience is found in the authorizations cache.
/// All the permissions found in the local store will be included in the generated token.
async fn token(
app_data: Data<AppData>,
token_request: Either<Json<TokenRequest>, Form<TokenRequest>>,
) -> HttpResponse {
let (
Either::Left(Json(token_request))
| Either::Right(Form(token_request))
) = token_request;
match token_request {
TokenRequest::ClientCredentials(request) => {
jwt_for_client_credentials(app_data, request).await
}
TokenRequest::AuthorizationCode(request) => {
jwt_for_authorization_code(app_data, request).await
}
}
}
let res = Resource::new("/oauth/token")
.name("token")
.guard(::actix_web::guard::Post())
.to(token);
HttpServiceFactory::register(res, cfg)
}
}
ca9b19a
to
68707f0
Compare
https://prima-assicurazioni-spa.myjetbrains.com/youtrack/issue/PLATFORM-1195