mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-13 08:22:55 +00:00
## Summary of changes A bunch of no-op changes. --------- Co-authored-by: Vlad Lazar <vlad@neon.tech>
22 lines
682 B
Rust
22 lines
682 B
Rust
use utils::auth::{AuthError, Claims, Scope};
|
|
use uuid::Uuid;
|
|
|
|
pub fn check_permission(claims: &Claims, required_scope: Scope) -> Result<(), AuthError> {
|
|
if claims.scope != required_scope {
|
|
return Err(AuthError("Scope mismatch. Permission denied".into()));
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub fn check_endpoint_permission(claims: &Claims, endpoint_id: Uuid) -> Result<(), AuthError> {
|
|
if claims.scope != Scope::TenantEndpoint {
|
|
return Err(AuthError("Scope mismatch. Permission denied".into()));
|
|
}
|
|
if claims.endpoint_id != Some(endpoint_id) {
|
|
return Err(AuthError("Endpoint id mismatch. Permission denied".into()));
|
|
}
|
|
Ok(())
|
|
}
|