Documentation
¶
Index ¶
- Constants
- Variables
- func AlbumRequestMessage(publicURL, personName, albumTitle string) notifications.Message
- func InvitationMessage(publicURL, personName, curatorName, email string) notifications.Message
- func JoinRequestMessage(publicURL, name, email string) notifications.Message
- func RegisterGoogleRoutes(e *echo.Echo, cfg *config.Config, module UseCases, options ...GoogleOption)
- func SignInCodeMessage(email, code string) notifications.Message
- func WithBrowser(ctx context.Context, userAgent string) context.Context
- type AccessRequest
- type AdmissionUseCases
- type AnnouncedContent
- type Announcements
- type ApproveAccessRequestRequest
- type AuthenticationUseCases
- type BrowserSession
- type Circle
- type CircleMembersRequest
- type CircleRequest
- type CircleUseCases
- type Claims
- type CreatePersonFromFaceRequest
- type CreatePersonRequest
- type ExchangeHandoffCodeRequest
- type FaceUseCases
- type GoogleOption
- type GoogleProvider
- type Handlers
- type Invitation
- type InvitationDelivery
- type LinkFaceRequest
- type LinkedEmail
- type LinkedFace
- type Mail
- type MobileSession
- type Module
- func (m *Module) ApproveAccessRequest(ctx context.Context, token, id string, request ApproveAccessRequestRequest) (AccessRequest, error)
- func (m *Module) Authenticate(ctx context.Context, token string) (Session, error)
- func (m *Module) Claimed(ctx context.Context) (bool, error)
- func (m *Module) CompleteOnboarding(ctx context.Context, token string, request UpdateProfileRequest) (Person, error)
- func (m *Module) CreateCircle(ctx context.Context, token string, request CircleRequest) (Circle, error)
- func (m *Module) CreatePerson(ctx context.Context, token string, request CreatePersonRequest) (Person, error)
- func (m *Module) CreatePersonFromFace(ctx context.Context, token string, request CreatePersonFromFaceRequest) (PersonDetail, error)
- func (m *Module) DeleteCircle(ctx context.Context, token, id string) error
- func (m *Module) DenyAccessRequest(ctx context.Context, token, id string) (AccessRequest, error)
- func (m *Module) ExchangeHandoffCode(ctx context.Context, code, platform string) (Session, error)
- func (m *Module) GetPerson(ctx context.Context, token, id string) (PersonDetail, error)
- func (m *Module) IgnoreFace(ctx context.Context, token, sourceID string) error
- func (m *Module) IssueHandoffCode(ctx context.Context, token string) (string, error)
- func (m *Module) LinkFace(ctx context.Context, token, personID string, request LinkFaceRequest) (PersonDetail, error)
- func (m *Module) ListAccessRequests(ctx context.Context, token string) ([]AccessRequest, error)
- func (m *Module) ListCircles(ctx context.Context, token string) ([]Circle, error)
- func (m *Module) ListPeople(ctx context.Context, token, search string) ([]PersonSummary, error)
- func (m *Module) PendingAccessRequests(ctx context.Context) (int, error)
- func (m *Module) Preauthorize(ctx context.Context, token, personID string, request PreauthorizeRequest) (Preauthorization, error)
- func (m *Module) Profile(ctx context.Context, token string) (Profile, error)
- func (m *Module) ReconsiderAccessRequest(ctx context.Context, token, id string) (AccessRequest, error)
- func (m *Module) RenameCircle(ctx context.Context, token, id string, request CircleRequest) (Circle, error)
- func (m *Module) RequestAlbumAccess(ctx context.Context, token, albumID string) (AccessRequest, error)
- func (m *Module) RequestSignInCode(ctx context.Context, request RequestSignInCodeRequest) error
- func (m *Module) ResetTips(ctx context.Context, token string) (Person, error)
- func (m *Module) RetireTip(ctx context.Context, token string, tip Tip) (Person, error)
- func (m *Module) RetryInvitation(ctx context.Context, token, personID, invitationID string) (Invitation, error)
- func (m *Module) RevokePreauthorization(ctx context.Context, token, personID, id string) error
- func (m *Module) SendInvitation(ctx context.Context, token, personID string, request SendInvitationRequest) (Invitation, error)
- func (m *Module) Sessions(ctx context.Context, token string) ([]BrowserSession, error)
- func (m *Module) SetCircleMembers(ctx context.Context, token, id string, request CircleMembersRequest) (Circle, error)
- func (m *Module) SetPersonAvatar(ctx context.Context, token, personID string, request SetPersonAvatarRequest) (PersonDetail, error)
- func (m *Module) SetPersonCircles(ctx context.Context, token, personID string, request PersonCirclesRequest) error
- func (m *Module) SignIn(ctx context.Context, claims Claims) (Session, error)
- func (m *Module) SignInCodesAvailable() bool
- func (m *Module) SignOut(ctx context.Context, token string) error
- func (m *Module) SignOutEverywhere(ctx context.Context, token string) error
- func (m *Module) UnlinkEmail(ctx context.Context, token, personID, emailID string) error
- func (m *Module) UpdatePerson(ctx context.Context, token, id string, request UpdatePersonRequest) (Person, error)
- func (m *Module) UpdateProfile(ctx context.Context, token string, request UpdateProfileRequest) (Profile, error)
- func (m *Module) VerifySignInCode(ctx context.Context, request VerifySignInCodeRequest) (Session, error)
- type PeopleUseCases
- type Person
- type PersonCircle
- type PersonCirclesRequest
- type PersonDetail
- type PersonSummary
- type Preauthorization
- type PreauthorizeRequest
- type Profile
- type ProfileUseCases
- type RequestSignInCodeRequest
- type SendInvitationRequest
- type Sender
- type Session
- type SetPersonAvatarRequest
- type SignInCodeResult
- type SignInMethod
- type SignInRequest
- type Status
- type Tip
- type UpdatePersonRequest
- type UpdateProfileRequest
- type UseCases
- type VerifySignInCodeRequest
Constants ¶
const ( RequestPending = "pending" RequestApproved = "approved" RequestDenied = "denied" // RequestJoin asks to join the installation; RequestAlbum asks to view one Album. RequestJoin = "join" RequestAlbum = "album" )
const CookieName = "memento_session"
const HandoffCodeLifetime = time.Minute
HandoffCodeLifetime bounds the hand-off from the browser sheet to the app.
const MobileExchangePath = "/api/identity/mobile/exchange"
MobileExchangePath is the one browser-API mutation made without a session or a browser Origin, so the server's Origin check lets it through by path.
const SessionLifetime = 180 * 24 * time.Hour
const ( // SignInCodeLifetime is how long an emailed Sign-in Code works. SignInCodeLifetime = 10 * time.Minute )
Variables ¶
var ( // ErrSignInCodeUnsent wraps the mail failure, which the server logs. The // browser sees server errors redacted and words this one itself. ErrSignInCodeUnsent = &errcodes.Error{HTTPCode: 503, Code: "sign_in_code_unsent", Message: "The sign-in code email could not be sent."} // ErrNameRequired means the code is right but the address is unknown: the // Person gives a name and verifies again to request access. The code is // not spent. ErrNameRequired = errors.New("a name is needed to request access") )
var ( ErrPersonDeactivated = &errcodes.Error{HTTPCode: 409, Code: "person_deactivated", Message: "This person is deactivated. Restore their access before inviting them."} )
var ( ErrAccessDenied = &errcodes.Error{HTTPCode: 403, Code: "access_denied", Message: "This email does not have access to this installation."} ErrUnauthenticated = &errcodes.Error{HTTPCode: 401, Code: "unauthenticated", Message: "Sign in to continue."} ErrUnverifiedEmail = &errcodes.Error{HTTPCode: 403, Code: "unverified_email", Message: "Sign-in requires a verified email address."} // ErrAccessRequested means the verified address is unknown and a Curator now has one pending request for it. ErrAccessRequested = &errcodes.Error{HTTPCode: 403, Code: "access_requested", Message: "This email does not have access yet. Your Curator has been asked to review your request."} )
var ( ErrRequestResolved = &errcodes.Error{HTTPCode: 409, Code: "request_resolved", Message: "This request was already approved. Manage the Person directly instead."} ErrEmailInUse = &errcodes.Error{HTTPCode: 409, Code: "email_in_use", Message: "This email is already approved for or linked to another Person. Review that Person before approving this request."} )
var ErrFinalCurator = &errcodes.Error{HTTPCode: 409, Code: "final_curator", Message: "Keep at least one active Curator with a linked email before making this change."}
ErrGoogleUnavailable means discovery or token exchange could not complete.
var ErrHandoffCodeInvalid = &errcodes.Error{HTTPCode: 401, Code: "invalid_code", Message: "That sign-in has expired. Start again from the app."}
var ErrLastEmail = &errcodes.Error{HTTPCode: 409, Code: "last_email", Message: "Link another email before removing your last one, or ask a Curator to remove it for you."}
var Tips = []Tip{TipVideos, TipJoin, TipChapters}
Tips lists every Tip. A new one also needs a migration that admits its name to persons.retired_tips.
Functions ¶
func AlbumRequestMessage ¶ added in v0.6.0
func AlbumRequestMessage(publicURL, personName, albumTitle string) notifications.Message
AlbumRequestMessage alerts Curators to a Person asking to see an Album. Like JoinRequestMessage, it has no recipient yet.
func InvitationMessage ¶ added in v0.6.0
func InvitationMessage(publicURL, personName, curatorName, email string) notifications.Message
InvitationMessage is plain outreach: it names the exact email to sign in with and links to ordinary sign-in. It carries no token or private link.
func JoinRequestMessage ¶ added in v0.6.0
func JoinRequestMessage(publicURL, name, email string) notifications.Message
JoinRequestMessage alerts Curators to someone new asking to join. It has no recipient; alertCurators addresses one copy to each Curator.
func RegisterGoogleRoutes ¶
func RegisterGoogleRoutes(e *echo.Echo, cfg *config.Config, module UseCases, options ...GoogleOption)
RegisterGoogleRoutes adds browser sign-in when both Google credentials are configured, without network I/O. Options substitute the provider for local protocol and HTTP tests.
func SignInCodeMessage ¶ added in v0.6.0
func SignInCodeMessage(email, code string) notifications.Message
SignInCodeMessage puts the code in the subject, so it shows in a notification without opening the email.
Types ¶
type AccessRequest ¶
type AccessRequest struct {
ID string `json:"id"`
// Kind is join for an unknown address and album for an existing Person's request.
Kind string `json:"kind"`
Email string `json:"email"`
DisplayName string `json:"display_name"`
PersonID string `json:"person_id"`
PersonName string `json:"person_name"`
AlbumID string `json:"album_id"`
AlbumTitle string `json:"album_title"`
Status string `json:"status"`
SignInCount int `json:"sign_in_count"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ResolvedAt *time.Time `json:"resolved_at"`
ResolvedBy string `json:"resolved_by"`
}
AccessRequest shows what a Curator may inspect. It never asserts that the address and any Person are the same human.
type AdmissionUseCases ¶
type AdmissionUseCases interface {
CompleteOnboarding(context.Context, string, UpdateProfileRequest) (Person, error)
SendInvitation(context.Context, string, string, SendInvitationRequest) (Invitation, error)
RetryInvitation(context.Context, string, string, string) (Invitation, error)
RequestAlbumAccess(context.Context, string, string) (AccessRequest, error)
ListAccessRequests(context.Context, string) ([]AccessRequest, error)
ApproveAccessRequest(context.Context, string, string, ApproveAccessRequestRequest) (AccessRequest, error)
DenyAccessRequest(context.Context, string, string) (AccessRequest, error)
ReconsiderAccessRequest(context.Context, string, string) (AccessRequest, error)
}
AdmissionUseCases covers Onboarding, Invitations, and Access Requests.
type AnnouncedContent ¶
AnnouncedContent counts a Person's notification baseline.
type Announcements ¶
type Announcements interface {
RecordBaseline(context.Context, bun.Tx, string) (notifications.Baseline, error)
RecordOfferedAlbums(context.Context, bun.Tx, string) error
Announced(context.Context, bun.IDB, string) (notifications.Baseline, error)
}
Announcements is the consumer-owned view of Notifications for Onboarding baselines and for turning "Tell me about albums I can join" back on.
type ApproveAccessRequestRequest ¶
type ApproveAccessRequestRequest struct {
PersonID string `json:"person_id" validate:"omitempty,uuid"`
DisplayName string `json:"display_name" validate:"omitempty,max=100" mod:"trim"`
CircleIDs []string `json:"circle_ids"`
}
ApproveAccessRequestRequest links an unknown address to an existing Person or creates one, and adds that Person to any picked Circles. Requests from an existing Person need none of the fields.
func (ApproveAccessRequestRequest) ValidationMessage ¶
func (ApproveAccessRequestRequest) ValidationMessage(field, rule string) string
type AuthenticationUseCases ¶
type AuthenticationUseCases interface {
Claimed(context.Context) (bool, error)
SignIn(context.Context, Claims) (Session, error)
Authenticate(context.Context, string) (Session, error)
SignOut(context.Context, string) error
SignInCodesAvailable() bool
RequestSignInCode(context.Context, RequestSignInCodeRequest) error
VerifySignInCode(context.Context, VerifySignInCodeRequest) (Session, error)
IssueHandoffCode(context.Context, string) (string, error)
ExchangeHandoffCode(context.Context, string, string) (Session, error)
}
type BrowserSession ¶
type BrowserSession struct {
ID string `json:"id"`
LinkedEmailID string `json:"linked_email_id"`
Email string `json:"email"`
Device string `json:"device"`
CreatedAt time.Time `json:"created_at"`
LastUsedAt time.Time `json:"last_used_at"`
ExpiresAt time.Time `json:"expires_at"`
Current bool `json:"current"`
}
BrowserSession exposes no credential or token hash.
type Circle ¶ added in v0.5.0
type Circle struct {
ID string `json:"id"`
Name string `json:"name"`
Members []Person `json:"members"`
}
Circle is a Curator-named set of People with its members in name order. Circles are Curator-only and never appear in a viewer response.
type CircleMembersRequest ¶ added in v0.5.0
type CircleMembersRequest struct {
PersonIDs []string `json:"person_ids" validate:"required"`
}
CircleMembersRequest is the complete set of People in a Circle.
func (CircleMembersRequest) ValidationMessage ¶ added in v0.5.0
func (CircleMembersRequest) ValidationMessage(field, _ string) string
type CircleRequest ¶ added in v0.5.0
type CircleRequest struct {
Name string `json:"name" validate:"required,max=100" mod:"trim"`
}
CircleRequest names a new Circle or renames one.
func (CircleRequest) ValidationMessage ¶ added in v0.5.0
func (CircleRequest) ValidationMessage(field, rule string) string
type CircleUseCases ¶ added in v0.5.0
type CircleUseCases interface {
ListCircles(context.Context, string) ([]Circle, error)
CreateCircle(context.Context, string, CircleRequest) (Circle, error)
RenameCircle(context.Context, string, string, CircleRequest) (Circle, error)
DeleteCircle(context.Context, string, string) error
SetCircleMembers(context.Context, string, string, CircleMembersRequest) (Circle, error)
SetPersonCircles(context.Context, string, string, PersonCirclesRequest) error
}
type Claims ¶
Claims are one verified address and the name the verifier reported. They must come from a trusted adapter, never an unchecked browser body, and any way of verifying an address (Google, a Sign-in Code) produces the same shape.
func FakeClaims ¶
func FakeClaims(request SignInRequest) Claims
FakeClaims treats a typed address as verified, only on explicitly enabled development routes. Real adapters call the same SignIn after verifying it.
type CreatePersonFromFaceRequest ¶
type CreatePersonFromFaceRequest struct {
DisplayName string `json:"display_name" validate:"required,max=100" mod:"trim"`
SourceFaceID string `json:"source_face_id" validate:"required,max=1024" mod:"trim"`
}
func (CreatePersonFromFaceRequest) ValidationMessage ¶
func (CreatePersonFromFaceRequest) ValidationMessage(field, rule string) string
type CreatePersonRequest ¶
type CreatePersonRequest struct {
DisplayName string `json:"display_name" validate:"required,max=100" mod:"trim"`
}
func (CreatePersonRequest) ValidationMessage ¶
func (CreatePersonRequest) ValidationMessage(field, rule string) string
type ExchangeHandoffCodeRequest ¶ added in v0.4.0
type ExchangeHandoffCodeRequest struct {
Code string `json:"code" validate:"required,max=64" mod:"trim"`
Platform string `json:"platform" validate:"required,max=40" mod:"trim"`
}
ExchangeHandoffCodeRequest carries the Hand-off Code the web sign-in gave the Mobile App, and the platform that names its session.
type FaceUseCases ¶
type FaceUseCases interface {
LinkFace(context.Context, string, string, LinkFaceRequest) (PersonDetail, error)
CreatePersonFromFace(context.Context, string, CreatePersonFromFaceRequest) (PersonDetail, error)
IgnoreFace(context.Context, string, string) error
SetPersonAvatar(context.Context, string, string, SetPersonAvatarRequest) (PersonDetail, error)
}
type GoogleOption ¶
type GoogleOption func(*GoogleProvider)
func WithGoogleIssuer ¶
func WithGoogleIssuer(issuer string, client *http.Client) GoogleOption
WithGoogleIssuer substitutes a local OIDC server at the adapter boundary in tests. Production configuration deliberately has no issuer or transport override.
type GoogleProvider ¶
type GoogleProvider struct {
// contains filtered or unexported fields
}
GoogleProvider verifies Google credentials before exposing Identity claims. Discovery is lazy, so Google outages do not prevent startup or database health checks.
func NewGoogleProvider ¶
func NewGoogleProvider(clientID, clientSecret, callbackURL string, options ...GoogleOption) *GoogleProvider
func (*GoogleProvider) AuthorizationURL ¶
func (p *GoogleProvider) AuthorizationURL(ctx context.Context, state, nonce, verifier string) (string, error)
AuthorizationURL starts a code flow bound to the caller's one-use state, nonce and PKCE verifier.
type Handlers ¶
type Handlers struct {
// contains filtered or unexported fields
}
func RegisterRoutes ¶
RegisterRoutes registers public authentication routes. Protected features reuse the guards.
func (*Handlers) RequireCurator ¶
func (h *Handlers) RequireCurator(next echo.HandlerFunc) echo.HandlerFunc
RequireCurator restricts administration to active Curators.
func (*Handlers) RequirePerson ¶
func (h *Handlers) RequirePerson(next echo.HandlerFunc) echo.HandlerFunc
RequirePerson admits every active signed-in Person, without inventing onboarding completion.
func (*Handlers) RequireSetupOrCurator ¶
func (h *Handlers) RequireSetupOrCurator(next echo.HandlerFunc) echo.HandlerFunc
RequireSetupOrCurator exposes installation diagnostics only to installers or Curators.
type Invitation ¶
type InvitationDelivery ¶
type InvitationDelivery struct {
Status string `json:"status"`
Attempts int `json:"attempts"`
Message string `json:"message"`
UpdatedAt time.Time `json:"updated_at"`
DeliveredAt *time.Time `json:"delivered_at"`
}
InvitationDelivery is Memento's delivery state; status is queued, sending, delivered, failed, or uncertain.
type LinkFaceRequest ¶
type LinkFaceRequest struct {
SourceFaceID string `json:"source_face_id" validate:"required,max=1024" mod:"trim"`
}
func (LinkFaceRequest) ValidationMessage ¶
func (LinkFaceRequest) ValidationMessage(field, _ string) string
type LinkedEmail ¶ added in v0.4.0
type LinkedEmail struct {
ID string `json:"id"`
Email string `json:"email"`
CreatedAt time.Time `json:"created_at"`
}
LinkedEmail is a Linked Email as the Person page and profile show it.
type LinkedFace ¶
type Mail ¶
type Mail interface {
Enqueue(context.Context, bun.Tx, notifications.Message) (notifications.Delivery, error)
Retry(context.Context, bun.Tx, string) (notifications.Delivery, error)
Deliveries(context.Context, bun.IDB, []string) (map[string]notifications.Delivery, error)
}
Mail is the consumer-owned view of Notifications for Invitations.
type MobileSession ¶ added in v0.3.0
MobileSession is what the Mobile App keeps after exchanging its code. The token goes in a bearer header; the app never sees a cookie.
type Module ¶
type Module struct {
// ImmichURL is the browser-reachable Immich origin used for "Open in
// Immich" links on linked faces. Empty hides those links.
ImmichURL string
// PublicURL is the origin Invitation emails point at.
PublicURL string
// Mail is nil until the server wires Notifications; Invitations then report SMTP as unconfigured.
Mail Mail
// Announcements records the Onboarding baseline and Albums offered while
// a Person was not hearing about them. Both fail without it.
Announcements Announcements
// Sender is nil until mail is configured, which turns Sign-in Codes off.
Sender Sender
// contains filtered or unexported fields
}
Module owns Identity transactions. The clock is replaceable for expiry tests.
func (*Module) ApproveAccessRequest ¶
func (m *Module) ApproveAccessRequest(ctx context.Context, token, id string, request ApproveAccessRequestRequest) (AccessRequest, error)
ApproveAccessRequest records the decision and, for an unknown address, chooses or creates the Person, adds the Preauthorization that admits it, and adds the Person to the picked Circles. It never writes an Access Decision: Album access stays a separate review.
func (*Module) Authenticate ¶
Authenticate rejects expired sessions and extends active sessions at most daily.
func (*Module) CompleteOnboarding ¶
func (m *Module) CompleteOnboarding(ctx context.Context, token string, request UpdateProfileRequest) (Person, error)
CompleteOnboarding is the one-time Person transition. It saves the confirmed profile and records the notification baseline in the same transaction, so a retry, another identity, or a later sign-in finds it already complete and changes nothing.
func (*Module) CreateCircle ¶ added in v0.5.0
func (*Module) CreatePerson ¶
func (*Module) CreatePersonFromFace ¶
func (m *Module) CreatePersonFromFace(ctx context.Context, token string, request CreatePersonFromFaceRequest) (PersonDetail, error)
func (*Module) DeleteCircle ¶ added in v0.5.0
DeleteCircle removes a Circle and its memberships. Its People stay.
func (*Module) DenyAccessRequest ¶
DenyAccessRequest records a reviewable refusal. Repeated matching sign-ins keep refreshing the denied request without reopening it.
func (*Module) ExchangeHandoffCode ¶ added in v0.4.0
ExchangeHandoffCode issues the app its own session, labeled by platform. The code is consumed as it is read, so concurrent exchanges admit one phone.
func (*Module) IgnoreFace ¶
func (*Module) IssueHandoffCode ¶ added in v0.4.0
IssueHandoffCode hands the browser's signed-in session over to the Mobile App as a Hand-off Code, and ends that session in the same transaction: the phone's session replaces it, so the next sign-in from the app starts fresh and can be someone else. Expired codes are removed on the way.
func (*Module) LinkFace ¶
func (m *Module) LinkFace(ctx context.Context, token, personID string, request LinkFaceRequest) (PersonDetail, error)
func (*Module) ListAccessRequests ¶
ListAccessRequests shows pending work first, then recent decisions.
func (*Module) ListCircles ¶ added in v0.5.0
ListCircles returns every Circle in name order with its members.
func (*Module) ListPeople ¶
func (*Module) PendingAccessRequests ¶
PendingAccessRequests counts requests waiting for a decision, for the Curator dashboard. The dashboard route already requires a Curator.
func (*Module) Preauthorize ¶
func (m *Module) Preauthorize(ctx context.Context, token, personID string, request PreauthorizeRequest) (Preauthorization, error)
func (*Module) ReconsiderAccessRequest ¶
func (m *Module) ReconsiderAccessRequest(ctx context.Context, token, id string) (AccessRequest, error)
ReconsiderAccessRequest reopens a denied request for a fresh decision.
func (*Module) RenameCircle ¶ added in v0.5.0
func (*Module) RequestAlbumAccess ¶
func (m *Module) RequestAlbumAccess(ctx context.Context, token, albumID string) (AccessRequest, error)
RequestAlbumAccess is the explicit action for an existing Person who reached an Album they cannot see. Visiting alone never calls it. One open request per Person and Album absorbs repeated clicks.
func (*Module) RequestSignInCode ¶ added in v0.4.0
func (m *Module) RequestSignInCode(ctx context.Context, request RequestSignInCodeRequest) error
RequestSignInCode emails a new Sign-in Code that replaces any earlier one. It reports success whether or not Memento knows the address, and also when a send limit quietly sends nothing, so nobody can learn who belongs.
func (*Module) ResetTips ¶ added in v0.7.0
ResetTips brings back every Tip for the signed-in Person. Only development installations expose it, so a developer can see the Tips again without creating another Person.
func (*Module) RetireTip ¶ added in v0.7.0
RetireTip records that the signed-in Person dismissed or used a Tip, so no device shows it to them again. Retiring one twice changes nothing.
func (*Module) RetryInvitation ¶
func (m *Module) RetryInvitation(ctx context.Context, token, personID, invitationID string) (Invitation, error)
RetryInvitation is the deliberate resend for failed or uncertain delivery. The delivery record decides whether any work is added, so repeated clicks are safe.
func (*Module) RevokePreauthorization ¶
func (*Module) SendInvitation ¶
func (m *Module) SendInvitation(ctx context.Context, token, personID string, request SendInvitationRequest) (Invitation, error)
SendInvitation creates at most one Invitation per Preauthorization and commits its delivery record with the same transaction. Repeating the request returns the existing Invitation instead of sending another email.
func (*Module) SetCircleMembers ¶ added in v0.5.0
func (m *Module) SetCircleMembers(ctx context.Context, token, id string, request CircleMembersRequest) (Circle, error)
SetCircleMembers makes the given People exactly the Circle's members.
func (*Module) SetPersonAvatar ¶
func (m *Module) SetPersonAvatar(ctx context.Context, token, personID string, request SetPersonAvatarRequest) (PersonDetail, error)
func (*Module) SetPersonCircles ¶ added in v0.5.0
func (m *Module) SetPersonCircles(ctx context.Context, token, personID string, request PersonCirclesRequest) error
SetPersonCircles makes the given Circles exactly the ones a Person belongs to.
func (*Module) SignIn ¶
SignIn resolves a verified address with resolveAddress and issues a session, or records an Access Request when no step admits the address.
func (*Module) SignInCodesAvailable ¶ added in v0.4.0
SignInCodesAvailable reports whether this Installation can email Sign-in Codes.
func (*Module) SignOutEverywhere ¶
func (*Module) UnlinkEmail ¶ added in v0.4.0
UnlinkEmail keeps the address on record but removes its sign-in access, ending its sessions. An empty personID selects the signed-in Person. The address is admitted again only through a new Preauthorization.
func (*Module) UpdatePerson ¶
func (*Module) UpdateProfile ¶
func (*Module) VerifySignInCode ¶ added in v0.4.0
func (m *Module) VerifySignInCode(ctx context.Context, request VerifySignInCodeRequest) (Session, error)
VerifySignInCode checks the newest code sent to the address and resolves it the way Google sign-in does. A code works once, dies after five wrong guesses, and is not spent when an unknown address must first give a name (ErrNameRequired). With a name, an unknown address spends the code on an Access Request and gets ErrAccessRequested.
type PeopleUseCases ¶
type PeopleUseCases interface {
CreatePerson(context.Context, string, CreatePersonRequest) (Person, error)
ListPeople(context.Context, string, string) ([]PersonSummary, error)
GetPerson(context.Context, string, string) (PersonDetail, error)
UpdatePerson(context.Context, string, string, UpdatePersonRequest) (Person, error)
}
type Person ¶
type Person struct {
ID string `json:"id"`
DisplayName string `json:"display_name"`
IsCurator bool `json:"is_curator"`
OnboardingCompletedAt *time.Time `json:"onboarding_completed_at"`
DeactivatedAt *time.Time `json:"deactivated_at"`
UpdateEmail string `json:"update_email"`
EmailUpdates bool `json:"email_updates"`
// OfferedAlbumUpdates is "Tell me about albums I can join".
OfferedAlbumUpdates bool `json:"offered_album_updates"`
AvatarURL string `json:"avatar_url"`
// RetiredTips are the Tips this Person has dismissed or used, so the
// viewer never shows them again on any device.
RetiredTips []Tip `json:"retired_tips"`
}
Person is a public projection, not a writable database model.
type PersonCircle ¶ added in v0.5.0
type PersonCircle struct {
ID string `json:"id"`
Name string `json:"name"`
Member bool `json:"member"`
}
PersonCircle is one Circle on a Person's details page and whether the Person belongs to it.
type PersonCirclesRequest ¶ added in v0.5.0
type PersonCirclesRequest struct {
CircleIDs []string `json:"circle_ids" validate:"required"`
}
PersonCirclesRequest is the complete set of Circles a Person belongs to.
func (PersonCirclesRequest) ValidationMessage ¶ added in v0.5.0
func (PersonCirclesRequest) ValidationMessage(field, _ string) string
type PersonDetail ¶
type PersonDetail struct {
Person Person `json:"person"`
Faces []LinkedFace `json:"faces"`
Emails []LinkedEmail `json:"emails"`
Invitations []Invitation `json:"invitations"`
Sessions []BrowserSession `json:"sessions"`
Announced AnnouncedContent `json:"announced"`
Circles []PersonCircle `json:"circles"`
}
type PersonSummary ¶
type PersonSummary struct {
Person `tstype:",extends"`
Email string `json:"email"`
Access string `json:"access"`
LastSeenAt *time.Time `json:"last_seen_at"`
}
PersonSummary is a People list row: the Person plus where they stand on signing in, so a Curator can see who still needs an email, an approval, or a first visit. Email is the newest linked email, or the newest open Preauthorization when nothing is linked yet. Access is "none", "approved", "linked", or "onboarded"; the last two mean they can sign in.
type Preauthorization ¶
type Preauthorization struct {
}
type PreauthorizeRequest ¶
type PreauthorizeRequest struct {
}
func (PreauthorizeRequest) ValidationMessage ¶
func (PreauthorizeRequest) ValidationMessage(field, rule string) string
type Profile ¶
type Profile struct {
Person Person `json:"person"`
Emails []LinkedEmail `json:"emails"`
}
type ProfileUseCases ¶
type ProfileUseCases interface {
Profile(context.Context, string) (Profile, error)
UpdateProfile(context.Context, string, UpdateProfileRequest) (Profile, error)
Sessions(context.Context, string) ([]BrowserSession, error)
SignOutEverywhere(context.Context, string) error
UnlinkEmail(context.Context, string, string, string) error
RetireTip(context.Context, string, Tip) (Person, error)
ResetTips(context.Context, string) (Person, error)
}
type RequestSignInCodeRequest ¶ added in v0.4.0
type RequestSignInCodeRequest struct {
Email string `json:"email" validate:"required,email,max=254" mod:"trim"`
}
RequestSignInCodeRequest asks for a Sign-in Code to be emailed to an address.
func (RequestSignInCodeRequest) ValidationMessage ¶ added in v0.4.0
func (RequestSignInCodeRequest) ValidationMessage(field, rule string) string
type SendInvitationRequest ¶
type SendInvitationRequest struct {
}
SendInvitationRequest names the unused Preauthorization the email should describe.
func (SendInvitationRequest) ValidationMessage ¶
func (SendInvitationRequest) ValidationMessage(field, _ string) string
type Sender ¶ added in v0.4.0
type Sender interface {
Send(context.Context, notifications.Message) error
}
Sender delivers one email now. Sign-in Codes skip the durable queue because a code is worthless after ten minutes and a retry is the wrong tool.
type SetPersonAvatarRequest ¶
type SetPersonAvatarRequest struct {
SourceFaceID string `json:"source_face_id" validate:"required,max=1024" mod:"trim"`
}
func (SetPersonAvatarRequest) ValidationMessage ¶
func (SetPersonAvatarRequest) ValidationMessage(field, _ string) string
type SignInCodeResult ¶ added in v0.4.0
SignInCodeResult is where a verified Sign-in Code leaves the browser. Outcome is signed_in with Person set, name_required when an unknown address must give a name and verify again, or requested once a Curator has been asked to review it.
type SignInMethod ¶ added in v0.4.0
type SignInMethod string
const ( SignInMethodCode SignInMethod = "code" SignInMethodGoogle SignInMethod = "google" SignInMethodFake SignInMethod = "fake" )
type SignInRequest ¶
type SignInRequest struct {
Email string `json:"email" validate:"required,email,max=254" mod:"trim"`
DisplayName string `json:"display_name" validate:"required,max=100" mod:"trim"`
}
SignInRequest supplies claims from the explicitly enabled development provider. Production providers verify their own credentials before calling SignIn.
func (SignInRequest) ValidationMessage ¶
func (SignInRequest) ValidationMessage(field, rule string) string
ValidationMessage supplies sign-in guidance for missing fields.
type Status ¶
type Status struct {
Claimed bool `json:"claimed"`
Person *Person `json:"person"`
// AuthMode and SignInCodes remain for older Mobile App clients. The web
// uses SignInMethods because several methods can be available together.
AuthMode string `json:"auth_mode"`
SignInMethods []SignInMethod `json:"sign_in_methods"`
SignInCodes bool `json:"sign_in_codes"`
Version string `json:"version"`
}
Status describes installation claiming and the current browser's identity. It is public, and the Mobile App checks Version against the oldest server it supports before sign-in starts.
type Tip ¶ added in v0.7.0
type Tip string
Tip names a one-time note pointing a viewer at something Memento does differently from other photo apps.
type UpdatePersonRequest ¶
type UpdatePersonRequest struct {
DisplayName string `json:"display_name" validate:"required,max=100" mod:"trim"`
IsCurator bool `json:"is_curator"`
Deactivated bool `json:"deactivated"`
// OfferedAlbumUpdates keeps the current setting when omitted, so older
// clients never turn it off by leaving it out.
OfferedAlbumUpdates *bool `json:"offered_album_updates"`
}
func (UpdatePersonRequest) ValidationMessage ¶
func (UpdatePersonRequest) ValidationMessage(field, rule string) string
type UpdateProfileRequest ¶
type UpdateProfileRequest struct {
DisplayName string `json:"display_name" validate:"required,max=100" mod:"trim"`
UpdateEmail string `json:"update_email" validate:"omitempty,email,max=254"`
EmailUpdates bool `json:"email_updates"`
// OfferedAlbumUpdates keeps the current setting when omitted, so older
// clients never turn it off by leaving it out.
OfferedAlbumUpdates *bool `json:"offered_album_updates"`
}
func (UpdateProfileRequest) ValidationMessage ¶
func (UpdateProfileRequest) ValidationMessage(field, rule string) string
type UseCases ¶
type UseCases interface {
AuthenticationUseCases
PeopleUseCases
CircleUseCases
ProfileUseCases
FaceUseCases
AdmissionUseCases
}
UseCases is the HTTP boundary; persistence and claim ordering stay in Module.
type VerifySignInCodeRequest ¶ added in v0.4.0
type VerifySignInCodeRequest struct {
Email string `json:"email" validate:"required,email,max=254" mod:"trim"`
Code string `json:"code" validate:"required,max=20"`
DisplayName string `json:"display_name" validate:"max=100" mod:"trim"`
}
VerifySignInCodeRequest proves control of an address with the code emailed to it. The name is needed only when an unknown address requests access.
func (VerifySignInCodeRequest) ValidationMessage ¶ added in v0.4.0
func (VerifySignInCodeRequest) ValidationMessage(field, rule string) string
Source Files
¶
- admission_handlers.go
- circles.go
- circles_handlers.go
- codes.go
- faces.go
- fake.go
- google.go
- google_handlers.go
- google_routes.go
- handlers.go
- invitations.go
- mobile.go
- mobile_handlers.go
- module.go
- onboarding.go
- people.go
- people_handlers.go
- preauthorizations.go
- profile.go
- requests.go
- routes.go
- sessions.go
- tips.go
- types.go
- validation.go