pub struct Store { /* private fields */ }Expand description
Campaigns, devices, setup codes and challenges, in Postgres.
Implementations§
Source§impl Store
impl Store
Sourcepub async fn token_key(&self) -> Result<DeviceKey, ApiError>
pub async fn token_key(&self) -> Result<DeviceKey, ApiError>
The token signing key, created by whichever instance starts first.
Sourcepub async fn create_campaign(
&self,
name: &str,
edition: Edition,
) -> Result<Campaign, ApiError>
pub async fn create_campaign( &self, name: &str, edition: Edition, ) -> Result<Campaign, ApiError>
Creates a campaign.
Sourcepub async fn delete_campaign(
&self,
id: Uuid,
) -> Result<Option<(Campaign, u64)>, ApiError>
pub async fn delete_campaign( &self, id: Uuid, ) -> Result<Option<(Campaign, u64)>, ApiError>
Deletes a campaign with its devices, setup codes, pairings and
login challenges, returning what it was; None if there’s no such
campaign. Its devices can’t log in from then on.
Sourcepub async fn new_setup_code(
&self,
campaign: Uuid,
valid_for: Duration,
) -> Result<String, ApiError>
pub async fn new_setup_code( &self, campaign: Uuid, valid_for: Duration, ) -> Result<String, ApiError>
A fresh one-time code that lets a device make itself DM of
campaign.
Sourcepub async fn peek_setup_code(
&self,
code: &str,
) -> Result<Option<Uuid>, ApiError>
pub async fn peek_setup_code( &self, code: &str, ) -> Result<Option<Uuid>, ApiError>
The campaign a setup code is for, without using it up.
Sourcepub async fn take_setup_code(
&self,
executor: impl PgExecutor<'_>,
code: &str,
) -> Result<Option<Uuid>, ApiError>
pub async fn take_setup_code( &self, executor: impl PgExecutor<'_>, code: &str, ) -> Result<Option<Uuid>, ApiError>
Uses up a setup code, returning its campaign if it was valid.
Sourcepub async fn add_device(
&self,
executor: impl PgExecutor<'_>,
cert: &SignedCert,
) -> Result<Device, ApiError>
pub async fn add_device( &self, executor: impl PgExecutor<'_>, cert: &SignedCert, ) -> Result<Device, ApiError>
Adds a device with its certificate, within the campaign’s limit.
Sourcepub async fn export_campaign(
&self,
id: Uuid,
) -> Result<Option<AuthExport>, ApiError>
pub async fn export_campaign( &self, id: Uuid, ) -> Result<Option<AuthExport>, ApiError>
The campaign and its devices, to keep or move elsewhere; None if
there’s no such campaign.
Sourcepub async fn import_campaign(
&self,
export: &AuthExport,
) -> Result<u64, ApiError>
pub async fn import_campaign( &self, export: &AuthExport, ) -> Result<u64, ApiError>
Takes in a campaign exported elsewhere, as it was, ids, keys and dates included; returns how many devices came with it. All or nothing, and not over a campaign that’s here already. Every certificate must be for the campaign and properly signed.
Sourcepub async fn settings(
&self,
campaign: Uuid,
) -> Result<CampaignSettings, ApiError>
pub async fn settings( &self, campaign: Uuid, ) -> Result<CampaignSettings, ApiError>
What was set for the campaign: by default, the services’ own limits, and changes allowed.
Sourcepub async fn set_settings(
&self,
campaign: Uuid,
settings: &CampaignSettings,
) -> Result<(), ApiError>
pub async fn set_settings( &self, campaign: Uuid, settings: &CampaignSettings, ) -> Result<(), ApiError>
Sets what the campaign may keep and do; its devices’ tokens say so from their next login.
Sourcepub async fn devices(&self, campaign: Uuid) -> Result<Vec<Device>, ApiError>
pub async fn devices(&self, campaign: Uuid) -> Result<Vec<Device>, ApiError>
The campaign’s devices, revoked ones too.
Sourcepub async fn revoke(
&self,
campaign: Uuid,
key: PublicKey,
) -> Result<Device, ApiError>
pub async fn revoke( &self, campaign: Uuid, key: PublicKey, ) -> Result<Device, ApiError>
Revokes a device. Refuses to revoke the campaign’s last DM device, which would leave nobody able to manage it.
Sourcepub async fn add_service(
&self,
name: &str,
key: PublicKey,
) -> Result<(), ApiError>
pub async fn add_service( &self, name: &str, key: PublicKey, ) -> Result<(), ApiError>
Lets a service log in to any campaign with key.
Sourcepub async fn principal(
&self,
campaign: Uuid,
key: PublicKey,
) -> Result<Option<(Principal, String)>, ApiError>
pub async fn principal( &self, campaign: Uuid, key: PublicKey, ) -> Result<Option<(Principal, String)>, ApiError>
Who key is in campaign: an active device or a service.
Sourcepub async fn create_challenge(
&self,
campaign: Uuid,
key: PublicKey,
server: PublicKey,
valid_for: Duration,
) -> Result<Challenge, ApiError>
pub async fn create_challenge( &self, campaign: Uuid, key: PublicKey, server: PublicKey, valid_for: Duration, ) -> Result<Challenge, ApiError>
A challenge for a device of the campaign to sign.
Sourcepub async fn take_challenge(
&self,
id: Uuid,
) -> Result<Option<IssuedChallenge>, ApiError>
pub async fn take_challenge( &self, id: Uuid, ) -> Result<Option<IssuedChallenge>, ApiError>
Removes a challenge, returning it if it existed. Whoever gets it first wins, so each challenge is answered at most once.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Store
impl !RefUnwindSafe for Store
impl Send for Store
impl Sync for Store
impl Unpin for Store
impl UnsafeUnpin for Store
impl !UnwindSafe for Store
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read more§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read more