flwr_oauth2/pkce

This module provides functions to create PKCE Verifiers and Challens as per RFC7636.

Types

pub type AuthorizationCodeGrantTokenRequestWithPKCE {
  AuthorizationCodeGrantTokenRequestWithPKCE(
    token_endpoint: uri.Uri,
    authentication: authentication.ClientAuthentication,
    redirect_uri: option.Option(uri.Uri),
    code: String,
    code_verifier: String,
  )
}

Constructors

The code challenge created from a code verifier

pub type Challenge {
  Challenge(value: String)
}

Constructors

  • Challenge(value: String)

The code verifier

pub type Verifier {
  Verifier(value: String)
}

Constructors

  • Verifier(value: String)

Values

pub fn new() -> Verifier

Creates a new code verifier as per RFC7636 4.1. Uses a default length for the verifier of 128.

For the definition of the code verifier see this excerpt from RFC7636:

high-entropy cryptographic random STRING using the unreserved characters [A-Z] / [a-z] / [0-9] / “-” / “.” / “_” / “~” from Section 2.3 of [RFC3986], with a minimum length of 43 characters and a maximum length of 128 characters.

pub fn to_challenge(verifier: Verifier) -> Challenge

Creates a code challenge from a given verifier. The given code verifier should conform to the RFC7636 definition of a code verifier, otherwise the resulting code challenge will be invalid.

pub fn to_string(
  request: AuthorizationCodeGrantTokenRequestWithPKCE,
) -> String
Search Document