Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ newtype-uuid = { version = "1.3.2", features = ["schemars08", "serde", "v4"] }
oauth2 = { version = "5.0.0", default-features = false, features = ["rustls-tls"] }
oauth2-reqwest = "0.1.0-alpha.3"
partial-struct = { git = "https://github.com/oxidecomputer/partial-struct" }
percent-encoding = "2.3.2"
proc-macro2 = "1"
quote = "1"
rand = "0.8.5"
Expand Down
1 change: 1 addition & 0 deletions v-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ oauth2 = { workspace = true }
oauth2-reqwest = { workspace = true }
newtype-uuid = { workspace = true }
partial-struct = { workspace = true }
percent-encoding = { workspace = true }
rand = { workspace = true, features = ["std"] }
rand_core = { workspace = true, features = ["std"] }
reqwest = { workspace = true }
Expand Down
7 changes: 5 additions & 2 deletions v-api/src/endpoints/login/oauth/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use newtype_uuid::TypedUuid;
use oauth2::{
AuthorizationCode, CsrfToken, PkceCodeChallenge, PkceCodeVerifier, Scope, TokenResponse,
};
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
use schemars::JsonSchema;
use secrecy::SecretString;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -205,8 +206,10 @@ where
// Assign any scope errors that arose
attempt.error = scope_error;

// Add in the user defined state and redirect uri
attempt.state = Some(query.state);
// Add in the user defined state and redirect uri. State is an arbitrary value and may be
// malicious. It must be url-encoded before being presented back to the client. Therefore we
// process once before storing so all downstream consumers see the encoded value.
attempt.state = Some(percent_encode(query.state.as_bytes(), NON_ALPHANUMERIC).to_string());

// If the remote provider supports pkce, set up a challenge
let pkce_challenge = if provider.supports_pkce() {
Expand Down
Loading