mas_oidc_client/lib.rs
1// Copyright 2024 New Vector Ltd.
2// Copyright 2022-2024 Kévin Commaille.
3//
4// SPDX-License-Identifier: AGPL-3.0-only
5// Please see LICENSE in the repository root for full details.
6
7//! An [OpenID Connect] client library for the [Matrix] specification.
8//!
9//! This is part of the [Matrix Authentication Service] project.
10//!
11//! # Scope
12//!
13//! The scope of this crate is to support OIDC features required by the
14//! Matrix specification according to [MSC3861] and its sub-proposals.
15//!
16//! As such, it is compatible with the OpenID Connect 1.0 specification, but
17//! also enforces Matrix-specific requirements or adds compatibility with new
18//! [OAuth 2.0] features.
19//!
20//! # OpenID Connect and OAuth 2.0 Features
21//!
22//! - Grant Types:
23//! - [Authorization Code](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth)
24//! - [Client Credentials](https://www.rfc-editor.org/rfc/rfc6749#section-4.4)
25//! - [Device Code](https://www.rfc-editor.org/rfc/rfc8628) (TBD)
26//! - [Refresh Token](https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens)
27//! - [User Info](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo)
28//! - [PKCE](https://www.rfc-editor.org/rfc/rfc7636)
29//!
30//! # Matrix features
31//!
32//! - Client registration
33//! - Login
34//! - Matrix API Scopes
35//! - Logout
36//!
37//! [OpenID Connect]: https://openid.net/connect/
38//! [Matrix]: https://matrix.org/
39//! [Matrix Authentication Service]: https://github.com/element-hq/matrix-authentication-service
40//! [MSC3861]: https://github.com/matrix-org/matrix-spec-proposals/pull/3861
41//! [OAuth 2.0]: https://oauth.net/2/
42
43#![deny(missing_docs)]
44#![allow(clippy::module_name_repetitions, clippy::implicit_hasher)]
45
46pub mod error;
47pub mod requests;
48pub mod types;
49
50use std::fmt;
51
52#[doc(inline)]
53pub use mas_jose as jose;
54
55// Wrapper around `String` that cannot be used in a meaningful way outside of
56// this crate. Used for string enums that only allow certain characters because
57// their variant can't be private.
58#[doc(hidden)]
59#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
60pub struct PrivString(String);
61
62impl fmt::Debug for PrivString {
63 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
64 self.0.fmt(f)
65 }
66}