All checks were successful
CI / Tests (push) Has been skipped
CI / Format (push) Successful in 3s
CI / Clippy (push) Successful in 3m7s
CI / Security Audit (push) Has been skipped
CI / Format (pull_request) Successful in 3s
CI / Clippy (pull_request) Successful in 3m5s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped
- Add external "Docs" link in sidebar with configurable DOCS_URL - Add Dockerfile.docs for VitePress static site (nginx) - Add DOCS_URL build arg to Dockerfile.dashboard - Run cargo fmt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
/// Keycloak OpenID Connect settings.
|
|
#[derive(Debug)]
|
|
pub struct KeycloakConfig {
|
|
pub url: String,
|
|
pub realm: String,
|
|
pub client_id: String,
|
|
pub redirect_uri: String,
|
|
pub app_url: String,
|
|
}
|
|
|
|
impl KeycloakConfig {
|
|
pub fn from_env() -> Option<Self> {
|
|
let url = std::env::var("KEYCLOAK_URL").ok()?;
|
|
let realm = std::env::var("KEYCLOAK_REALM").ok()?;
|
|
let client_id = std::env::var("KEYCLOAK_CLIENT_ID").ok()?;
|
|
let redirect_uri = std::env::var("REDIRECT_URI").ok()?;
|
|
let app_url = std::env::var("APP_URL").ok()?;
|
|
Some(Self {
|
|
url,
|
|
realm,
|
|
client_id,
|
|
redirect_uri,
|
|
app_url,
|
|
})
|
|
}
|
|
|
|
pub fn auth_endpoint(&self) -> String {
|
|
format!(
|
|
"{}/realms/{}/protocol/openid-connect/auth",
|
|
self.url, self.realm
|
|
)
|
|
}
|
|
|
|
pub fn token_endpoint(&self) -> String {
|
|
format!(
|
|
"{}/realms/{}/protocol/openid-connect/token",
|
|
self.url, self.realm
|
|
)
|
|
}
|
|
|
|
pub fn userinfo_endpoint(&self) -> String {
|
|
format!(
|
|
"{}/realms/{}/protocol/openid-connect/userinfo",
|
|
self.url, self.realm
|
|
)
|
|
}
|
|
|
|
pub fn logout_endpoint(&self) -> String {
|
|
format!(
|
|
"{}/realms/{}/protocol/openid-connect/logout",
|
|
self.url, self.realm
|
|
)
|
|
}
|
|
}
|