pub struct Authorization {
    resources: Vec<String>,
    issued_at: String,
    expiration_time: Option<String>,
    not_before: Option<String>,
    pub address: H160,
}
Expand description

An authorization is issued to a particular address based on the fields included in the AuthRequest message. With the Resources vecotr, the API can have even more granular control over the access control of a particular address. All the fields are populated by a AuthRequest.message, from the fields with the same name.

Fields

resources: Vec<String>issued_at: Stringexpiration_time: Option<String>not_before: Option<String>address: H160

Implementations

Parses a worker::Request for an authentication token, serialized as a JSON object in the body of the request. The authentication token is used to retrieve the related Authorization and verify that the token-holder can access the particular resource.

Get an authorizsation from the Cloudflare KV store, based on a token. The token is retrived from the request with parse_request and used as the key to find the Authorization struct.

Creates an Authorization in the Cloudflare KC store based on an AuthRequest. After the message is verified against the signature, the authorization is tied to the address that signed the message. The message is converted to bytes and hashed with a pseudorandomly generated salt. The hash is used as the KEY of the Authorization and returned to the user to be used as a token.

For better UX, we return the token in the form of a cookie that can be used by the web application.

The Authorization value is set to expire at the Cloduflare KV store at the same time that it expires as an Authorization, defined in the expiration_time field of the SIWE::Message. That way, we don’t have to deal with stale records, but Cloudflare takes care of it. After it expires, the token will no longer be usable and the user will have to Authorize again and use a new token.

Trait Implementations

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more