flwr_oauth2/authorization_server_metadata

This module implements RFC8414 OAuth 2.0 Authorization Server Metadata.

Types

Represents the document returned by the RFC8414 Authorization Server Metadata Endpoint.

pub type AuthorizationServerMetadata {
  AuthorizationServerMetadata(
    issuer: uri.Uri,
    authorization_endpoint: option.Option(uri.Uri),
    token_endpoint: option.Option(uri.Uri),
    jwks_uri: option.Option(uri.Uri),
    registration_endpoint: option.Option(uri.Uri),
    scopes_supported: option.Option(List(String)),
    response_types_supported: List(
      client_registration.ResponseType,
    ),
    response_modes_supported: List(ResponseMode),
    grant_types_supported: List(client_registration.GrantType),
    token_endpoint_auth_methods_supported: List(
      client_registration.TokenEndpointAuthMethod,
    ),
    token_endpoint_auth_signing_alg_values_supported: option.Option(
      List(jwk.Algorithm),
    ),
    service_documentation: option.Option(uri.Uri),
    ui_locales_supported: option.Option(List(String)),
    op_policy_uri: option.Option(uri.Uri),
    op_tos_uri: option.Option(uri.Uri),
    revocation_endpoint: option.Option(uri.Uri),
    revocation_endpoint_auth_methods_supported: List(
      client_registration.TokenEndpointAuthMethod,
    ),
    revocation_endpoint_auth_signing_alg_values_supported: option.Option(
      List(jwk.Algorithm),
    ),
    introspection_endpoint: option.Option(uri.Uri),
    introspection_endpoint_auth_methods_supported: option.Option(
      List(client_registration.TokenEndpointAuthMethod),
    ),
    introspection_endpoint_auth_signing_alg_values_supported: option.Option(
      List(jwk.Algorithm),
    ),
    code_challenge_methods_supported: option.Option(
      List(authorization_grant.CodeChallengeMethod),
    ),
    signed_metadata: option.Option(String),
  )
}

Constructors

pub type AuthorizationServerMetadataResponseError {
  ParseError(common.ParseError)
  InvalidStatus(status: Int)
}

Constructors

pub type ResponseMode {
  Query
  Fragment
  FormPost
  OtherResponseMode(value: String)
}

Constructors

  • Query
  • Fragment
  • FormPost
  • OtherResponseMode(value: String)

Values

pub fn parse_http_response(
  response resp: response.Response(String),
) -> Result(
  AuthorizationServerMetadata,
  AuthorizationServerMetadataResponseError,
)

Parses the body of the response of the metadata endpoint. Only parses fields declared by RFC8414, others are ignored. If they are required create a decoder for the missing fields, such as the ones required for OIDC discovery mechanism. According to RFC8414, the issuer field has to match exactly the request URI, since Gleam responses do not contain the original request URI this cannot be validated by this method. Furthermore, this method does not validate that the issuer URI does not contain any fragments or query parts.

pub fn to_http_request(
  endpoint: uri.Uri,
) -> Result(request.Request(String), token_request.RequestError)

Utility method to create a request from the .well-known endpoint for the authorization server metadata document. This method assumes that the endpoint provided is an already constructed endpoint.

✨ Search Document