Skip to content

Authorization implementation #2

@ZoopOTheGoop

Description

@ZoopOTheGoop

The code is set up to handle authorization easily, but it's not implemented. The general outline is this:

Create a new struct like so:

pub struct AuthorizedClient<'a> {
    underlying: SnapdClient,
    macaroon: Macaroon<'a>
}

Where Macaroon is a newtype over a Cow. Then you can implement GetClient (etc) as for SnapdClient, but override attach_headers to also attach the auth header.

As for getting the credentials, use the /v2/login API, which can be implemented under the hood as a Get, and put a convenience method on SnapdClient called login<'a>(&self) -> AuthorizedClient<'a> {} which creates the client with an owned macaroon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions