feat: store Outpost credentials as digests and rate limit public endpoints (auth M4)
Credentials - pairing codes and Outpost upload tokens are stored only as SHA-256 digests; the token is minted at claim (256-bit OsRng) and returned once - the old clear-text wormhole_tokens table is migrated in place and dropped with secure_delete; active tokens keep working with a fresh lifetime - admin rotate (with grace window) and revoke endpoints, audited; a revoked Outpost is refused on its next request - optional end date for the shared admin token (TESSERA_ADMIN_TOKEN_EXPIRES) Limits - governor per-source limits for emergency login, pairing claim and SSO start/callback; X-Forwarded-For only from TESSERA_TRUSTED_PROXIES; IPv6 by /64 - at most two concurrent Argon2 verifications, refused immediately when busy - denials audited at most once a minute per source - the mTLS listener now supplies the peer address to handlers Existing hubs: rotate every Outpost token after upgrading; old database copies still contain the clear-text tokens. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,13 +5,14 @@ use crate::auth::{AuditAction, AuditOutcome, AuditResource, Principal};
|
||||
use crate::oidc::OidcError;
|
||||
use crate::state::HubState;
|
||||
use axum::{
|
||||
extract::{Query, State},
|
||||
extract::{ConnectInfo, Query, State},
|
||||
http::{header, HeaderMap, HeaderValue, StatusCode},
|
||||
response::{IntoResponse, Redirect, Response},
|
||||
routing::get,
|
||||
Router,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
const CORRELATION: &str = "__Host-tessera-oidc";
|
||||
|
||||
@@ -59,8 +60,12 @@ fn correlation_from(headers: &HeaderMap) -> Option<String> {
|
||||
})
|
||||
}
|
||||
|
||||
async fn login(State(state): State<HubState>) -> Response {
|
||||
async fn login(peer: Option<ConnectInfo<SocketAddr>>, State(state): State<HubState>, headers: HeaderMap) -> Response {
|
||||
let Some(oidc) = state.oidc.clone() else { return StatusCode::NOT_FOUND.into_response() };
|
||||
let source = state.limits.source(peer.map(|ConnectInfo(a)| a), &headers);
|
||||
if !state.limits.oidc_login_allowed(source) {
|
||||
return StatusCode::TOO_MANY_REQUESTS.into_response();
|
||||
}
|
||||
let begun = match oidc.begin().await {
|
||||
Ok(begun) => begun,
|
||||
Err(_) => return failure(&state, "unavailable", StatusCode::SERVICE_UNAVAILABLE).await,
|
||||
@@ -76,8 +81,17 @@ async fn login(State(state): State<HubState>) -> Response {
|
||||
response
|
||||
}
|
||||
|
||||
async fn callback(State(state): State<HubState>, headers: HeaderMap, Query(query): Query<CallbackQuery>) -> Response {
|
||||
async fn callback(
|
||||
peer: Option<ConnectInfo<SocketAddr>>,
|
||||
State(state): State<HubState>,
|
||||
headers: HeaderMap,
|
||||
Query(query): Query<CallbackQuery>,
|
||||
) -> Response {
|
||||
let Some(oidc) = state.oidc.clone() else { return StatusCode::NOT_FOUND.into_response() };
|
||||
let source = state.limits.source(peer.map(|ConnectInfo(a)| a), &headers);
|
||||
if !state.limits.oidc_callback_allowed(source) {
|
||||
return StatusCode::TOO_MANY_REQUESTS.into_response();
|
||||
}
|
||||
let outcome = complete(&state, &oidc, &headers, query).await;
|
||||
let mut response = match outcome {
|
||||
Ok(session) => {
|
||||
|
||||
Reference in New Issue
Block a user