Skip to main content

opentalk_client/
oidc.rs

1// SPDX-FileCopyrightText: OpenTalk GmbH <mail@opentalk.eu>
2//
3// SPDX-License-Identifier: EUPL-1.2
4
5use http_request_derive::HttpRequest;
6use secrecy::SecretString;
7use serde::Deserialize;
8use url::Url;
9
10#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
11/// OAuth2/OIDC endpoints as pers [spec](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
12pub struct OidcEndpoints {
13    /// [Device Authorization Endpoint](https://datatracker.ietf.org/doc/html/rfc8628#section-3.1)
14    pub device_authorization_endpoint: Option<Url>,
15    /// [Authorization Endpoint](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint)
16    pub authorization_endpoint: Url,
17    /// [Token Endpoint](https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint)
18    pub token_endpoint: Url,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, HttpRequest)]
22#[http_request(
23    method = "GET",
24    response = OidcEndpoints,
25    path = ".well-known/openid-configuration"
26)]
27pub(crate) struct OidcWellKnownRequest;
28
29/// Supported auth methods to obtain OAuth2/OIDC grants
30#[derive(Debug)]
31pub enum OidcAuthMethod {
32    /// Used to obtain a Resource Owner Password (Direct Access) grant
33    DirectAccess {
34        /// Username
35        username: String,
36        /// Password
37        password: SecretString,
38    },
39    /// Used to obtain a Token Exchange grant
40    TokenExchange {
41        /// Token, that will be exchanged against an OIDC access token
42        subject_token: SecretString,
43    },
44    /// Used to obtain a Device Authorization grant
45    DeviceAuthorization,
46}