Authenticate a native protocol client. Returns `(identity, warning)` — warning is non-empty when the account is in a password grace period or `must_change_password` is set. `OidcBearer` tokens are validated directly against the OIDC provider catalog (not the `JwksRegistry` provider list), enabling runtime `CREATE OIDC PROVIDER` without a server restart.
(
state: &SharedState,
auth_mode: &crate::config::auth::AuthMode,
auth: &ProtoAuth,
peer_addr: &str,
)
| 16 | /// (not the `JwksRegistry` provider list), enabling runtime `CREATE OIDC PROVIDER` |
| 17 | /// without a server restart. |
| 18 | pub(crate) async fn handle_auth( |
| 19 | state: &SharedState, |
| 20 | auth_mode: &crate::config::auth::AuthMode, |
| 21 | auth: &ProtoAuth, |
| 22 | peer_addr: &str, |
| 23 | ) -> crate::Result<(AuthenticatedIdentity, Option<String>)> { |
| 24 | if let ProtoAuth::OidcBearer { token, .. } = auth { |
| 25 | let identity = crate::control::security::oidc::verify_bearer_token(state, token).await?; |
| 26 | state.audit_record( |
| 27 | crate::control::security::audit::AuditEvent::AuthSuccess, |
| 28 | Some(identity.tenant_id), |
| 29 | peer_addr, |
| 30 | &format!( |
| 31 | "OIDC bearer login: sub={} method=oidc_bearer", |
| 32 | identity.username |
| 33 | ), |
| 34 | ); |
| 35 | state.auth_metrics.record_auth_success("oidc_bearer"); |
| 36 | return Ok((identity, None)); |
| 37 | } |
| 38 | |
| 39 | let body = match auth { |
| 40 | ProtoAuth::Trust { username } => { |
| 41 | serde_json::json!({ "method": "trust", "username": username }) |
| 42 | } |
| 43 | ProtoAuth::Password { username, password } => { |
| 44 | serde_json::json!({ "method": "password", "username": username, "password": password }) |
| 45 | } |
| 46 | ProtoAuth::ApiKey { token } => { |
| 47 | serde_json::json!({ "method": "api_key", "token": token }) |
| 48 | } |
| 49 | _ => { |
| 50 | return Err(crate::Error::BadRequest { |
| 51 | detail: "unsupported authentication method".into(), |
| 52 | }); |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | super::super::super::session_auth::authenticate(state, auth_mode, &body, peer_addr).await |
| 57 | } |
| 58 | |
| 59 | /// Respond to a ping with a pong. |
| 60 | pub(crate) fn handle_ping(seq: u64) -> NativeResponse { |
no test coverage detected