use snafu::Snafu;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
#[non_exhaustive]
pub enum CompleteError {
#[snafu(display("Issuer mismatch: original = {}, callback = {}", original, callback))]
IssuerMismatch {
original: String,
callback: String,
},
#[snafu(display("State mismatch between original request and callback"))]
StateMismatch,
#[snafu(display(
"Authorization server claims to support issuer identification but no issuer returned."
))]
MissingIssuer,
#[snafu(display(
"ID token received but the grant cannot validate it; \
supply `jws_verifier_factory` on the builder"
))]
IdTokenVerifierNotConfigured,
#[snafu(display(
"ID token received but grant has no issuer configured; provide an issuer via server metadata or builder"
))]
IdTokenIssuerNotConfigured,
#[snafu(display(
"openid scope granted but token response contained no ID token (OIDC Core 1.0 §3.1.3.3)"
))]
MissingIdToken,
}
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
#[non_exhaustive]
pub enum StartError {
#[snafu(display(
"OIDC flow started (scope contains `openid`) but no `jws_verifier_factory` was \
supplied, so the required ID token (OIDC Core 1.0 §3.1.3.3) could never be \
validated; supply one on the builder, or set `oidc(false)` if `openid` is an \
ordinary scope on this server"
))]
OidcVerifierNotConfigured,
#[snafu(display(
"OIDC flow started (scope contains `openid`) but the grant has no issuer \
configured, so the required ID token (OIDC Core 1.0 §3.1.3.3) could never be \
validated; provide an issuer via server metadata or builder, or `.oidc(false)` \
if `openid` is an ordinary scope on this server"
))]
OidcIssuerNotConfigured,
}
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
#[non_exhaustive]
pub enum ParseCallbackError {
#[snafu(display("Authorization server returned error: {error}"))]
OAuthError {
error: String,
error_description: Option<String>,
},
#[snafu(display("Failed to parse callback parameters: {source}"))]
InvalidParameters {
source: crate::core::oauth_form::Error,
},
#[snafu(display("Missing required parameter: {param}"))]
MissingParameter {
param: &'static str,
},
}
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(super)))]
#[non_exhaustive]
pub enum BuildError {
#[snafu(display(
"jws_verifier_factory was set but no JWS verifier platform is configured; \
enable the `default-jws-verifier-platform` feature or call \
`.jws_verifier_platform(...)` on the builder"
))]
MissingJwsVerifierPlatform,
#[snafu(display(
"require_pushed_authorization_requests is set but no \
pushed_authorization_request_endpoint is configured; supply the endpoint \
or unset the requirement — proceeding would silently downgrade required \
PAR (RFC 9126 §5) to a plain authorization request"
))]
RequiredParEndpointMissing,
#[snafu(display(
"oidc(true) was set but no `jws_verifier_factory` was supplied, \
so ID tokens could never be validated"
))]
OidcRequiresVerifier,
#[snafu(display(
"oidc(true) was set but no issuer is configured; \
provide one via server metadata or builder"
))]
OidcRequiresIssuer,
}