Auth types and OAuth 2.0 / OpenID Connect (M3, M4)

- Digest (MD5/SHA-256, -sess, auth/auth-int) with challenge round trip,
  self-signed JWT, AWS SigV4 (header and presigned), OAuth 1.0a,
  PKCS#12 client certificates; every type explains its computation
- OAuth: discovery, authorization code with PKCE over a loopback
  listener (knock:// and paste-by-hand as alternatives), client
  credentials, device code, password; tokens per issuer/client/scopes/
  environment in the keyring with auto refresh and one retry after 401
- Flow log with step timeline, raw exchanges, cURL export, plain-language
  diagnosis of provider errors, ID token validation incl. JWKS signature
- OAuth panel with redirect URI on top, token inspector, refresh,
  userinfo, introspection, revocation, logout and connection test
This commit is contained in:
2026-11-27 16:53:32 +01:00
parent f6484f4dc8
commit a469697af7
29 changed files with 5177 additions and 58 deletions
+7 -7
View File
@@ -309,7 +309,7 @@ pub struct ScopeArgs {
pub env: Option<String>,
}
pub fn build_context(state: &AppState, a: &ScopeArgs) -> anyhow::Result<RequestContext> {
pub fn build_context(app: &AppHandle, state: &AppState, a: &ScopeArgs) -> anyhow::Result<RequestContext> {
let globals = db::globals_load(&state.db.lock().unwrap()).unwrap_or_default();
match &a.col {
Some(col) => {
@@ -325,7 +325,7 @@ pub fn build_context(state: &AppState, a: &ScopeArgs) -> anyhow::Result<RequestC
runtime: state.runtime_vars(col),
globals,
secrets: Arc::new(store),
oauth: Some(Arc::new(crate::oauth::TokenLookup::new(state, &c, a.env.as_deref()))),
oauth: Some(Arc::new(crate::oauth::TokenLookup::new(app, &c, a.env.as_deref()))),
})
}
None => {
@@ -352,8 +352,8 @@ pub struct VarsView {
}
#[tauri::command]
pub fn vars_list(state: State<'_, AppState>, args: ScopeArgs) -> Res<VarsView> {
let ctx = build_context(&state, &args).map_err(errx)?;
pub fn vars_list(app: AppHandle, state: State<'_, AppState>, args: ScopeArgs) -> Res<VarsView> {
let ctx = build_context(&app, &state, &args).map_err(errx)?;
Ok(VarsView {
vars: ctx.resolver.names(),
dynamic: DYNAMIC_VARS.iter().map(|(a, b)| (a.to_string(), b.to_string())).collect(),
@@ -410,7 +410,7 @@ pub struct SendResult {
#[tauri::command]
pub async fn request_send(app: AppHandle, args: SendArgs) -> Res<SendResult> {
let state = app.state::<AppState>();
let ctx = build_context(&state, &args.scope).map_err(errx)?;
let ctx = build_context(&app, &state, &args.scope).map_err(errx)?;
let engine = state.engine.clone();
let req = args.scope.request.clone();
let host = crate::oauth::Host::new(app.clone(), args.scope.col.clone(), args.scope.env.clone());
@@ -522,7 +522,7 @@ pub struct Preview {
#[tauri::command]
pub async fn request_preview(app: AppHandle, args: ScopeArgs) -> Res<Preview> {
let state = app.state::<AppState>();
let ctx = build_context(&state, &args).map_err(errx)?;
let ctx = build_context(&app, &state, &args).map_err(errx)?;
let mut p = match knock_core::prepare::prepare(&args.request, &ctx) {
Ok(p) => p,
Err(e) => {
@@ -530,7 +530,7 @@ pub async fn request_preview(app: AppHandle, args: ScopeArgs) -> Res<Preview> {
}
};
let host = crate::oauth::Host::preview(app.clone(), args.col.clone(), args.env.clone());
let auth = knock_core::auth::apply(&ctx.auth, &mut p, &ctx.resolver, Some(&host), false).await;
let auth = knock_core::auth::apply(&ctx.auth, &mut p, &ctx.resolver, Some(&host), false, &ctx.root).await;
Ok(Preview {
request: Some(knock_core::run::SentRequest {
method: p.method.clone(),