mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-12-04 22:31:47 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76d90f09f2 | ||
|
|
2f356eaa91 | ||
|
|
e6afb63648 | ||
|
|
ac7f79bd26 | ||
|
|
5f2b73db9d | ||
|
|
1a616146d0 |
No files matched your search
@@ -17,7 +17,7 @@ go to "files changed", and click on the "+" symbol in the line number gutter,
|
|||||||
and attach comments to the lines that you think would benefit from some clarification.
|
and attach comments to the lines that you think would benefit from some clarification.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
This pull request...
|
This pull request... <!-- do not forget to write here! -->
|
||||||
|
|
||||||
<!-- Example:
|
<!-- Example:
|
||||||
This pull request allows us to warp through time and space ten times faster than before by
|
This pull request allows us to warp through time and space ten times faster than before by
|
||||||
@@ -26,8 +26,8 @@ efficient. This resolves the common issue where we have to wait more than 10 mil
|
|||||||
engage, use, and disengage the warp drive when travelling between galaxies.
|
engage, use, and disengage the warp drive when travelling between galaxies.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- Closes: #... -->
|
<!-- Closes #... -->
|
||||||
<!-- Fixes: #... -->
|
<!-- Fixes #... -->
|
||||||
<!-- Uncomment the above line(s) if your pull request fixes an issue or closes another pull request
|
<!-- Uncomment the above line(s) if your pull request fixes an issue or closes another pull request
|
||||||
by superseding it. Replace `#...` with the issue/pr number, such as `#123`. -->
|
by superseding it. Replace `#...` with the issue/pr number, such as `#123`. -->
|
||||||
|
|
||||||
@@ -73,6 +73,7 @@ Notes on these requirements:
|
|||||||
main, it's difficult to get out cleanly, so put on your best dress, smile for the cameras!
|
main, it's difficult to get out cleanly, so put on your best dress, smile for the cameras!
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- Do not delete below this line -->
|
||||||
[c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md
|
[c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md
|
||||||
[c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx
|
[c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx
|
||||||
[c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks
|
[c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ repos:
|
|||||||
- pre-push
|
- pre-push
|
||||||
|
|
||||||
- repo: https://code.forgejo.org/forgejo/runner
|
- repo: https://code.forgejo.org/forgejo/runner
|
||||||
rev: v13.2.1
|
rev: v13.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: forgejo-runner-validate
|
- id: forgejo-runner-validate
|
||||||
stages:
|
stages:
|
||||||
|
|||||||
Generated
+119
-575
File diff suppressed because it is too large.
Load diff
+2
-12
@@ -166,15 +166,6 @@ features = [
|
|||||||
"form",
|
"form",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Needed for as long as openidconnect is on an outdated reqwest
|
|
||||||
[workspace.dependencies.reqwest_0_12]
|
|
||||||
package = "reqwest"
|
|
||||||
version = "0.12"
|
|
||||||
default-features = false
|
|
||||||
features = [
|
|
||||||
"rustls-tls-native-roots-no-provider",
|
|
||||||
]
|
|
||||||
|
|
||||||
[workspace.dependencies.serde]
|
[workspace.dependencies.serde]
|
||||||
version = "1.0.229"
|
version = "1.0.229"
|
||||||
default-features = false
|
default-features = false
|
||||||
@@ -422,10 +413,9 @@ default-features = false
|
|||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
[workspace.dependencies.openidconnect]
|
[workspace.dependencies.openid]
|
||||||
version = "4.1.0"
|
version = "0.26.0"
|
||||||
default-features = false
|
default-features = false
|
||||||
features = ["reqwest"]
|
|
||||||
|
|
||||||
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
# optional opentelemetry, performance measurements, flamegraphs, etc for performance measurements and monitoring
|
||||||
[workspace.dependencies.opentelemetry]
|
[workspace.dependencies.opentelemetry]
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
The `element_hacks` build feature, which has done almost nothing for many versions, has been removed completely. Contributed by @ginger.
|
||||||
@@ -102,7 +102,7 @@ look like this:
|
|||||||
RUSTFLAGS="--cfg tokio_unstable" cargo +nightly build \
|
RUSTFLAGS="--cfg tokio_unstable" cargo +nightly build \
|
||||||
--release \
|
--release \
|
||||||
--no-default-features \
|
--no-default-features \
|
||||||
--features=systemd,element_hacks,gzip_compression,brotli_compression,zstd_compression,tokio_console
|
--features=systemd,gzip_compression,brotli_compression,zstd_compression,tokio_console
|
||||||
```
|
```
|
||||||
|
|
||||||
You will also need to enable the `tokio_console` config option in Continuwuity
|
You will also need to enable the `tokio_console` config option in Continuwuity
|
||||||
|
|||||||
+1
-1
@@ -146,7 +146,7 @@ cargo clippy \
|
|||||||
--locked \
|
--locked \
|
||||||
--profile test \
|
--profile test \
|
||||||
--no-default-features \
|
--no-default-features \
|
||||||
--features=console,systemd,element_hacks,direct_tls,perf_measurements,brotli_compression \
|
--features=console,systemd,direct_tls,perf_measurements,brotli_compression \
|
||||||
--color=always \
|
--color=always \
|
||||||
-- \
|
-- \
|
||||||
-D warnings
|
-D warnings
|
||||||
|
|||||||
@@ -21,9 +21,6 @@ brotli_compression = [
|
|||||||
"conduwuit-service/brotli_compression",
|
"conduwuit-service/brotli_compression",
|
||||||
"reqwest/brotli",
|
"reqwest/brotli",
|
||||||
]
|
]
|
||||||
element_hacks = [
|
|
||||||
"conduwuit-service/element_hacks",
|
|
||||||
]
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"conduwuit-service/gzip_compression",
|
"conduwuit-service/gzip_compression",
|
||||||
|
|||||||
+1
-1
@@ -117,7 +117,7 @@ prometheus.workspace = true
|
|||||||
lock_api.workspace = true
|
lock_api.workspace = true
|
||||||
hyper-util.workspace = true
|
hyper-util.workspace = true
|
||||||
resolvematrix.workspace = true
|
resolvematrix.workspace = true
|
||||||
openidconnect.workspace = true
|
openid.workspace = true
|
||||||
libmimalloc-sys.optional = true
|
libmimalloc-sys.optional = true
|
||||||
libmimalloc-sys.workspace = true
|
libmimalloc-sys.workspace = true
|
||||||
mimalloc.optional = true
|
mimalloc.optional = true
|
||||||
|
|||||||
+5
-18
@@ -23,7 +23,6 @@ use figment::providers::{Env, Format, Toml};
|
|||||||
pub use figment::{Figment, value::Value as FigmentValue};
|
pub use figment::{Figment, value::Value as FigmentValue};
|
||||||
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
use governor::{DefaultKeyedRateLimiter, Quota, RateLimiter};
|
||||||
use lettre::message::Mailbox;
|
use lettre::message::Mailbox;
|
||||||
use openidconnect::{Audience, ClientId, ClientSecret, Scope};
|
|
||||||
use regex::RegexSet;
|
use regex::RegexSet;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
|
OwnedRoomId, OwnedRoomOrAliasId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId,
|
||||||
@@ -2802,15 +2801,15 @@ pub struct OidcConfig {
|
|||||||
/// automatically fetch the identity provider's metadata from this URL.
|
/// automatically fetch the identity provider's metadata from this URL.
|
||||||
/// Generally you should set this to the base domain your identity provider
|
/// Generally you should set this to the base domain your identity provider
|
||||||
/// runs on.
|
/// runs on.
|
||||||
pub discovery_url: String,
|
pub discovery_url: Url,
|
||||||
|
|
||||||
/// The OAuth client ID for Continuwuity to use when communicating with the
|
/// The OAuth client ID for Continuwuity to use when communicating with the
|
||||||
/// identity provider.
|
/// identity provider.
|
||||||
pub client_id: ClientId,
|
pub client_id: String,
|
||||||
|
|
||||||
/// The OAuth client secret for Continuwuity to use when communicating with
|
/// The OAuth client secret for Continuwuity to use when communicating with
|
||||||
/// the identity provider.
|
/// the identity provider.
|
||||||
pub client_secret: Option<ClientSecret>,
|
pub client_secret: Option<String>,
|
||||||
|
|
||||||
/// A path to a file which Continuwuity will read the client secret from.
|
/// A path to a file which Continuwuity will read the client secret from.
|
||||||
/// If this option is set, it will override `client_secret`.
|
/// If this option is set, it will override `client_secret`.
|
||||||
@@ -2826,19 +2825,7 @@ pub struct OidcConfig {
|
|||||||
///
|
///
|
||||||
/// default: ["profile"]
|
/// default: ["profile"]
|
||||||
#[serde(default = "default_additional_scopes")]
|
#[serde(default = "default_additional_scopes")]
|
||||||
pub additional_scopes: Vec<Scope>,
|
pub additional_scopes: Vec<String>,
|
||||||
|
|
||||||
/// Additional trusted audiences that Continuwuity will accept in the `aud`
|
|
||||||
/// claim of the OIDC token returned by the IDP. If your identity
|
|
||||||
/// provider includes other values in the `aud` claim in addition to the
|
|
||||||
/// client ID, they must be listed here for Continuwuity to accept them.
|
|
||||||
///
|
|
||||||
/// Most deployments will not need to set this, because most identity
|
|
||||||
/// providers only include the client ID in the `aud` claim by default.
|
|
||||||
///
|
|
||||||
/// default: []
|
|
||||||
#[serde(default)]
|
|
||||||
pub additional_trusted_audiences: BTreeSet<Audience>,
|
|
||||||
|
|
||||||
/// The name of the identity provider. If this is set, the login page's
|
/// The name of the identity provider. If this is set, the login page's
|
||||||
/// button reads "Continue with <name>" instead of just "Continue".
|
/// button reads "Continue with <name>" instead of just "Continue".
|
||||||
@@ -3444,7 +3431,7 @@ fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinut
|
|||||||
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_additional_scopes() -> Vec<Scope> { vec![Scope::new("profile".to_owned())] }
|
fn default_additional_scopes() -> Vec<String> { vec!["profile".to_owned()] }
|
||||||
|
|
||||||
// NOTE: This must be declared *after* every config struct in this file. The
|
// NOTE: This must be declared *after* every config struct in this file. The
|
||||||
// example config generator writes sections in macro expansion order, and the
|
// example config generator writes sections in macro expansion order, and the
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ default = [
|
|||||||
standard = [
|
standard = [
|
||||||
"brotli_compression",
|
"brotli_compression",
|
||||||
"direct_tls",
|
"direct_tls",
|
||||||
"element_hacks",
|
|
||||||
"gzip_compression",
|
"gzip_compression",
|
||||||
"io_uring",
|
"io_uring",
|
||||||
"jemalloc_conf",
|
"jemalloc_conf",
|
||||||
@@ -86,10 +85,6 @@ console = [
|
|||||||
direct_tls = [
|
direct_tls = [
|
||||||
"conduwuit-router/direct_tls"
|
"conduwuit-router/direct_tls"
|
||||||
]
|
]
|
||||||
element_hacks = [
|
|
||||||
"conduwuit-service/element_hacks",
|
|
||||||
"conduwuit-router/element_hacks",
|
|
||||||
]
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"conduwuit-router/gzip_compression",
|
"conduwuit-router/gzip_compression",
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ direct_tls = [
|
|||||||
"axum-server/tls-rustls-no-provider",
|
"axum-server/tls-rustls-no-provider",
|
||||||
"dep:axum-server-dual-protocol",
|
"dep:axum-server-dual-protocol",
|
||||||
]
|
]
|
||||||
element_hacks = [
|
|
||||||
"conduwuit-api/element_hacks",
|
|
||||||
]
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-admin/gzip_compression",
|
"conduwuit-admin/gzip_compression",
|
||||||
"conduwuit-api/gzip_compression",
|
"conduwuit-api/gzip_compression",
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ console = [
|
|||||||
"dep:rustyline-async",
|
"dep:rustyline-async",
|
||||||
"dep:termimad",
|
"dep:termimad",
|
||||||
]
|
]
|
||||||
element_hacks = []
|
|
||||||
gzip_compression = [
|
gzip_compression = [
|
||||||
"conduwuit-core/gzip_compression",
|
"conduwuit-core/gzip_compression",
|
||||||
"reqwest/gzip",
|
"reqwest/gzip",
|
||||||
@@ -131,10 +130,7 @@ yansi.workspace = true
|
|||||||
lettre.workspace = true
|
lettre.workspace = true
|
||||||
resolvematrix.workspace = true
|
resolvematrix.workspace = true
|
||||||
serde_urlencoded.workspace = true
|
serde_urlencoded.workspace = true
|
||||||
openidconnect.workspace = true
|
openid.workspace = true
|
||||||
# We use this to set TLS backend features on the outdated reqwest bundled by openidconnect,
|
|
||||||
# which is necessary to call `danger_accept_invalid_certs`.
|
|
||||||
reqwest_0_12.workspace = true
|
|
||||||
rand.workspace = true
|
rand.workspace = true
|
||||||
|
|
||||||
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
[target.'cfg(all(unix, target_os = "linux"))'.dependencies]
|
||||||
@@ -144,9 +140,6 @@ sd-notify.optional = true
|
|||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
||||||
[package.metadata.cargo-shear]
|
|
||||||
ignored = ["reqwest_0_12"]
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
opentelemetry.workspace = true
|
opentelemetry.workspace = true
|
||||||
rustls = { workspace = true, features = ["ring"] }
|
rustls = { workspace = true, features = ["ring"] }
|
||||||
@@ -44,18 +44,3 @@ impl reqwest::dns::Resolve for DnsResolver {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// openidconnect is weird and vendors reqwest (?), therefore we have to
|
|
||||||
// completely re-implement Resolve with different types
|
|
||||||
impl openidconnect::reqwest::dns::Resolve for DnsResolver {
|
|
||||||
fn resolve(&self, name: openidconnect::reqwest::dns::Name) -> Resolving {
|
|
||||||
let resolver = self.resolver.clone();
|
|
||||||
Box::pin(async move {
|
|
||||||
let lookup = resolver.lookup_ip(name.as_str()).await?;
|
|
||||||
let addrs: Addrs = Box::new(SocketAddrs {
|
|
||||||
iter: lookup.iter().collect::<Vec<_>>().into_iter(),
|
|
||||||
});
|
|
||||||
Ok(addrs)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+158
-168
@@ -1,26 +1,19 @@
|
|||||||
use std::{collections::HashMap, net::IpAddr, str::FromStr, sync::Arc, time::Duration};
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
net::IpAddr,
|
||||||
|
str::FromStr,
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Result, SyncRwLock,
|
Result, SyncRwLock,
|
||||||
config::{OidcConfig, OidcProfileKeyImportMode},
|
config::{OidcConfig, OidcProfileKeyImportMode},
|
||||||
debug, err, error, info, warn,
|
debug, err, error, info, utils, warn,
|
||||||
};
|
};
|
||||||
use database::{Deserialized, Map};
|
use database::{Deserialized, Map};
|
||||||
use lettre::Address;
|
use lettre::Address;
|
||||||
use openidconnect::{
|
use openid::{Claims as _, Options, StandardClaims, Token};
|
||||||
AdditionalClaims, AuthorizationCode, ClaimsVerificationError, ClientSecret, CsrfToken,
|
|
||||||
EmptyExtraTokenFields, EndpointMaybeSet, EndpointNotSet, EndpointSet, IdTokenClaims,
|
|
||||||
IdTokenFields, IssuerUrl, Nonce, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl,
|
|
||||||
SignatureVerificationError, StandardErrorResponse, StandardTokenResponse, TokenResponse,
|
|
||||||
core::{
|
|
||||||
CoreAuthDisplay, CoreAuthPrompt, CoreAuthenticationFlow, CoreErrorResponseType,
|
|
||||||
CoreGenderClaim, CoreJsonWebKey, CoreJweContentEncryptionAlgorithm,
|
|
||||||
CoreJwsSigningAlgorithm, CoreProviderMetadata, CoreRevocableToken,
|
|
||||||
CoreRevocationErrorResponse, CoreTokenIntrospectionResponse, CoreTokenType,
|
|
||||||
},
|
|
||||||
reqwest,
|
|
||||||
};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedUserId, UserId,
|
OwnedUserId, UserId,
|
||||||
api::client::profile::PropagateTo,
|
api::client::profile::PropagateTo,
|
||||||
@@ -50,6 +43,7 @@ struct Data {
|
|||||||
openidsubjectprofilefield_url: Arc<Map>,
|
openidsubjectprofilefield_url: Arc<Map>,
|
||||||
}
|
}
|
||||||
struct Services {
|
struct Services {
|
||||||
|
client: Dep<client::Service>,
|
||||||
config: Dep<config::Service>,
|
config: Dep<config::Service>,
|
||||||
globals: Dep<globals::Service>,
|
globals: Dep<globals::Service>,
|
||||||
media: Dep<media::Service>,
|
media: Dep<media::Service>,
|
||||||
@@ -58,56 +52,61 @@ struct Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct OidcClient {
|
struct OidcClient {
|
||||||
|
client_secret: String,
|
||||||
config: OidcConfig,
|
config: OidcConfig,
|
||||||
client_secret: ClientSecret,
|
client: SetOnce<SyncRwLock<Arc<IdpClient>>>,
|
||||||
machine: SetOnce<SyncRwLock<Arc<OidcClientMachine>>>,
|
|
||||||
client: reqwest::Client,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type OidcClientMachine = openidconnect::Client<
|
type IdpClient = openid::Client<openid::Discovered, Claims>;
|
||||||
AllClaims,
|
|
||||||
CoreAuthDisplay,
|
|
||||||
CoreGenderClaim,
|
|
||||||
CoreJweContentEncryptionAlgorithm,
|
|
||||||
CoreJsonWebKey,
|
|
||||||
CoreAuthPrompt,
|
|
||||||
StandardErrorResponse<CoreErrorResponseType>,
|
|
||||||
StandardTokenResponse<
|
|
||||||
IdTokenFields<
|
|
||||||
AllClaims,
|
|
||||||
EmptyExtraTokenFields,
|
|
||||||
CoreGenderClaim,
|
|
||||||
CoreJweContentEncryptionAlgorithm,
|
|
||||||
CoreJwsSigningAlgorithm,
|
|
||||||
>,
|
|
||||||
CoreTokenType,
|
|
||||||
>,
|
|
||||||
CoreTokenIntrospectionResponse,
|
|
||||||
CoreRevocableToken,
|
|
||||||
CoreRevocationErrorResponse,
|
|
||||||
EndpointSet,
|
|
||||||
EndpointNotSet,
|
|
||||||
EndpointNotSet,
|
|
||||||
EndpointNotSet,
|
|
||||||
EndpointMaybeSet,
|
|
||||||
EndpointMaybeSet,
|
|
||||||
>;
|
|
||||||
|
|
||||||
pub type Claims = IdTokenClaims<AllClaims, CoreGenderClaim>;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
pub struct AllClaims {
|
pub struct Claims {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub claims: HashMap<String, Value>,
|
standard_claims: StandardClaims,
|
||||||
|
|
||||||
|
#[serde(flatten)]
|
||||||
|
other_claims: HashMap<String, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AdditionalClaims for AllClaims {}
|
impl Claims {
|
||||||
|
fn get(&self, key: &str) -> Option<&Value> { self.other_claims.get(key) }
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! standard {
|
||||||
|
($($field:ident: $type:ty),*$(,)?) => {
|
||||||
|
$(
|
||||||
|
fn $field(&self) -> $type {
|
||||||
|
self.standard_claims.$field()
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl openid::Claims for Claims {
|
||||||
|
standard! {
|
||||||
|
userinfo: &openid::Userinfo,
|
||||||
|
c_hash: Option<&String>,
|
||||||
|
at_hash: Option<&String>,
|
||||||
|
iss: &Url,
|
||||||
|
sub: &str,
|
||||||
|
aud: &openid::SingleOrMultiple<String>,
|
||||||
|
exp: i64,
|
||||||
|
iat: i64,
|
||||||
|
auth_time: Option<i64>,
|
||||||
|
nonce: Option<&String>,
|
||||||
|
acr: Option<&String>,
|
||||||
|
amr: Option<&Vec<String>>,
|
||||||
|
azp: Option<&String>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl openid::CompactJson for Claims {}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct PendingSession {
|
pub struct PendingSession {
|
||||||
pkce_verifier: PkceCodeVerifier,
|
pkce_verifier: String,
|
||||||
nonce: Nonce,
|
nonce: String,
|
||||||
csrf_token: CsrfToken,
|
csrf_token: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum SessionCompletionStatus {
|
pub enum SessionCompletionStatus {
|
||||||
@@ -135,54 +134,33 @@ impl crate::Service for Service {
|
|||||||
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
|
||||||
Ok(Arc::new(Self {
|
Ok(Arc::new(Self {
|
||||||
services: Services {
|
services: Services {
|
||||||
|
client: args.depend::<client::Service>("client"),
|
||||||
config: args.depend::<config::Service>("config"),
|
config: args.depend::<config::Service>("config"),
|
||||||
globals: args.depend::<globals::Service>("globals"),
|
globals: args.depend::<globals::Service>("globals"),
|
||||||
media: args.depend::<media::Service>("media"),
|
media: args.depend::<media::Service>("media"),
|
||||||
threepid: args.depend::<threepid::Service>("threepid"),
|
threepid: args.depend::<threepid::Service>("threepid"),
|
||||||
users: args.depend::<users::Service>("users"),
|
users: args.depend::<users::Service>("users"),
|
||||||
},
|
},
|
||||||
runtime: args.server.runtime().clone(),
|
runtime: args.server.runtime().clone(),
|
||||||
db: Data {
|
db: Data {
|
||||||
openidsubject_localpart: args.db["openidsubject_localpart"].clone(),
|
openidsubject_localpart: args.db["openidsubject_localpart"].clone(),
|
||||||
openidsubjectprofilefield_url: args.db["openidsubjectprofilefield_url"].clone(),
|
openidsubjectprofilefield_url: args.db["openidsubjectprofilefield_url"].clone(),
|
||||||
},
|
},
|
||||||
client: args.server.config.oauth.oidc.as_ref().map(|config| -> Result<OidcClient> {
|
client: args
|
||||||
Ok(OidcClient {
|
.server
|
||||||
config: config.clone(),
|
.config
|
||||||
client_secret: if let Some(client_secret_file) = &config.client_secret_file {
|
.oauth
|
||||||
std::fs::read_to_string(client_secret_file)
|
.oidc
|
||||||
.map(|client_secret| client_secret.trim().to_owned())
|
.clone()
|
||||||
.map(ClientSecret::new)
|
.map(Self::create_client)
|
||||||
.map_err(|err| err!("Failed to read OIDC client secret file: {err}"))?
|
.transpose()?,
|
||||||
} else if let Some(client_secret) = &config.client_secret {
|
|
||||||
client_secret.clone()
|
|
||||||
} else {
|
|
||||||
// The config check function should cause an early exit before this happens
|
|
||||||
panic!("neither client secret or client secret file were set");
|
|
||||||
},
|
|
||||||
machine: SetOnce::new(),
|
|
||||||
// This isn't in the client service because it has to use the `reqwest` shipped by `openidconnect`
|
|
||||||
client: reqwest::ClientBuilder::new()
|
|
||||||
.dns_resolver(args.depend::<client::Service>("client").reqwest_resolver.clone())
|
|
||||||
.connect_timeout(Duration::from_secs(args.server.config.request_conn_timeout))
|
|
||||||
.read_timeout(Duration::from_secs(args.server.config.request_timeout))
|
|
||||||
.timeout(Duration::from_secs(args.server.config.request_total_timeout))
|
|
||||||
.pool_idle_timeout(Duration::from_secs(args.server.config.request_idle_timeout))
|
|
||||||
.pool_max_idle_per_host(args.server.config.request_idle_per_host.into())
|
|
||||||
.user_agent(conduwuit::user_agent())
|
|
||||||
.redirect(reqwest::redirect::Policy::none())
|
|
||||||
.danger_accept_invalid_certs(args.server.config.allow_invalid_tls_certificates_yes_i_know_what_the_fuck_i_am_doing_with_this_and_i_know_this_is_insecure)
|
|
||||||
.build()
|
|
||||||
.expect("client should build")
|
|
||||||
})}
|
|
||||||
).transpose()?,
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn worker(self: Arc<Self>) -> Result {
|
async fn worker(self: Arc<Self>) -> Result {
|
||||||
if let Some(OidcClient { machine, .. }) = &self.client {
|
if let Some(OidcClient { client, .. }) = &self.client {
|
||||||
let discovered = self.discover().await?;
|
let discovered = self.discover().await?;
|
||||||
machine
|
client
|
||||||
.set(SyncRwLock::new(Arc::new(discovered)))
|
.set(SyncRwLock::new(Arc::new(discovered)))
|
||||||
.expect("machine should be empty");
|
.expect("machine should be empty");
|
||||||
}
|
}
|
||||||
@@ -198,13 +176,36 @@ impl Service {
|
|||||||
// into the media repository. Keep this synced with the list in the
|
// into the media repository. Keep this synced with the list in the
|
||||||
// doc comment for `profile_key_map` in the config.
|
// doc comment for `profile_key_map` in the config.
|
||||||
const IMAGE_PROFILE_KEYS: &[&str] = &["avatar_url", "chat.commet.profile_banner"];
|
const IMAGE_PROFILE_KEYS: &[&str] = &["avatar_url", "chat.commet.profile_banner"];
|
||||||
|
const NONCE_SIZE: usize = 32;
|
||||||
const SERVER_MISCONFIGURED: &str =
|
const SERVER_MISCONFIGURED: &str =
|
||||||
"Identity server is misconfigured. Contact your homeserver's administrator.";
|
"Identity server is misconfigured. Contact your homeserver's administrator.";
|
||||||
|
|
||||||
|
fn create_nonce() -> String { utils::random_string(Self::NONCE_SIZE) }
|
||||||
|
|
||||||
|
fn create_client(config: OidcConfig) -> Result<OidcClient> {
|
||||||
|
let client_secret = if let Some(client_secret_file) = &config.client_secret_file {
|
||||||
|
std::fs::read_to_string(client_secret_file)
|
||||||
|
.map(|client_secret| client_secret.trim().to_owned())
|
||||||
|
.map_err(|err| err!("Failed to read OIDC client secret file: {err}"))?
|
||||||
|
} else if let Some(client_secret) = &config.client_secret {
|
||||||
|
client_secret.clone()
|
||||||
|
} else {
|
||||||
|
// The config check function should cause an early exit before this
|
||||||
|
// happens
|
||||||
|
panic!("neither client secret or client secret file were set");
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(OidcClient {
|
||||||
|
client_secret,
|
||||||
|
config,
|
||||||
|
client: SetOnce::new(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn enabled(&self) -> bool { self.client.is_some() }
|
pub fn enabled(&self) -> bool { self.client.is_some() }
|
||||||
|
|
||||||
async fn discover(&self) -> Result<OidcClientMachine> {
|
async fn discover(&self) -> Result<IdpClient> {
|
||||||
let OidcClient { config, client_secret, client, .. } =
|
let OidcClient { config, client_secret, .. } =
|
||||||
self.client.as_ref().expect("oidc should be configured");
|
self.client.as_ref().expect("oidc should be configured");
|
||||||
|
|
||||||
let redirect_url = self
|
let redirect_url = self
|
||||||
@@ -214,20 +215,15 @@ impl Service {
|
|||||||
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
|
.join(&format!("{}/oidc/complete", conduwuit::ROUTE_PREFIX))
|
||||||
.expect("redirect url should be valid");
|
.expect("redirect url should be valid");
|
||||||
|
|
||||||
let provider_metadata = CoreProviderMetadata::discover_async(
|
IdpClient::discover_with_client(
|
||||||
IssuerUrl::new(config.discovery_url.clone())
|
self.services.client.external_resource.clone(),
|
||||||
.map_err(|err| err!("Failed to parse OIDC discovery URL: {err}"))?,
|
|
||||||
client,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))?;
|
|
||||||
|
|
||||||
Ok(OidcClientMachine::from_provider_metadata(
|
|
||||||
provider_metadata,
|
|
||||||
config.client_id.clone(),
|
config.client_id.clone(),
|
||||||
Some(client_secret.clone()),
|
Some(client_secret.clone()),
|
||||||
|
Some(redirect_url.to_string()),
|
||||||
|
config.discovery_url.clone(),
|
||||||
)
|
)
|
||||||
.set_redirect_uri(RedirectUrl::from_url(redirect_url)))
|
.await
|
||||||
|
.map_err(|err| err!("Failed to discover OIDC provider metadata: {err}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provider_name(&self) -> Option<String> {
|
pub fn provider_name(&self) -> Option<String> {
|
||||||
@@ -256,29 +252,32 @@ impl Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn begin_session(&self, prompt: Option<CoreAuthPrompt>) -> (PendingSession, Url) {
|
pub async fn begin_session(&self, prompt: Option<openid::Prompt>) -> (PendingSession, Url) {
|
||||||
let OidcClient { machine, config, .. } =
|
let OidcClient { client, config, .. } =
|
||||||
self.client.as_ref().expect("oidc should be configured");
|
self.client.as_ref().expect("oidc should be configured");
|
||||||
let machine = machine.wait().await.read().clone();
|
let client = client.wait().await.read().clone();
|
||||||
|
|
||||||
let (pkce_challenge, pkce_verifier) = PkceCodeChallenge::new_random_sha256();
|
let csrf_token = Self::create_nonce();
|
||||||
|
let nonce = Self::create_nonce();
|
||||||
|
|
||||||
let mut auth_url = machine
|
let (auth_url, pkce) = client.auth_url_with_new_pkce(&Options {
|
||||||
.authorize_url(
|
// The client will add the `openid` scope for us.
|
||||||
CoreAuthenticationFlow::AuthorizationCode,
|
scope: Some(config.additional_scopes.join(" ")),
|
||||||
CsrfToken::new_random,
|
state: Some(csrf_token.clone()),
|
||||||
Nonce::new_random,
|
nonce: Some(nonce.clone()),
|
||||||
)
|
prompt: prompt.map(|prompt| HashSet::from_iter([prompt])),
|
||||||
.add_scopes(config.additional_scopes.iter().cloned())
|
|
||||||
.set_pkce_challenge(pkce_challenge);
|
|
||||||
|
|
||||||
if let Some(prompt) = prompt {
|
..Default::default()
|
||||||
auth_url = auth_url.add_prompt(prompt);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
let (auth_url, csrf_token, nonce) = auth_url.url();
|
(
|
||||||
|
PendingSession {
|
||||||
(PendingSession { pkce_verifier, nonce, csrf_token }, auth_url)
|
pkce_verifier: pkce.code_verifier().to_owned(),
|
||||||
|
nonce,
|
||||||
|
csrf_token,
|
||||||
|
},
|
||||||
|
auth_url,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn exchange_code(
|
pub async fn exchange_code(
|
||||||
@@ -286,78 +285,77 @@ impl Service {
|
|||||||
session: PendingSession,
|
session: PendingSession,
|
||||||
response: AuthorizationCodeResponse,
|
response: AuthorizationCodeResponse,
|
||||||
) -> Result<Claims, &'static str> {
|
) -> Result<Claims, &'static str> {
|
||||||
let Some(OidcClient { machine, client, config, .. }) = self.client.as_ref() else {
|
let Some(OidcClient { client, .. }) = self.client.as_ref() else {
|
||||||
return Err("Delegated authentication is not enabled on this server.");
|
return Err("Delegated authentication is not enabled on this server.");
|
||||||
};
|
};
|
||||||
|
|
||||||
let current = machine.wait().await.read().clone();
|
let current = client.wait().await.read().clone();
|
||||||
|
|
||||||
if session.csrf_token.into_secret() != response.state {
|
if session.csrf_token != response.state {
|
||||||
return Err("State mismatch.");
|
return Err("State mismatch.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let token_response = current
|
let token_response = current
|
||||||
.exchange_code(AuthorizationCode::new(response.code))
|
.request_token_pkce(&response.code, Some(&session.pkce_verifier))
|
||||||
.expect("machine should be configured correctly")
|
|
||||||
.set_pkce_verifier(session.pkce_verifier)
|
|
||||||
.request_async(client)
|
|
||||||
.await
|
.await
|
||||||
|
.map(Token::<Claims>::from)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
error!(error=?err, "Failed to exchange OIDC authorization code");
|
error!(error=?err, "Failed to exchange OIDC authorization code");
|
||||||
"Code exchange failed. The identity provider may be unreachable. Contact your \
|
"Code exchange failed. The identity provider may be unreachable. Contact your \
|
||||||
homeserver's administrator."
|
homeserver's administrator."
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let Some(id_token) = token_response.id_token() else {
|
let Some(mut id_token) = token_response.id_token else {
|
||||||
error!("Identity server did not return an id token");
|
error!("Identity server did not return an id token");
|
||||||
return Err(Self::SERVER_MISCONFIGURED);
|
return Err(Self::SERVER_MISCONFIGURED);
|
||||||
};
|
};
|
||||||
|
|
||||||
let verify = |machine: &OidcClientMachine| {
|
if let Err(err) = current.decode_token(&mut id_token) {
|
||||||
let verifier =
|
error!(error=?err, "Failed to decode ID token");
|
||||||
machine
|
return Err(Self::SERVER_MISCONFIGURED);
|
||||||
.id_token_verifier()
|
}
|
||||||
.set_other_audience_verifier_fn(|audience| {
|
|
||||||
config.additional_trusted_audiences.contains(audience)
|
|
||||||
});
|
|
||||||
|
|
||||||
id_token
|
let verify = |client: &IdpClient| {
|
||||||
.claims(&verifier, &session.nonce)
|
client.validate_token(&id_token, Some(session.nonce.as_str()), None)
|
||||||
.map(ToOwned::to_owned)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut result = verify(¤t);
|
let mut result = verify(¤t);
|
||||||
|
|
||||||
if matches!(
|
if matches!(
|
||||||
result,
|
result,
|
||||||
Err(ClaimsVerificationError::SignatureVerification(
|
Err(openid::error::Error::Jose(openid::error::Jose::ValidationError(
|
||||||
SignatureVerificationError::NoMatchingKey
|
openid::biscuit::errors::ValidationError::KeyNotFound
|
||||||
))
|
)))
|
||||||
) {
|
) {
|
||||||
match self.discover().await {
|
match self.discover().await {
|
||||||
| Ok(discovered) => {
|
| Ok(discovered) => {
|
||||||
info!("Refreshed OIDC provider metadata after an unknown signing key");
|
info!("Refreshed OIDC provider metadata after an unknown signing key");
|
||||||
result = verify(&discovered);
|
result = verify(&discovered);
|
||||||
*machine.wait().await.write() = Arc::new(discovered);
|
*client.wait().await.write() = Arc::new(discovered);
|
||||||
},
|
},
|
||||||
| Err(err) => warn!("Failed to refresh OIDC provider metadata: {err}"),
|
| Err(err) => warn!("Failed to refresh OIDC provider metadata: {err}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let claims = result.map_err(|err| {
|
match result {
|
||||||
error!("Failed to verify id token claims: {err}");
|
| Ok(()) => {
|
||||||
Self::SERVER_MISCONFIGURED
|
let (_, claims) = id_token.unwrap_decoded();
|
||||||
})?;
|
|
||||||
|
|
||||||
info!(subject = claims.subject().as_str(), "Authenticated subject");
|
info!(subject = claims.sub(), "Authenticated subject");
|
||||||
|
|
||||||
Ok(claims)
|
Ok(claims)
|
||||||
|
},
|
||||||
|
| Err(err) => {
|
||||||
|
error!("Failed to verify id token claims: {err}");
|
||||||
|
Err(Self::SERVER_MISCONFIGURED)
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self, claims), fields(subject = claims.subject().to_string()))]
|
#[tracing::instrument(skip(self, claims), fields(subject = claims.sub().to_owned()))]
|
||||||
pub async fn complete_session(
|
pub async fn complete_session(
|
||||||
&self,
|
&self,
|
||||||
claims: &Claims,
|
claims: Claims,
|
||||||
supplied_user_id: Option<OwnedUserId>,
|
supplied_user_id: Option<OwnedUserId>,
|
||||||
client_ip: &IpAddr,
|
client_ip: &IpAddr,
|
||||||
) -> Result<SessionCompletionStatus, &'static str> {
|
) -> Result<SessionCompletionStatus, &'static str> {
|
||||||
@@ -365,21 +363,14 @@ impl Service {
|
|||||||
return Err("Delegated authentication is not enabled on this server.");
|
return Err("Delegated authentication is not enabled on this server.");
|
||||||
};
|
};
|
||||||
|
|
||||||
// this is a truly awful hack but we really need all the claims in a map
|
debug!(claims = ?claims.other_claims, "Got claims from the identity provider");
|
||||||
let all_claims = serde_json::to_value(claims)
|
|
||||||
.expect("should be able to serialize claims")
|
|
||||||
.as_object()
|
|
||||||
.expect("claims should be an object")
|
|
||||||
.to_owned();
|
|
||||||
|
|
||||||
debug!(?all_claims, "Got claims from the identity provider");
|
let subject = claims.sub().to_owned();
|
||||||
|
|
||||||
let subject = claims.subject().as_str();
|
|
||||||
|
|
||||||
let user_id = if let Ok(localpart) = self
|
let user_id = if let Ok(localpart) = self
|
||||||
.db
|
.db
|
||||||
.openidsubject_localpart
|
.openidsubject_localpart
|
||||||
.get(subject)
|
.get(&subject)
|
||||||
.await
|
.await
|
||||||
.deserialized::<String>()
|
.deserialized::<String>()
|
||||||
{
|
{
|
||||||
@@ -391,7 +382,7 @@ impl Service {
|
|||||||
} else {
|
} else {
|
||||||
return Ok(SessionCompletionStatus::NeedsUserId);
|
return Ok(SessionCompletionStatus::NeedsUserId);
|
||||||
}
|
}
|
||||||
} else if let Some(preferred_username) = all_claims
|
} else if let Some(preferred_username) = claims
|
||||||
.get(&config.preferred_username_claim)
|
.get(&config.preferred_username_claim)
|
||||||
.and_then(|claim| claim.as_str())
|
.and_then(|claim| claim.as_str())
|
||||||
{
|
{
|
||||||
@@ -435,7 +426,7 @@ impl Service {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
self.link_user(&user_id, subject);
|
self.link_user(&user_id, &subject);
|
||||||
|
|
||||||
// Import profile fields
|
// Import profile fields
|
||||||
if matches!(config.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
if matches!(config.profile_key_import_mode, OidcProfileKeyImportMode::OnLogin)
|
||||||
@@ -445,7 +436,7 @@ impl Service {
|
|||||||
) && new_account_registered)
|
) && new_account_registered)
|
||||||
{
|
{
|
||||||
if let Some(email_claim) = &config.email_claim {
|
if let Some(email_claim) = &config.email_claim {
|
||||||
if let Some(email) = claims.email().map(|email| email.as_str())
|
if let Some(email) = claims.get(email_claim).and_then(|email| email.as_str())
|
||||||
&& let Ok(address) = Address::from_str(email)
|
&& let Ok(address) = Address::from_str(email)
|
||||||
{
|
{
|
||||||
if let Err(err) = self
|
if let Err(err) = self
|
||||||
@@ -465,7 +456,6 @@ impl Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let user_id = user_id.clone();
|
let user_id = user_id.clone();
|
||||||
let subject = claims.subject().to_string();
|
|
||||||
let profile_key_map = config.profile_key_map.clone();
|
let profile_key_map = config.profile_key_map.clone();
|
||||||
let openidsubjectprofilefield_url = self.db.openidsubjectprofilefield_url.clone();
|
let openidsubjectprofilefield_url = self.db.openidsubjectprofilefield_url.clone();
|
||||||
let users = self.services.users.clone();
|
let users = self.services.users.clone();
|
||||||
@@ -475,7 +465,7 @@ impl Service {
|
|||||||
// TODO: once we get support for full profile replacement, use
|
// TODO: once we get support for full profile replacement, use
|
||||||
// that logic instead
|
// that logic instead
|
||||||
for (field, claim) in &profile_key_map {
|
for (field, claim) in &profile_key_map {
|
||||||
let Some(value) = all_claims.get(claim).cloned() else {
|
let Some(value) = claims.get(claim).cloned() else {
|
||||||
warn!(?field, ?claim, "IDP provided no value for this mapped claim");
|
warn!(?field, ?claim, "IDP provided no value for this mapped claim");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -75,8 +75,7 @@ impl Service {
|
|||||||
"lazy loading should be enabled by your options"
|
"lazy loading should be enabled by your options"
|
||||||
);
|
);
|
||||||
|
|
||||||
let include_redundant = cfg!(feature = "element_hacks")
|
let include_redundant = ctx.options.is_some_and(Options::include_redundant_members);
|
||||||
|| ctx.options.is_some_and(Options::include_redundant_members);
|
|
||||||
|
|
||||||
let witness = self
|
let witness = self
|
||||||
.witness(ctx, senders.iter().map(AsRef::as_ref))
|
.witness(ctx, senders.iter().map(AsRef::as_ref))
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ form_urlencoded = "1.2.2"
|
|||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
lettre.workspace = true
|
lettre.workspace = true
|
||||||
memory-serve = "2.4.0"
|
memory-serve = "2.4.0"
|
||||||
openidconnect.workspace = true
|
openid.workspace = true
|
||||||
ruma.workspace = true
|
ruma.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use axum::{
|
|||||||
routing::{get, on},
|
routing::{get, on},
|
||||||
};
|
};
|
||||||
use conduwuit_api::client::handle_login;
|
use conduwuit_api::client::handle_login;
|
||||||
use openidconnect::core::CoreAuthPrompt;
|
use openid::Prompt;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
OwnedUserId,
|
OwnedUserId,
|
||||||
api::client::uiaa::{EmailUserIdentifier, MatrixUserIdentifier, UserIdentifier},
|
api::client::uiaa::{EmailUserIdentifier, MatrixUserIdentifier, UserIdentifier},
|
||||||
@@ -86,8 +86,8 @@ async fn route_login(
|
|||||||
let (session, redirect_url) = services
|
let (session, redirect_url) = services
|
||||||
.oidc
|
.oidc
|
||||||
.begin_session(match intent {
|
.begin_session(match intent {
|
||||||
| Some(LoginIntent::SwitchAccounts) => Some(CoreAuthPrompt::SelectAccount),
|
| Some(LoginIntent::SwitchAccounts) => Some(Prompt::SelectAccount),
|
||||||
| _ if reauthenticate => Some(CoreAuthPrompt::Consent),
|
| _ if reauthenticate => Some(Prompt::Consent),
|
||||||
| _ => None,
|
| _ => None,
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|||||||
@@ -106,10 +106,7 @@ async fn route_complete(
|
|||||||
.await
|
.await
|
||||||
.expect("should be able to serialize oidc session");
|
.expect("should be able to serialize oidc session");
|
||||||
|
|
||||||
services
|
Box::pin(services.oidc.complete_session(claims, None, &client_ip)).await
|
||||||
.oidc
|
|
||||||
.complete_session(&claims, None, &client_ip)
|
|
||||||
.await
|
|
||||||
},
|
},
|
||||||
| OidcSessionState::Authorized { claims } => {
|
| OidcSessionState::Authorized { claims } => {
|
||||||
let supplied_user_id = if let Some(form) = form {
|
let supplied_user_id = if let Some(form) = form {
|
||||||
@@ -166,10 +163,12 @@ async fn route_complete(
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
services
|
Box::pin(
|
||||||
.oidc
|
services
|
||||||
.complete_session(&claims, supplied_user_id, &client_ip)
|
.oidc
|
||||||
.await
|
.complete_session(*claims, supplied_user_id, &client_ip),
|
||||||
|
)
|
||||||
|
.await
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
.map_err(|err| WebError::BadRequest(err.to_owned()))?;
|
.map_err(|err| WebError::BadRequest(err.to_owned()))?;
|
||||||
|
|||||||
Reference in new issue
Block a user