File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ use crate :: error:: VssError ;
2+ use async_trait:: async_trait;
3+ use std:: collections:: HashMap ;
4+ use std:: string:: ToString ;
5+
6+ #[ derive( Debug , Clone ) ]
7+ pub struct AuthResponse {
8+ pub user_token : String ,
9+ }
10+
11+ // Interface for authorizer that is run before every request.
12+ #[ async_trait]
13+ pub trait Authorizer : Send + Sync {
14+ async fn verify ( & self , headers_map : & HashMap < String , String > )
15+ -> Result < AuthResponse , VssError > ;
16+ }
17+
18+ // A no-operation authorizer, that lets any user-request go through.
19+ pub struct NoopAuthorizer { }
20+
21+ const UNAUTHENTICATED_USER : & str = "unauth-user" ;
22+
23+ #[ async_trait]
24+ impl Authorizer for NoopAuthorizer {
25+ async fn verify (
26+ & self , _headers_map : & HashMap < String , String > ,
27+ ) -> Result < AuthResponse , VssError > {
28+ Ok ( AuthResponse { user_token : UNAUTHENTICATED_USER . to_string ( ) . clone ( ) } )
29+ }
30+ }
Original file line number Diff line number Diff line change 1+ pub mod auth;
12pub mod error;
23pub mod kv_store;
34pub mod types;
You can’t perform that action at this time.
0 commit comments