Skip to content

Commit

Permalink
Add note about missing CSRF validation in oauth example (#2512)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpdrsn authored Jan 13, 2024
1 parent 9ebd105 commit 358f196
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/oauth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ async fn index(user: Option<User>) -> impl IntoResponse {
}

async fn discord_auth(State(client): State<BasicClient>) -> impl IntoResponse {
// TODO: this example currently doesn't validate the CSRF token during login attempts. That
// makes it vulnerable to cross-site request forgery. If you copy code from this example make
// sure to add a check for the CSRF token.
//
// Issue for adding check to this example https://github.com/tokio-rs/axum/issues/2511
let (auth_url, _csrf_token) = client
.authorize_url(CsrfToken::new_random)
.add_scope(Scope::new("identify".to_string()))
Expand Down

0 comments on commit 358f196

Please sign in to comment.