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"] }
|
||||
urlencoding = "2.1.0"
|
||||
derive_more = "0.99"
|
||||
pkce = "0.2.0"
|
||||
|
||||
[dev-dependencies]
|
||||
test-log = { version = "0.2", default-features = false, features = ["trace"] }
|
||||
|
|
|
@ -214,9 +214,11 @@ pub struct Code {
|
|||
|
||||
impl Code {
|
||||
fn new() -> Self {
|
||||
let verifier = random_string(86);
|
||||
let hex_digest = sha256::digest_bytes(verifier.as_bytes());
|
||||
let challenge = base64::encode_config(&hex_digest, base64::URL_SAFE);
|
||||
let verifier = pkce::code_verifier(86);
|
||||
let challenge = pkce::code_challenge(&verifier);
|
||||
|
||||
// Unwrap should be OK here, since code_verifier() generates bytes from ASCII.
|
||||
let verifier = String::from_utf8(verifier).unwrap();
|
||||
|
||||
Self {
|
||||
verifier,
|
||||
|
|
Loading…
Reference in a new issue