pub use volga_oauth_core::{
AuthorizationServerMetadata, BearerChallenge, ClientMetadata, ClientRegistrationResponse,
OAuthError, OAuthErrorCode, ProtectedResourceMetadata, WELL_KNOWN_AUTHORIZATION_SERVER,
WELL_KNOWN_OPENID_CONFIGURATION, WELL_KNOWN_PROTECTED_RESOURCE,
authorization_server_metadata_url, canonicalize_resource_uri, openid_configuration_url,
protected_resource_metadata_url,
};
mod handlers;
impl From<OAuthError> for crate::error::Error {
#[inline]
fn from(err: OAuthError) -> Self {
Self::from_parts(err.error.status(), None, err)
}
}
#[cfg(test)]
mod tests {
use super::{OAuthError, OAuthErrorCode};
use crate::{error::Error, http::StatusCode};
#[test]
fn it_converts_oauth_error_into_volga_error() {
let err: Error = OAuthError::new(OAuthErrorCode::InvalidToken)
.with_description("Token has expired")
.into();
assert_eq!(err.status(), StatusCode::UNAUTHORIZED);
assert!(err.instance().is_none());
assert_eq!(err.to_string(), "invalid_token: Token has expired");
}
}