pub struct AuthenticatedPeer {
pub peer_id: String,
pub role: TokenRole,
pub parties: Vec<PartyRef>,
pub version: VersionNumber,
}server only.Expand description
The party a request was authenticated as.
Fields§
§peer_id: StringA stable identifier for the platform, for logging and for looking up its state.
role: TokenRoleWhich handshake token this is, which decides what it may address.
parties: Vec<PartyRef>The parties this platform speaks for, from the roles of its credentials.
version: VersionNumberThe OCPI version the connection was registered with.
Implementations§
Source§impl AuthenticatedPeer
impl AuthenticatedPeer
Sourcepub fn owns(&self, party: &PartyRef) -> bool
pub fn owns(&self, party: &PartyRef) -> bool
Whether this platform speaks for party.
This is what decides whether a client-owned-object URL is theirs to write to.
Sourcepub fn check_scope(&self, module: &ModuleId) -> Result<(), OcpiError>
pub fn check_scope(&self, module: &ModuleId) -> Result<(), OcpiError>
Checks that this token may address module.
When a server receives a request with a valid
CREDENTIALS_TOKEN_A, on another module thancredentialsorversions, the server SHALL respond with an HTTP401 - Unauthorizedstatus code.
§Errors
Returns OcpiError::TokenAOutOfScope, which maps to HTTP 401.
Spec: 2.3.0 §transport_and_format_authorization_header
Sourcepub fn check_ownership(&self, owner: &PartyRef) -> Result<(), OcpiError>
pub fn check_ownership(&self, owner: &PartyRef) -> Result<(), OcpiError>
Checks that this platform may write to a client-owned object under owner.
When a client tries to access an object with a URL that has a different
country_codeand/orparty_idthan one of the CredentialsRoles given during the credentials handshake, it is allowed to respond with an HTTP404status code, this way blocking client access to objects that do not belong to them.
A 404 rather than a 403 is deliberate: it does not reveal whether the object exists.
§Errors
Returns OcpiError::NotFound, which maps to HTTP 404.
Spec: 2.3.0 §transport_and_format_errors
Trait Implementations§
Source§impl Clone for AuthenticatedPeer
impl Clone for AuthenticatedPeer
Source§fn clone(&self) -> AuthenticatedPeer
fn clone(&self) -> AuthenticatedPeer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more