mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
+1








14fba21e57
Signed-off-by: tlongwell-block <109685178+tlongwell-block@users.noreply.github.com> Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Signed-off-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub17jjz49l9jjmhhk7cac63j8yt9z555n9cw8vk7v5jz4vzw4ppld5qgj57cc <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Eva <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Mari <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Sami <f4a42a97e594b77bdbd8ee35191c8b28a94a4cb871d96f32921558275421fb68@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Max <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Quinn <96f056ad5f2305c8ddf637dc65d048aa4c12d7daeb8867690e34fca46b0ef64c@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Dawn <c6237ef84fa537c78dcee78efd2d4e59f728859c7f194da42ac51ededfa0be05@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Co-authored-by: Sami <sami@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1t2tgm7d8f995uqvmnm8h88sg3wnpp9a5xysjf6dg3tjmgt3ltulqdp8ehr <5a968df9a7494b4e019b9ecf739e088ba61097b4312124e9a88ae5b42e3f5f3e@sprout-oss.stage.blox.sqprod.co>
60 lines
2.4 KiB
Rust
60 lines
2.4 KiB
Rust
//! Error types for buzz-auth.
|
|
|
|
/// All errors that can occur during authentication and authorization.
|
|
///
|
|
/// Variants are designed to be safe to return to callers without leaking
|
|
/// internal implementation details. Do **not** include raw token values,
|
|
/// database contents, or stack traces in error messages.
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub enum AuthError {
|
|
/// The NIP-42 event signature is invalid or the event is structurally malformed.
|
|
#[error("invalid signature or malformed auth event")]
|
|
InvalidSignature,
|
|
|
|
/// The `challenge` tag in the AUTH event does not match the relay's issued challenge.
|
|
#[error("challenge mismatch")]
|
|
ChallengeMismatch,
|
|
|
|
/// The `relay` tag in the AUTH event does not match this relay's URL.
|
|
#[error("relay url mismatch")]
|
|
RelayUrlMismatch,
|
|
|
|
/// The AUTH event's `created_at` timestamp is more than ±60 seconds from now.
|
|
#[error("auth event timestamp outside ±60s window")]
|
|
EventExpired,
|
|
|
|
/// NIP-98 HTTP Auth event (kind:27235) failed verification.
|
|
///
|
|
/// The inner string describes the specific failure (signature, timestamp, URL, etc.)
|
|
/// and is safe to include in server logs. Do **not** forward raw event content to clients.
|
|
#[error("NIP-98 HTTP Auth verification failed: {0}")]
|
|
Nip98Invalid(String),
|
|
|
|
/// A NIP-98 event with the same id has already been observed within the
|
|
/// replay-prevention window. The event itself was structurally valid; the
|
|
/// rejection is on freshness, not validity.
|
|
#[error("NIP-98 replay: event id already seen within window")]
|
|
Nip98Replay,
|
|
|
|
/// The pubkey in the auth event does not match the expected identity.
|
|
#[error("pubkey mismatch: event pubkey does not match authenticated identity")]
|
|
PubkeyMismatch,
|
|
|
|
/// The authenticated context does not have the required scope for this operation.
|
|
#[error("insufficient scope: required {required}, have {have:?}")]
|
|
InsufficientScope {
|
|
/// The scope that was required.
|
|
required: String,
|
|
/// The scopes the caller actually holds.
|
|
have: Vec<String>,
|
|
},
|
|
|
|
/// The authenticated user is not a member of the requested channel.
|
|
#[error("channel access denied")]
|
|
ChannelAccessDenied,
|
|
|
|
/// An unexpected internal error occurred (e.g. a `spawn_blocking` panic).
|
|
#[error("internal auth error: {0}")]
|
|
Internal(String),
|
|
}
|