diff --git a/actix_identity/all.html b/actix_identity/all.html index ee46bf0c6..7e6d374ce 100644 --- a/actix_identity/all.html +++ b/actix_identity/all.html @@ -1 +1 @@ -
#[non_exhaustive]
+pub enum GetIdentityError {
+ SessionExpiryError(SessionExpiryError),
+ MissingIdentityError(MissingIdentityError),
+ SessionGetError(SessionGetError),
+ LostIdentityError(LostIdentityError),
+}
Errors that can occur while retrieving an identity.
+The session has expired.
+No identity is found in a session.
+Failed to accessing the session store.
+Identity info was lost after being validated.
+Seeing this error indicates a bug in actix-identity.
+Failure modes of identity operations.
+pub struct LoginError(_);
Error that can occur during login attempts.
+#[non_exhaustive]pub struct LostIdentityError;
The identity information has been lost.
+Seeing this error in user code indicates a bug in actix-identity.
+#[non_exhaustive]pub struct MissingIdentityError;
There is no identity information attached to the current session.
+pub struct SessionExpiryError(_);
Error encountered when working with a session that has expired.
+Identity management for Actix Web.
+Identity management for Actix Web.
actix-identity
can be used to track identity of a user across multiple requests. It is built
on top of HTTP sessions, via actix-session
.
IdentityMiddlewareBuilder::visit_deadline
;
IdentityMiddlewareBuilder::login_deadline
).IdentityMiddleware
.Identity
instance from various actix-web
’s types.IdentityMiddleware
.Identity
instance from various actix-web
’s types.pub struct Identity(_);
A verified user identity. It can be used as a request extractor.
+pub struct Identity(_);
A verified user identity. It can be used as a request extractor.
The lifecycle of a user identity is tied to the lifecycle of the underlying session. If the session is destroyed (e.g. the session expired), the user identity will be forgotten, de-facto forcing a user log out.
@@ -49,7 +49,7 @@ control of the error path. .finish() } }Return the user id associated to the current session.
+Return the user id associated to the current session.
use actix_web::{get, Responder};
use actix_identity::Identity;
@@ -62,7 +62,7 @@ control of the error path.
"Welcome Anonymous!".to_owned()
}
}
Attach a valid user identity to the current session.
+Attach a valid user identity to the current session.
This method should be called after you have successfully authenticated the user. After
login
has been called, the user will be able to access all routes that require a valid
Identity
.
pub trait IdentityExt {
- fn get_identity(&self) -> Result<Identity, Error>;
+ fn get_identity(&self) -> Result<Identity, GetIdentityError>;
}
Helper trait to retrieve an Identity
instance from various actix-web
’s types.
Retrieve the identity attached to the current session, if available.
-Retrieve the identity attached to the current session, if available.
+Access-Control-Request-Headers
has an …","Request header Access-Control-Request-Method
has an …","Builder for CORS middleware.","Errors that can occur when processing CORS guarded …","One or more request headers are not allowed.","Request method is not allowed.","Request header Origin
is required but was not provided.","Request header Access-Control-Request-Method
is required …","Origin is not allowed to make this request.","Allowed origin argument must not be wildcard (*
).","Resets allowed request header list to a state where any …","Resets allowed methods list to all methods.","Resets allowed origin list to a state where any origin is …","Allow private network access.","Add an allowed request header.","Set a list of request header field names which can be used …","Set a list of methods which allowed origins can perform.","Add an origin that is allowed to make requests.","Determinate allowed origins by processing requests which …","Configures whether requests should be pre-emptively …","","","","","","","A restrictive (security paranoid) set of defaults.","Disable support for preflight requests.","Disable Vary
header support.","","Resets exposed response header list to a state where all …","Set a list of headers which are safe to expose to the API …","","","","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self)
.","Calls U::from(self)
.","Set a maximum time (in seconds) for which this CORS …","","A very permissive set of default for quick development. …","","Set to use wildcard origins.","","Allows users to make authenticated requests","","","","","","","","","",""],"i":[4,4,0,0,4,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1,4,1,4,4,4,1,1,1,4,1,1,1,4,4,1,4,1,4,1,1,1,4,1,4,1,4,4,1,4,1,4,1,4,1,4],"f":[0,0,0,0,0,0,0,0,0,0,[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[1,1],[[1,2],1],[1,1],[[1,3],1],[[]],[[]],[[]],[[]],[4,4],[[]],[[],1],[1,1],[1,1],[4,5],[1,1],[1,1],[[1,6],7],[[4,6],7],[[4,6],7],[[]],[[]],[[]],[[]],[[1,[10,[[9,[8]]]]],1],[1],[[],1],[11],[1,1],[4,12],[1,1],[[]],[[],13],[[],14],[[],14],[[],14],[[],14],[[],15],[[],15],[[]],[[]]],"p":[[3,"Cors"],[15,"str"],[15,"bool"],[4,"CorsError"],[3,"HttpResponse"],[3,"Formatter"],[6,"Result"],[15,"usize"],[4,"Option"],[8,"Into"],[3,"Demand"],[3,"StatusCode"],[3,"String"],[4,"Result"],[3,"TypeId"]]},\
-"actix_identity":{"doc":"Identity management for Actix Web.","t":[3,8,3,11,11,11,11,11,11,11,0,11,11,11,11,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,3,4,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["Identity","IdentityExt","IdentityMiddleware","borrow","borrow","borrow_mut","borrow_mut","builder","clone","clone_into","config","default","from","from","from_request","get_identity","id","into","into","login","logout","new_transform","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","vzip","vzip","DeleteIdentityKeys","IdentityMiddlewareBuilder","LogoutBehaviour","PurgeSession","borrow","borrow","borrow_mut","borrow_mut","build","clone","clone","clone_into","clone_into","fmt","fmt","from","from","into","into","login_deadline","logout_behaviour","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","visit_deadline","vzip","vzip"],"q":["actix_identity","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","actix_identity::config","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["A verified user identity. It can be used as a request …","Helper trait to retrieve an Identity
instance from various …","Identity management middleware.","","","","","A fluent API to configure IdentityMiddleware
.","","","Configuration options to tune the behaviour of …","","Returns the argument unchanged.","Returns the argument unchanged.","","Retrieve the identity attached to the current session, if …","Return the user id associated to the current session.","Calls U::from(self)
.","Calls U::from(self)
.","Attach a valid user identity to the current session.","Remove the user identity from the current session.","","","","","","","","","","","When Identity::logout
is called, remove the identity …","A fluent builder to construct an IdentityMiddleware
…","LogoutBehaviour
controls what actions are going to be …","When Identity::logout
is called, purge the current session.","","","","","Finalises the builder and returns an IdentityMiddleware
…","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self)
.","Calls U::from(self)
.","Automatically logs out users after a certain amount of …","Determines how Identity::logout
affects the current …","","","","","","","","","Automatically logs out users after a certain amount of …","",""],"i":[0,0,0,5,2,5,2,2,2,2,0,2,5,2,5,16,5,5,2,5,5,2,2,5,2,5,2,5,2,5,2,11,0,0,11,11,1,11,1,1,11,1,11,1,11,1,11,1,11,1,1,1,11,1,11,1,11,1,11,1,1,11,1],"f":[0,0,0,[[]],[[]],[[]],[[]],[[],1],[2,2],[[]],0,[[],2],[[]],[[]],[[3,4]],[[],[[7,[5,6]]]],[5,[[7,[8,6]]]],[[]],[[]],[[9,8],[[7,[5,6]]]],[5],[2],[[]],[[],7],[[],7],[[],7],[[],7],[[],10],[[],10],[[]],[[]],0,0,0,0,[[]],[[]],[[]],[[]],[1,2],[11,11],[1,1],[[]],[[]],[[11,12],13],[[1,12],13],[[]],[[]],[[]],[[]],[[1,[15,[14]]],1],[[1,11],1],[[]],[[]],[[],7],[[],7],[[],7],[[],7],[[],10],[[],10],[[1,[15,[14]]],1],[[]],[[]]],"p":[[3,"IdentityMiddlewareBuilder"],[3,"IdentityMiddleware"],[3,"HttpRequest"],[4,"Payload"],[3,"Identity"],[3,"Error"],[4,"Result"],[3,"String"],[3,"Extensions"],[3,"TypeId"],[4,"LogoutBehaviour"],[3,"Formatter"],[6,"Result"],[3,"Duration"],[4,"Option"],[8,"IdentityExt"]]},\
+"actix_identity":{"doc":"Identity management for Actix Web.","t":[3,8,3,11,11,11,11,11,11,11,0,11,0,11,11,11,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,13,3,4,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,4,3,3,13,3,13,3,13,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["Identity","IdentityExt","IdentityMiddleware","borrow","borrow","borrow_mut","borrow_mut","builder","clone","clone_into","config","default","error","from","from","from_request","get_identity","id","into","into","login","logout","new_transform","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","vzip","vzip","DeleteIdentityKeys","IdentityMiddlewareBuilder","LogoutBehaviour","PurgeSession","borrow","borrow","borrow_mut","borrow_mut","build","clone","clone","clone_into","clone_into","fmt","fmt","from","from","into","into","login_deadline","logout_behaviour","to_owned","to_owned","try_from","try_from","try_into","try_into","type_id","type_id","visit_deadline","vzip","vzip","GetIdentityError","LoginError","LostIdentityError","LostIdentityError","MissingIdentityError","MissingIdentityError","SessionExpiryError","SessionExpiryError","SessionGetError","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","fmt","fmt","fmt","fmt","fmt","fmt","fmt","fmt","fmt","fmt","from","from","from","from","from","from","from","from","from","from","into","into","into","into","into","provide","provide","provide","provide","provide","source","source","source","source","status_code","status_code","to_string","to_string","to_string","to_string","to_string","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","vzip","vzip","vzip","vzip","vzip"],"q":["actix_identity","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","actix_identity::config","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","actix_identity::error","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["A verified user identity. It can be used as a request …","Helper trait to retrieve an Identity
instance from various …","Identity management middleware.","","","","","A fluent API to configure IdentityMiddleware
.","","","Configuration options to tune the behaviour of …","","Failure modes of identity operations.","Returns the argument unchanged.","Returns the argument unchanged.","","Retrieve the identity attached to the current session, if …","Return the user id associated to the current session.","Calls U::from(self)
.","Calls U::from(self)
.","Attach a valid user identity to the current session.","Remove the user identity from the current session.","","","","","","","","","","","When Identity::logout
is called, remove the identity …","A fluent builder to construct an IdentityMiddleware
…","LogoutBehaviour
controls what actions are going to be …","When Identity::logout
is called, purge the current session.","","","","","Finalises the builder and returns an IdentityMiddleware
…","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self)
.","Calls U::from(self)
.","Automatically logs out users after a certain amount of …","Determines how Identity::logout
affects the current …","","","","","","","","","Automatically logs out users after a certain amount of …","","","Errors that can occur while retrieving an identity.","Error that can occur during login attempts.","The identity information has been lost.","Identity info was lost after being validated.","There is no identity information attached to the current …","No identity is found in a session.","Error encountered when working with a session that has …","The session has expired.","Failed to accessing the session store.","","","","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","Returns the argument unchanged.","","","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,0,0,5,2,5,2,2,2,2,0,2,0,5,2,5,26,5,5,2,5,5,2,2,5,2,5,2,5,2,5,2,12,0,0,12,12,1,12,1,1,12,1,12,1,12,1,12,1,12,1,1,1,12,1,12,1,12,1,12,1,1,12,1,0,0,0,6,0,6,0,6,6,10,17,18,19,6,10,17,18,19,6,10,10,17,17,18,18,19,19,6,6,10,10,17,18,19,6,6,6,6,6,10,17,18,19,6,10,17,18,19,6,10,18,19,6,10,6,10,17,18,19,6,10,17,18,19,6,10,17,18,19,6,10,17,18,19,6,10,17,18,19,6],"f":[0,0,0,[[]],[[]],[[]],[[]],[[],1],[2,2],[[]],0,[[],2],0,[[]],[[]],[[3,4]],[[],[[7,[5,6]]]],[5,[[7,[8,6]]]],[[]],[[]],[[9,8],[[7,[5,10]]]],[5],[2],[[]],[[],7],[[],7],[[],7],[[],7],[[],11],[[],11],[[]],[[]],0,0,0,0,[[]],[[]],[[]],[[]],[1,2],[12,12],[1,1],[[]],[[]],[[12,13],14],[[1,13],14],[[]],[[]],[[]],[[]],[[1,[16,[15]]],1],[[1,12],1],[[]],[[]],[[],7],[[],7],[[],7],[[],7],[[],11],[[],11],[[1,[16,[15]]],1],[[]],[[]],0,0,0,0,0,0,0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[10,13],14],[[10,13],14],[[17,13],14],[[17,13],14],[[18,13],14],[[18,13],14],[[19,13],14],[[19,13],14],[[6,13],14],[[6,13],14],[20,10],[[]],[[]],[[]],[[]],[18,6],[21,6],[[]],[19,6],[22,6],[[]],[[]],[[]],[[]],[[]],[23],[23],[23],[23],[23],[10,[[16,[24]]]],[18,[[16,[24]]]],[19,[[16,[24]]]],[6,[[16,[24]]]],[10,25],[6,25],[[],8],[[],8],[[],8],[[],8],[[],8],[[],7],[[],7],[[],7],[[],7],[[],7],[[],7],[[],7],[[],7],[[],7],[[],7],[[],11],[[],11],[[],11],[[],11],[[],11],[[]],[[]],[[]],[[]],[[]]],"p":[[3,"IdentityMiddlewareBuilder"],[3,"IdentityMiddleware"],[3,"HttpRequest"],[4,"Payload"],[3,"Identity"],[4,"GetIdentityError"],[4,"Result"],[3,"String"],[3,"Extensions"],[3,"LoginError"],[3,"TypeId"],[4,"LogoutBehaviour"],[3,"Formatter"],[6,"Result"],[3,"Duration"],[4,"Option"],[3,"SessionExpiryError"],[3,"LostIdentityError"],[3,"MissingIdentityError"],[3,"SessionInsertError"],[3,"ComponentRange"],[3,"SessionGetError"],[3,"Demand"],[8,"Error"],[3,"StatusCode"],[8,"IdentityExt"]]},\
"actix_limitation":{"doc":"Rate limiter using a fixed window counter for arbitrary …","t":[3,13,17,17,17,17,4,13,3,13,3,3,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["Builder","Client","DEFAULT_COOKIE_NAME","DEFAULT_PERIOD_SECS","DEFAULT_REQUEST_LIMIT","DEFAULT_SESSION_KEY","Error","LimitExceeded","Limiter","Other","RateLimiter","Status","Time","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","build","builder","clone","clone","clone_into","clone_into","cookie_name","count","default","fmt","fmt","fmt","fmt","fmt","fmt","from","from","from","from","from","from","from","into","into","into","into","into","key_by","limit","limit","new_transform","period","provide","remaining","reset_epoch_utc","session_key","source","to_owned","to_owned","to_string","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","vzip","vzip","vzip","vzip","vzip"],"q":["actix_limitation","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["Rate limiter builder.","Redis client failed to connect or run a query.","Default cookie name.","Default period (in seconds).","Default request limit.","Default session key.","Failure modes of the rate limiter.","Limit is exceeded for a key.","Rate limiter.","Generic error.","Rate limit middleware.","A report for a given key containing the limit status.","Time conversion failed.","","","","","","","","","","","Finalizes and returns a Limiter
.","Construct rate limiter builder with defaults.","","","","","Sets name of cookie to be sent.","Consumes one rate limit unit, returning the status.","","","","","","","","Returns the argument unchanged.","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Sets rate limit key derivation function.","Set upper limit.","Returns the maximum number of requests allowed in the …","","Set limit window/period.","","Returns how many requests are left in the current period.","Returns a UNIX timestamp in UTC approximately when the …","Sets session key to be used in backend.","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[0,3,0,0,0,0,0,3,0,3,0,0,3,1,3,10,7,2,1,3,10,7,2,1,2,7,2,7,2,1,2,10,1,3,3,10,7,2,1,3,3,3,10,7,2,1,3,10,7,2,1,1,7,10,1,3,7,7,1,3,7,2,3,1,3,10,7,2,1,3,10,7,2,1,3,10,7,2,1,3,10,7,2],"f":[0,0,0,0,0,0,0,0,0,0,0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[1,[[4,[2,3]]]],[[[6,[5]]],1],[7,7],[2,2],[[]],[[]],[[1,[6,[[9,[8]]]]],1],[[2,[6,[5]]],[[4,[7,3]]]],[[],10],[[1,11],12],[[3,11],12],[[3,11],12],[[10,11],12],[[7,11],12],[[2,11],12],[[]],[13,3],[14,3],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[1,1],[[1,15],1],[7,15],[10],[[1,16],1],[17],[7,15],[7,15],[[1,[6,[[9,[8]]]]],1],[3,[[19,[18]]]],[[]],[[]],[[],5],[[],4],[[],4],[[],4],[[],4],[[],4],[[],4],[[],4],[[],4],[[],4],[[],4],[[],20],[[],20],[[],20],[[],20],[[],20],[[]],[[]],[[]],[[]],[[]]],"p":[[3,"Builder"],[3,"Limiter"],[4,"Error"],[4,"Result"],[3,"String"],[8,"Into"],[3,"Status"],[15,"str"],[4,"Cow"],[3,"RateLimiter"],[3,"Formatter"],[6,"Result"],[3,"RedisError"],[3,"ComponentRange"],[15,"usize"],[3,"Duration"],[3,"Demand"],[8,"Error"],[4,"Option"],[3,"TypeId"]]},\
"actix_protobuf":{"doc":"Protobuf payload extractor for Actix Web.","t":[13,13,13,13,3,3,3,4,8,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["ContentType","Deserialize","Overflow","Payload","ProtoBuf","ProtoBufConfig","ProtoBufMessage","ProtoBufPayloadError","ProtoBufResponseBuilder","Serialize","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","default","deref","deref_mut","error_response","fmt","fmt","fmt","fmt","from","from","from","from","from","from","from_request","into","into","into","into","into_future","limit","limit","new","poll","protobuf","resource_path","respond_to","to_string","to_string","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_poll","type_id","type_id","type_id","type_id","vzip","vzip","vzip","vzip"],"q":["actix_protobuf","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["Content type error","Deserialize error","Payload size is bigger than 256k","Payload error","","","","","","Serialize error","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","Returns the argument unchanged.","","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","","Change max size of payload. By default max size is 256Kb","Change max size of payload. By default max size is 256Kb","Create ProtoBufMessage
for request.","","","","","","","","","","","","","","","","","","","","","","",""],"i":[4,4,4,4,0,0,0,0,0,4,3,1,14,4,3,1,14,4,1,3,3,4,3,3,4,4,3,1,14,4,4,4,3,3,1,14,4,14,1,14,14,14,23,3,3,3,4,3,1,14,4,3,1,14,4,14,3,1,14,4,3,1,14,4],"f":[0,0,0,0,0,0,0,0,0,0,[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[],1],[[[3,[2]]]],[[[3,[2]]]],[4,5],[[3,6],7],[[3,6],7],[[4,6],7],[[4,6],7],[[]],[[]],[[]],[8,4],[9,4],[[]],[[10,11]],[[]],[[]],[[]],[[]],[[]],[[1,12],1],[[[14,[[0,[2,13]]]],12],[[14,[[0,[2,13]]]]]],[[10,11],[[14,[[0,[2,13]]]]]],[[[15,[[14,[[0,[2,13]]]]]],16],17],[2,[[19,[5,18]]]],[[],20],[[[3,[[0,[2,13]]]],10],5],[[],21],[[],21],[[],19],[[],19],[[],19],[[],19],[[],19],[[],19],[[],19],[[],19],[[15,16],17],[[],22],[[],22],[[],22],[[],22],[[]],[[]],[[]],[[]]],"p":[[3,"ProtoBufConfig"],[8,"Message"],[3,"ProtoBuf"],[4,"ProtoBufPayloadError"],[3,"HttpResponse"],[3,"Formatter"],[6,"Result"],[3,"DecodeError"],[4,"PayloadError"],[3,"HttpRequest"],[4,"Payload"],[15,"usize"],[8,"Default"],[3,"ProtoBufMessage"],[3,"Pin"],[3,"Context"],[4,"Poll"],[3,"Error"],[4,"Result"],[3,"Path"],[3,"String"],[3,"TypeId"],[8,"ProtoBufResponseBuilder"]]},\
"actix_redis":{"doc":"Redis integration for actix
.","t":[13,13,3,13,13,4,13,13,13,13,13,13,13,3,13,13,4,4,13,13,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,14,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["Array","BulkString","Command","Connection","Disconnected","Error","Error","IO","Integer","Internal","Nil","NotConnected","Redis","RedisActor","Remote","Resp","RespError","RespValue","SimpleString","Unexpected","append","borrow","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","borrow_mut","clone","clone_into","eq","equivalent","error","fmt","fmt","fmt","fmt","fmt","fmt","from","from","from","from","from","from","from","from","from","from","from","from","from","from","from","from_resp_int","handle","handle","into","into","into","into","into","provide","provide","push","resp_array","restarting","source","source","start","started","to_owned","to_string","to_string","try_from","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","type_id","vzip","vzip","vzip","vzip","vzip"],"q":["actix_redis","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""],"d":["Zero, one or more other RespValue
s.","A bulk string. In Redis terminology a string is a …","Command for sending data to Redis.","Error creating a connection, or an error with a connection …","Cancel all waiters when connection is dropped.","General purpose actix-redis
error.","An error from the Redis server","An IO error occurred","Redis documentation defines an integer as being a signed …","A non-specific internal error that prevented an operation …","","Receiving message during reconnecting.","","Redis communication actor.","A remote error","A RESP parsing/serialising error occurred","","A single RESP value, this owns the data that is read/to-be …","","An unexpected error. In this context “unexpected” …","Convenience function for building dynamic Redis commands …","","","","","","","","","","","","","","","","","","","","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","Returns the argument unchanged.","","","","","","","","","Returns the argument unchanged.","","","","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","Calls U::from(self)
.","","","Push item to Resp array","Macro to create a RESP array, useful for preparing …","","","","Start new Supervisor
with RedisActor
.","","","","","","","","","","","","","","","","","","","","","","","",""],"i":[1,1,0,13,10,0,1,13,1,13,1,10,10,0,13,13,0,0,1,13,1,4,7,10,1,13,4,7,10,1,13,1,1,1,1,4,7,10,10,1,13,13,4,7,10,10,1,1,1,1,1,1,1,1,13,13,13,1,4,4,4,7,10,1,13,10,13,1,0,4,10,13,4,4,1,10,13,4,7,10,1,13,4,7,10,1,13,4,7,10,1,13,4,7,10,1,13],"f":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,[[1,2],1],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[[]],[1,1],[[]],[[1,1],3],[[],3],[[4,5],6],[[7,8],9],[[10,8],9],[[10,8],9],[[1,8],[[12,[11]]]],[[13,8],[[12,[11]]]],[[13,8],[[12,[11]]]],[[]],[[]],[[]],[13,10],[[[16,[14,15]]],1],[[]],[[],1],[17,1],[18,1],[[[20,[19]]],1],[18,1],[19,1],[5,13],[21,13],[[]],[1,[[12,[1,13]]]],[[4,[12,[1,13]]]],[[4,7]],[[]],[[]],[[]],[[]],[[]],[22],[22],[1],0,[4],[10,[[24,[23]]]],[13,[[24,[23]]]],[[[25,[18]]],[[26,[4]]]],[[4,27]],[[]],[[],18],[[],18],[[],12],[[],12],[[],12],[[],12],[[],12],[[],12],[[],12],[[],12],[[],12],[[],12],[[],28],[[],28],[[],28],[[],28],[[],28],[[]],[[]],[[]],[[]],[[]]],"p":[[4,"RespValue"],[8,"IntoIterator"],[15,"bool"],[3,"RedisActor"],[3,"Error"],[4,"Running"],[3,"Command"],[3,"Formatter"],[6,"Result"],[4,"Error"],[3,"Error"],[4,"Result"],[4,"RespError"],[15,"u8"],[3,"Global"],[3,"Vec"],[15,"usize"],[3,"String"],[15,"str"],[3,"Arc"],[3,"TrySendError"],[3,"Demand"],[8,"Error"],[4,"Option"],[8,"Into"],[3,"Addr"],[3,"Context"],[3,"TypeId"]]},\
diff --git a/settings.html b/settings.html
index 2eb99cdc7..4cd5f80a0 100644
--- a/settings.html
+++ b/settings.html
@@ -1 +1,2 @@
-1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +
//! Failure modes of identity operations.
+
+use std::fmt;
+
+use actix_session::{SessionGetError, SessionInsertError};
+use actix_web::{cookie::time::error::ComponentRange, http::StatusCode, ResponseError};
+
+/// Error that can occur during login attempts.
+#[derive(Debug)]
+pub struct LoginError(SessionInsertError);
+
+impl fmt::Display for LoginError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", self.0)
+ }
+}
+
+impl std::error::Error for LoginError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ Some(&self.0)
+ }
+}
+
+impl ResponseError for LoginError {
+ fn status_code(&self) -> StatusCode {
+ StatusCode::UNAUTHORIZED
+ }
+}
+
+impl From<SessionInsertError> for LoginError {
+ fn from(error: SessionInsertError) -> Self {
+ Self(error)
+ }
+}
+
+/// Error encountered when working with a session that has expired.
+#[derive(Debug)]
+pub struct SessionExpiryError(ComponentRange);
+
+impl fmt::Display for SessionExpiryError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str("The given session has expired and is no longer valid")
+ }
+}
+
+impl std::error::Error for SessionExpiryError {}
+
+/// The identity information has been lost.
+///
+/// Seeing this error in user code indicates a bug in actix-identity.
+#[derive(Debug)]
+#[non_exhaustive]
+pub struct LostIdentityError;
+
+impl fmt::Display for LostIdentityError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str(
+ "The identity information in the current session has disappeared \
+ after having been successfully validated. This is likely to be a bug.",
+ )
+ }
+}
+
+impl std::error::Error for LostIdentityError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ Some(self)
+ }
+}
+
+/// There is no identity information attached to the current session.
+#[derive(Debug)]
+#[non_exhaustive]
+pub struct MissingIdentityError;
+
+impl fmt::Display for MissingIdentityError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str("There is no identity information attached to the current session.")
+ }
+}
+
+impl std::error::Error for MissingIdentityError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ Some(self)
+ }
+}
+
+/// Errors that can occur while retrieving an identity.
+#[derive(Debug)]
+#[non_exhaustive]
+pub enum GetIdentityError {
+ /// The session has expired.
+ SessionExpiryError(SessionExpiryError),
+
+ /// No identity is found in a session.
+ MissingIdentityError(MissingIdentityError),
+
+ /// Failed to accessing the session store.
+ SessionGetError(SessionGetError),
+
+ /// Identity info was lost after being validated.
+ ///
+ /// Seeing this error indicates a bug in actix-identity.
+ LostIdentityError(LostIdentityError),
+}
+
+impl fmt::Display for GetIdentityError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::SessionExpiryError(err) => write!(f, "{err}"),
+ Self::MissingIdentityError(err) => write!(f, "{err}"),
+ Self::SessionGetError(err) => write!(f, "{err}"),
+ Self::LostIdentityError(err) => write!(f, "{err}"),
+ }
+ }
+}
+
+impl std::error::Error for GetIdentityError {
+ fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ match self {
+ Self::SessionExpiryError(err) => Some(err),
+ Self::MissingIdentityError(err) => Some(err),
+ Self::SessionGetError(err) => Some(err),
+ Self::LostIdentityError(err) => Some(err),
+ }
+ }
+}
+
+impl ResponseError for GetIdentityError {
+ fn status_code(&self) -> StatusCode {
+ StatusCode::UNAUTHORIZED
+ }
+}
+
+impl From<LostIdentityError> for GetIdentityError {
+ fn from(error: LostIdentityError) -> Self {
+ Self::LostIdentityError(error)
+ }
+}
+
+impl From<MissingIdentityError> for GetIdentityError {
+ fn from(error: MissingIdentityError) -> Self {
+ Self::MissingIdentityError(error)
+ }
+}
+
+impl From<ComponentRange> for GetIdentityError {
+ fn from(error: ComponentRange) -> Self {
+ Self::SessionExpiryError(SessionExpiryError(error))
+ }
+}
+
+impl From<SessionGetError> for GetIdentityError {
+ fn from(source: SessionGetError) -> Self {
+ Self::SessionGetError(source)
+ }
+}
+
use actix_web::{dev::ServiceRequest, guard::GuardContext, HttpMessage, HttpRequest};
-use crate::Identity;
+use crate::{error::GetIdentityError, Identity};
/// Helper trait to retrieve an [`Identity`] instance from various `actix-web`'s types.
pub trait IdentityExt {
/// Retrieve the identity attached to the current session, if available.
- fn get_identity(&self) -> Result<Identity, anyhow::Error>;
+
fn get_identity(&self) -> Result<Identity, GetIdentityError>;
}
impl IdentityExt for HttpRequest {
- fn get_identity(&self) -> Result<Identity, anyhow::Error> {
+ fn get_identity(&self) -> Result<Identity, GetIdentityError> {
Identity::extract(&self.extensions())
}
}
impl IdentityExt for ServiceRequest {
- fn get_identity(&self) -> Result<Identity, anyhow::Error> {
+ fn get_identity(&self) -> Result<Identity, GetIdentityError> {
Identity::extract(&self.extensions())
}
}
impl<'a> IdentityExt for GuardContext<'a> {
- fn get_identity(&self) -> Result<Identity, anyhow::Error> {
+ fn get_identity(&self) -> Result<Identity, GetIdentityError> {
Identity::extract(&self.req_data())
}
}
diff --git a/src/actix_identity/lib.rs.html b/src/actix_identity/lib.rs.html
index 2d54d5583..823f65b2c 100644
--- a/src/actix_identity/lib.rs.html
+++ b/src/actix_identity/lib.rs.html
@@ -96,6 +96,7 @@
96
97
98
+99
//! Identity management for Actix Web.
//!
//! `actix-identity` can be used to track identity of a user across multiple requests. It is built
@@ -189,6 +190,7 @@
#![warn(future_incompatible)]
pub mod config;
+pub mod error;
mod identity;
mod identity_ext;
mod middleware;