bug: #1 fix auth using pkce
This commit is contained in:
parent
050b9da48a
commit
2bd682de6a
|
@ -27,6 +27,7 @@ chrono = { version = "0.4", features = ["serde"] }
|
||||||
strum = { version = "0.24.1", features = ["derive"] }
|
strum = { version = "0.24.1", features = ["derive"] }
|
||||||
urlencoding = "2.1.0"
|
urlencoding = "2.1.0"
|
||||||
derive_more = "0.99"
|
derive_more = "0.99"
|
||||||
|
pkce = "0.2.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
test-log = { version = "0.2", default-features = false, features = ["trace"] }
|
test-log = { version = "0.2", default-features = false, features = ["trace"] }
|
||||||
|
|
|
@ -214,9 +214,11 @@ pub struct Code {
|
||||||
|
|
||||||
impl Code {
|
impl Code {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
let verifier = random_string(86);
|
let verifier = pkce::code_verifier(86);
|
||||||
let hex_digest = sha256::digest_bytes(verifier.as_bytes());
|
let challenge = pkce::code_challenge(&verifier);
|
||||||
let challenge = base64::encode_config(&hex_digest, base64::URL_SAFE);
|
|
||||||
|
// Unwrap should be OK here, since code_verifier() generates bytes from ASCII.
|
||||||
|
let verifier = String::from_utf8(verifier).unwrap();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
verifier,
|
verifier,
|
||||||
|
|
Loading…
Reference in a new issue