From c180a2debb1685f5a979010f8a44438bf672d9a5 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Mon, 2 Nov 2026 06:03:41 +1100 Subject: [PATCH] feat(access): scoped canary grant replaces instance-admin CANARY_TOKEN (#1727) The canary now authenticates as a dedicated service-account identity in the system org whose only grant is access.CalaryGrantPolicy: read the signal endpoints (chat update, alerts, logs, tasks), read and write the update-settings resource, and trigger an update install. CANARY_TOKEN no longer carries instance admin; DEPLOY_TOKEN stays CI-only. - authorize: POST /api/chat/update/install and /defer map to update on Object::"update" (dashboard) instead of run on any workflow, so the grant can cover installs without granting workflow runs - accounts: active service-account identities may authenticate with bearer tokens (CanAct), not just users - new POST /api/identities/{id}/tokens (behind manage_identities) mints a token for a named non-user identity; new AccountService RPC BindIdentityPersonalToken backs it remotely, refusing user-kind targets, with the caller recorded as audit actor - engine tests pin the grant's exact allow/deny surface RELEASING.md documents the one-time setup. task check passes on this tree. --- RELEASING.md | 42 +- internal/contracts/state/v1/account.pb.go | 522 +++++++++++------- .../contracts/state/v1/account_grpc.pb.go | 48 ++ internal/domain/access/canary.go | 29 + internal/domain/access/canary_test.go | 28 + internal/infrastructure/access/engine_test.go | 70 +++ .../staterpc/personal_tokens.go | 43 ++ .../staterpc/personal_tokens_test.go | 89 +++ internal/webui/accounts.go | 6 +- internal/webui/accounts_test.go | 144 +++++ internal/webui/api_identities.go | 66 +++ internal/webui/api_personal_tokens.go | 52 +- internal/webui/authorize.go | 27 +- internal/webui/authorize_test.go | 29 + internal/webui/server.go | 1 + proto/state/v1/account.proto | 13 + 16 files changed, 978 insertions(+), 231 deletions(-) create mode 100644 internal/domain/access/canary.go create mode 100644 internal/domain/access/canary_test.go diff --git a/RELEASING.md b/RELEASING.md index 249edb620..96d9b3c3d 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -179,11 +179,49 @@ by hand. | Name | Kind | Holds | | --- | --- | --- | | `CANARY_URL` | Actions variable | the canary's dashboard URL; unset disables the canary steps | -| `CANARY_TOKEN` | Actions secret | a personal API token on the canary with instance admin | +| `CANARY_TOKEN` | Actions secret | an API token bound to a dedicated `service_account` identity on the canary, carrying only the canary grant policy (see below) — never instance admin | | `CANARY_WINDOW` | Actions variable | optional `-window` override for `canary check`; unset is 24h | -| `DEPLOY_TOKEN` | Actions secret | registry and repository write, for publishing, promoting and the release push | +| `DEPLOY_TOKEN` | Actions secret | registry and repository write, for publishing, promoting and the release push; stays CI-only, promotion runs in CI and never on the host | | `RELEASE_SIGNING_KEY` | Actions secret | the release signing seed | +#### Setting up `CANARY_TOKEN` once + +`CANARY_TOKEN` is a bearer token for a dedicated service-account identity in +the system org whose only grant is the canary policy +(`access.CanaryGrantPolicy`): read the signal endpoints (`GET /api/chat/update`, +`GET /api/alerts`, `GET /api/logs`, `GET /api/tasks`), read and write the +`update-settings` resource, and trigger an update install +(`POST /api/chat/update/install`). It carries no other rights, and instance +admin is never needed. With an instance-admin token (for example the operator +session), run against the canary host: + +```bash +# 1. Create the service-account identity in the system org. +curl -X POST "$CANARY_URL/api/identities" -H "Authorization: Bearer $ADMIN" \ + -H 'Content-Type: application/json' \ + -d '{"kind":"service_account","display_name":"ci-canary"}' +# -> {"id":"", ...} + +# 2. Issue its token (shown exactly once). +curl -X POST "$CANARY_URL/api/identities//tokens" \ + -H "Authorization: Bearer $ADMIN" -H 'Content-Type: application/json' \ + -d '{"name":"ci-canary","days":90}' +# -> {"id":"","token":"archie_pat_..."} -- store the token value as the CANARY_TOKEN secret + +# 3. Install the grant, scoped to that identity. The policy's org is pinned +# to the caller's org (org-sys for the instance admin), so the body needs +# no org field. +curl -X PUT "$CANARY_URL/api/access/policies" -H "Authorization: Bearer $ADMIN" \ + -H 'Content-Type: application/json' \ + -d '{"id":"org-canary-grant","level":"org","text":"permit(principal, action, resource) when {\n resource.org == principal.org &&\n principal == Archie::Identity::\"\" &&\n (\n (action == Archie::Action::\"read\" && [\"dashboard\", \"task\"].contains(resource.kind)) ||\n (action == Archie::Action::\"read\" && resource == Archie::Object::\"update-settings\") ||\n (action == Archie::Action::\"update\" && resource == Archie::Object::\"update\") ||\n (action == Archie::Action::\"manage_identities\" && resource == Archie::Object::\"update-settings\")\n )\n};"}' +``` + +The policy text is exactly `access.CanaryGrantPolicy(org-sys, )` +from `internal/domain/access/canary.go`; the curl body above is that text with +the identity id filled in. The canary needs no other rights: `GET +/health/detailed` is unauthenticated, and every other call it makes is covered +by the grant. + The runner must reach `CANARY_URL`. Without a canary a release stays on `next` until promoted by hand, under the same refusals: diff --git a/internal/contracts/state/v1/account.pb.go b/internal/contracts/state/v1/account.pb.go index 4e80e7fe7..4d79d4e5d 100644 --- a/internal/contracts/state/v1/account.pb.go +++ b/internal/contracts/state/v1/account.pb.go @@ -356,6 +356,110 @@ func (*RevokePersonalTokenResponse) Descriptor() ([]byte, []int) { return file_state_v1_account_proto_rawDescGZIP(), []int{6} } +type BindIdentityPersonalTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + IdentityId string `protobuf:"bytes,1,opt,name=identity_id,json=identityId,proto3" json:"identity_id,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` // unset: never expires + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BindIdentityPersonalTokenRequest) Reset() { + *x = BindIdentityPersonalTokenRequest{} + mi := &file_state_v1_account_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BindIdentityPersonalTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BindIdentityPersonalTokenRequest) ProtoMessage() {} + +func (x *BindIdentityPersonalTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_account_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BindIdentityPersonalTokenRequest.ProtoReflect.Descriptor instead. +func (*BindIdentityPersonalTokenRequest) Descriptor() ([]byte, []int) { + return file_state_v1_account_proto_rawDescGZIP(), []int{7} +} + +func (x *BindIdentityPersonalTokenRequest) GetIdentityId() string { + if x != nil { + return x.IdentityId + } + return "" +} + +func (x *BindIdentityPersonalTokenRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *BindIdentityPersonalTokenRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *BindIdentityPersonalTokenRequest) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.ExpiresAt + } + return nil +} + +type BindIdentityPersonalTokenResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *BindIdentityPersonalTokenResponse) Reset() { + *x = BindIdentityPersonalTokenResponse{} + mi := &file_state_v1_account_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *BindIdentityPersonalTokenResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BindIdentityPersonalTokenResponse) ProtoMessage() {} + +func (x *BindIdentityPersonalTokenResponse) ProtoReflect() protoreflect.Message { + mi := &file_state_v1_account_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BindIdentityPersonalTokenResponse.ProtoReflect.Descriptor instead. +func (*BindIdentityPersonalTokenResponse) Descriptor() ([]byte, []int) { + return file_state_v1_account_proto_rawDescGZIP(), []int{8} +} + type AccountSetupRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -364,7 +468,7 @@ type AccountSetupRequest struct { func (x *AccountSetupRequest) Reset() { *x = AccountSetupRequest{} - mi := &file_state_v1_account_proto_msgTypes[7] + mi := &file_state_v1_account_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -376,7 +480,7 @@ func (x *AccountSetupRequest) String() string { func (*AccountSetupRequest) ProtoMessage() {} func (x *AccountSetupRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[7] + mi := &file_state_v1_account_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -389,7 +493,7 @@ func (x *AccountSetupRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AccountSetupRequest.ProtoReflect.Descriptor instead. func (*AccountSetupRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{7} + return file_state_v1_account_proto_rawDescGZIP(), []int{9} } type AccountSetupResponse struct { @@ -401,7 +505,7 @@ type AccountSetupResponse struct { func (x *AccountSetupResponse) Reset() { *x = AccountSetupResponse{} - mi := &file_state_v1_account_proto_msgTypes[8] + mi := &file_state_v1_account_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -413,7 +517,7 @@ func (x *AccountSetupResponse) String() string { func (*AccountSetupResponse) ProtoMessage() {} func (x *AccountSetupResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[8] + mi := &file_state_v1_account_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -426,7 +530,7 @@ func (x *AccountSetupResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AccountSetupResponse.ProtoReflect.Descriptor instead. func (*AccountSetupResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{8} + return file_state_v1_account_proto_rawDescGZIP(), []int{10} } func (x *AccountSetupResponse) GetRequired() bool { @@ -452,7 +556,7 @@ type RegisterAccountRequest struct { func (x *RegisterAccountRequest) Reset() { *x = RegisterAccountRequest{} - mi := &file_state_v1_account_proto_msgTypes[9] + mi := &file_state_v1_account_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -464,7 +568,7 @@ func (x *RegisterAccountRequest) String() string { func (*RegisterAccountRequest) ProtoMessage() {} func (x *RegisterAccountRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[9] + mi := &file_state_v1_account_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -477,7 +581,7 @@ func (x *RegisterAccountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterAccountRequest.ProtoReflect.Descriptor instead. func (*RegisterAccountRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{9} + return file_state_v1_account_proto_rawDescGZIP(), []int{11} } func (x *RegisterAccountRequest) GetEmail() string { @@ -545,7 +649,7 @@ type RegisterAccountResponse struct { func (x *RegisterAccountResponse) Reset() { *x = RegisterAccountResponse{} - mi := &file_state_v1_account_proto_msgTypes[10] + mi := &file_state_v1_account_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -557,7 +661,7 @@ func (x *RegisterAccountResponse) String() string { func (*RegisterAccountResponse) ProtoMessage() {} func (x *RegisterAccountResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[10] + mi := &file_state_v1_account_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -570,7 +674,7 @@ func (x *RegisterAccountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RegisterAccountResponse.ProtoReflect.Descriptor instead. func (*RegisterAccountResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{10} + return file_state_v1_account_proto_rawDescGZIP(), []int{12} } func (x *RegisterAccountResponse) GetIdentity() *Identity { @@ -590,7 +694,7 @@ type SignInAccountRequest struct { func (x *SignInAccountRequest) Reset() { *x = SignInAccountRequest{} - mi := &file_state_v1_account_proto_msgTypes[11] + mi := &file_state_v1_account_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -602,7 +706,7 @@ func (x *SignInAccountRequest) String() string { func (*SignInAccountRequest) ProtoMessage() {} func (x *SignInAccountRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[11] + mi := &file_state_v1_account_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -615,7 +719,7 @@ func (x *SignInAccountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SignInAccountRequest.ProtoReflect.Descriptor instead. func (*SignInAccountRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{11} + return file_state_v1_account_proto_rawDescGZIP(), []int{13} } func (x *SignInAccountRequest) GetEmail() string { @@ -643,7 +747,7 @@ type SignInAccountResponse struct { func (x *SignInAccountResponse) Reset() { *x = SignInAccountResponse{} - mi := &file_state_v1_account_proto_msgTypes[12] + mi := &file_state_v1_account_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -655,7 +759,7 @@ func (x *SignInAccountResponse) String() string { func (*SignInAccountResponse) ProtoMessage() {} func (x *SignInAccountResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[12] + mi := &file_state_v1_account_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -668,7 +772,7 @@ func (x *SignInAccountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SignInAccountResponse.ProtoReflect.Descriptor instead. func (*SignInAccountResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{12} + return file_state_v1_account_proto_rawDescGZIP(), []int{14} } func (x *SignInAccountResponse) GetIdentity() *Identity { @@ -701,7 +805,7 @@ type ResolveAccountSessionRequest struct { func (x *ResolveAccountSessionRequest) Reset() { *x = ResolveAccountSessionRequest{} - mi := &file_state_v1_account_proto_msgTypes[13] + mi := &file_state_v1_account_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -713,7 +817,7 @@ func (x *ResolveAccountSessionRequest) String() string { func (*ResolveAccountSessionRequest) ProtoMessage() {} func (x *ResolveAccountSessionRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[13] + mi := &file_state_v1_account_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -726,7 +830,7 @@ func (x *ResolveAccountSessionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveAccountSessionRequest.ProtoReflect.Descriptor instead. func (*ResolveAccountSessionRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{13} + return file_state_v1_account_proto_rawDescGZIP(), []int{15} } func (x *ResolveAccountSessionRequest) GetToken() string { @@ -745,7 +849,7 @@ type ResolveAccountSessionResponse struct { func (x *ResolveAccountSessionResponse) Reset() { *x = ResolveAccountSessionResponse{} - mi := &file_state_v1_account_proto_msgTypes[14] + mi := &file_state_v1_account_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -757,7 +861,7 @@ func (x *ResolveAccountSessionResponse) String() string { func (*ResolveAccountSessionResponse) ProtoMessage() {} func (x *ResolveAccountSessionResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[14] + mi := &file_state_v1_account_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -770,7 +874,7 @@ func (x *ResolveAccountSessionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ResolveAccountSessionResponse.ProtoReflect.Descriptor instead. func (*ResolveAccountSessionResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{14} + return file_state_v1_account_proto_rawDescGZIP(), []int{16} } func (x *ResolveAccountSessionResponse) GetIdentity() *Identity { @@ -789,7 +893,7 @@ type SignOutAccountRequest struct { func (x *SignOutAccountRequest) Reset() { *x = SignOutAccountRequest{} - mi := &file_state_v1_account_proto_msgTypes[15] + mi := &file_state_v1_account_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -801,7 +905,7 @@ func (x *SignOutAccountRequest) String() string { func (*SignOutAccountRequest) ProtoMessage() {} func (x *SignOutAccountRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[15] + mi := &file_state_v1_account_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -814,7 +918,7 @@ func (x *SignOutAccountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SignOutAccountRequest.ProtoReflect.Descriptor instead. func (*SignOutAccountRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{15} + return file_state_v1_account_proto_rawDescGZIP(), []int{17} } func (x *SignOutAccountRequest) GetToken() string { @@ -832,7 +936,7 @@ type SignOutAccountResponse struct { func (x *SignOutAccountResponse) Reset() { *x = SignOutAccountResponse{} - mi := &file_state_v1_account_proto_msgTypes[16] + mi := &file_state_v1_account_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -844,7 +948,7 @@ func (x *SignOutAccountResponse) String() string { func (*SignOutAccountResponse) ProtoMessage() {} func (x *SignOutAccountResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[16] + mi := &file_state_v1_account_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -857,7 +961,7 @@ func (x *SignOutAccountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SignOutAccountResponse.ProtoReflect.Descriptor instead. func (*SignOutAccountResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{16} + return file_state_v1_account_proto_rawDescGZIP(), []int{18} } type ChangeAccountPasswordRequest struct { @@ -870,7 +974,7 @@ type ChangeAccountPasswordRequest struct { func (x *ChangeAccountPasswordRequest) Reset() { *x = ChangeAccountPasswordRequest{} - mi := &file_state_v1_account_proto_msgTypes[17] + mi := &file_state_v1_account_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -882,7 +986,7 @@ func (x *ChangeAccountPasswordRequest) String() string { func (*ChangeAccountPasswordRequest) ProtoMessage() {} func (x *ChangeAccountPasswordRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[17] + mi := &file_state_v1_account_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -895,7 +999,7 @@ func (x *ChangeAccountPasswordRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ChangeAccountPasswordRequest.ProtoReflect.Descriptor instead. func (*ChangeAccountPasswordRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{17} + return file_state_v1_account_proto_rawDescGZIP(), []int{19} } func (x *ChangeAccountPasswordRequest) GetCurrentPassword() string { @@ -920,7 +1024,7 @@ type ChangeAccountPasswordResponse struct { func (x *ChangeAccountPasswordResponse) Reset() { *x = ChangeAccountPasswordResponse{} - mi := &file_state_v1_account_proto_msgTypes[18] + mi := &file_state_v1_account_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -932,7 +1036,7 @@ func (x *ChangeAccountPasswordResponse) String() string { func (*ChangeAccountPasswordResponse) ProtoMessage() {} func (x *ChangeAccountPasswordResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[18] + mi := &file_state_v1_account_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -945,7 +1049,7 @@ func (x *ChangeAccountPasswordResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ChangeAccountPasswordResponse.ProtoReflect.Descriptor instead. func (*ChangeAccountPasswordResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{18} + return file_state_v1_account_proto_rawDescGZIP(), []int{20} } type AuthenticationSettings struct { @@ -960,7 +1064,7 @@ type AuthenticationSettings struct { func (x *AuthenticationSettings) Reset() { *x = AuthenticationSettings{} - mi := &file_state_v1_account_proto_msgTypes[19] + mi := &file_state_v1_account_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -972,7 +1076,7 @@ func (x *AuthenticationSettings) String() string { func (*AuthenticationSettings) ProtoMessage() {} func (x *AuthenticationSettings) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[19] + mi := &file_state_v1_account_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -985,7 +1089,7 @@ func (x *AuthenticationSettings) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthenticationSettings.ProtoReflect.Descriptor instead. func (*AuthenticationSettings) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{19} + return file_state_v1_account_proto_rawDescGZIP(), []int{21} } func (x *AuthenticationSettings) GetPublicUrl() string { @@ -1024,7 +1128,7 @@ type GetAuthenticationSettingsRequest struct { func (x *GetAuthenticationSettingsRequest) Reset() { *x = GetAuthenticationSettingsRequest{} - mi := &file_state_v1_account_proto_msgTypes[20] + mi := &file_state_v1_account_proto_msgTypes[22] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1036,7 +1140,7 @@ func (x *GetAuthenticationSettingsRequest) String() string { func (*GetAuthenticationSettingsRequest) ProtoMessage() {} func (x *GetAuthenticationSettingsRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[20] + mi := &file_state_v1_account_proto_msgTypes[22] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1049,7 +1153,7 @@ func (x *GetAuthenticationSettingsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetAuthenticationSettingsRequest.ProtoReflect.Descriptor instead. func (*GetAuthenticationSettingsRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{20} + return file_state_v1_account_proto_rawDescGZIP(), []int{22} } type GetAuthenticationSettingsResponse struct { @@ -1061,7 +1165,7 @@ type GetAuthenticationSettingsResponse struct { func (x *GetAuthenticationSettingsResponse) Reset() { *x = GetAuthenticationSettingsResponse{} - mi := &file_state_v1_account_proto_msgTypes[21] + mi := &file_state_v1_account_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1073,7 +1177,7 @@ func (x *GetAuthenticationSettingsResponse) String() string { func (*GetAuthenticationSettingsResponse) ProtoMessage() {} func (x *GetAuthenticationSettingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[21] + mi := &file_state_v1_account_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1086,7 +1190,7 @@ func (x *GetAuthenticationSettingsResponse) ProtoReflect() protoreflect.Message // Deprecated: Use GetAuthenticationSettingsResponse.ProtoReflect.Descriptor instead. func (*GetAuthenticationSettingsResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{21} + return file_state_v1_account_proto_rawDescGZIP(), []int{23} } func (x *GetAuthenticationSettingsResponse) GetSettings() *AuthenticationSettings { @@ -1105,7 +1209,7 @@ type SaveAuthenticationSettingsRequest struct { func (x *SaveAuthenticationSettingsRequest) Reset() { *x = SaveAuthenticationSettingsRequest{} - mi := &file_state_v1_account_proto_msgTypes[22] + mi := &file_state_v1_account_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1117,7 +1221,7 @@ func (x *SaveAuthenticationSettingsRequest) String() string { func (*SaveAuthenticationSettingsRequest) ProtoMessage() {} func (x *SaveAuthenticationSettingsRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[22] + mi := &file_state_v1_account_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1130,7 +1234,7 @@ func (x *SaveAuthenticationSettingsRequest) ProtoReflect() protoreflect.Message // Deprecated: Use SaveAuthenticationSettingsRequest.ProtoReflect.Descriptor instead. func (*SaveAuthenticationSettingsRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{22} + return file_state_v1_account_proto_rawDescGZIP(), []int{24} } func (x *SaveAuthenticationSettingsRequest) GetSettings() *AuthenticationSettings { @@ -1148,7 +1252,7 @@ type SaveAuthenticationSettingsResponse struct { func (x *SaveAuthenticationSettingsResponse) Reset() { *x = SaveAuthenticationSettingsResponse{} - mi := &file_state_v1_account_proto_msgTypes[23] + mi := &file_state_v1_account_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1160,7 +1264,7 @@ func (x *SaveAuthenticationSettingsResponse) String() string { func (*SaveAuthenticationSettingsResponse) ProtoMessage() {} func (x *SaveAuthenticationSettingsResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[23] + mi := &file_state_v1_account_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1173,7 +1277,7 @@ func (x *SaveAuthenticationSettingsResponse) ProtoReflect() protoreflect.Message // Deprecated: Use SaveAuthenticationSettingsResponse.ProtoReflect.Descriptor instead. func (*SaveAuthenticationSettingsResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{23} + return file_state_v1_account_proto_rawDescGZIP(), []int{25} } type BeginPasskeyRequest struct { @@ -1185,7 +1289,7 @@ type BeginPasskeyRequest struct { func (x *BeginPasskeyRequest) Reset() { *x = BeginPasskeyRequest{} - mi := &file_state_v1_account_proto_msgTypes[24] + mi := &file_state_v1_account_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1197,7 +1301,7 @@ func (x *BeginPasskeyRequest) String() string { func (*BeginPasskeyRequest) ProtoMessage() {} func (x *BeginPasskeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[24] + mi := &file_state_v1_account_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1210,7 +1314,7 @@ func (x *BeginPasskeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use BeginPasskeyRequest.ProtoReflect.Descriptor instead. func (*BeginPasskeyRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{24} + return file_state_v1_account_proto_rawDescGZIP(), []int{26} } func (x *BeginPasskeyRequest) GetRegistration() bool { @@ -1230,7 +1334,7 @@ type BeginPasskeyResponse struct { func (x *BeginPasskeyResponse) Reset() { *x = BeginPasskeyResponse{} - mi := &file_state_v1_account_proto_msgTypes[25] + mi := &file_state_v1_account_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1242,7 +1346,7 @@ func (x *BeginPasskeyResponse) String() string { func (*BeginPasskeyResponse) ProtoMessage() {} func (x *BeginPasskeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[25] + mi := &file_state_v1_account_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1255,7 +1359,7 @@ func (x *BeginPasskeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use BeginPasskeyResponse.ProtoReflect.Descriptor instead. func (*BeginPasskeyResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{25} + return file_state_v1_account_proto_rawDescGZIP(), []int{27} } func (x *BeginPasskeyResponse) GetToken() string { @@ -1284,7 +1388,7 @@ type FinishPasskeyRequest struct { func (x *FinishPasskeyRequest) Reset() { *x = FinishPasskeyRequest{} - mi := &file_state_v1_account_proto_msgTypes[26] + mi := &file_state_v1_account_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1296,7 +1400,7 @@ func (x *FinishPasskeyRequest) String() string { func (*FinishPasskeyRequest) ProtoMessage() {} func (x *FinishPasskeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[26] + mi := &file_state_v1_account_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1309,7 +1413,7 @@ func (x *FinishPasskeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use FinishPasskeyRequest.ProtoReflect.Descriptor instead. func (*FinishPasskeyRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{26} + return file_state_v1_account_proto_rawDescGZIP(), []int{28} } func (x *FinishPasskeyRequest) GetToken() string { @@ -1351,7 +1455,7 @@ type FinishPasskeyResponse struct { func (x *FinishPasskeyResponse) Reset() { *x = FinishPasskeyResponse{} - mi := &file_state_v1_account_proto_msgTypes[27] + mi := &file_state_v1_account_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1363,7 +1467,7 @@ func (x *FinishPasskeyResponse) String() string { func (*FinishPasskeyResponse) ProtoMessage() {} func (x *FinishPasskeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[27] + mi := &file_state_v1_account_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1376,7 +1480,7 @@ func (x *FinishPasskeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use FinishPasskeyResponse.ProtoReflect.Descriptor instead. func (*FinishPasskeyResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{27} + return file_state_v1_account_proto_rawDescGZIP(), []int{29} } func (x *FinishPasskeyResponse) GetIdentity() *Identity { @@ -1410,7 +1514,7 @@ type Passkey struct { func (x *Passkey) Reset() { *x = Passkey{} - mi := &file_state_v1_account_proto_msgTypes[28] + mi := &file_state_v1_account_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1422,7 +1526,7 @@ func (x *Passkey) String() string { func (*Passkey) ProtoMessage() {} func (x *Passkey) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[28] + mi := &file_state_v1_account_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1435,7 +1539,7 @@ func (x *Passkey) ProtoReflect() protoreflect.Message { // Deprecated: Use Passkey.ProtoReflect.Descriptor instead. func (*Passkey) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{28} + return file_state_v1_account_proto_rawDescGZIP(), []int{30} } func (x *Passkey) GetId() string { @@ -1460,7 +1564,7 @@ type ListPasskeysRequest struct { func (x *ListPasskeysRequest) Reset() { *x = ListPasskeysRequest{} - mi := &file_state_v1_account_proto_msgTypes[29] + mi := &file_state_v1_account_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1472,7 +1576,7 @@ func (x *ListPasskeysRequest) String() string { func (*ListPasskeysRequest) ProtoMessage() {} func (x *ListPasskeysRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[29] + mi := &file_state_v1_account_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1485,7 +1589,7 @@ func (x *ListPasskeysRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPasskeysRequest.ProtoReflect.Descriptor instead. func (*ListPasskeysRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{29} + return file_state_v1_account_proto_rawDescGZIP(), []int{31} } type ListPasskeysResponse struct { @@ -1497,7 +1601,7 @@ type ListPasskeysResponse struct { func (x *ListPasskeysResponse) Reset() { *x = ListPasskeysResponse{} - mi := &file_state_v1_account_proto_msgTypes[30] + mi := &file_state_v1_account_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1509,7 +1613,7 @@ func (x *ListPasskeysResponse) String() string { func (*ListPasskeysResponse) ProtoMessage() {} func (x *ListPasskeysResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[30] + mi := &file_state_v1_account_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1522,7 +1626,7 @@ func (x *ListPasskeysResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ListPasskeysResponse.ProtoReflect.Descriptor instead. func (*ListPasskeysResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{30} + return file_state_v1_account_proto_rawDescGZIP(), []int{32} } func (x *ListPasskeysResponse) GetPasskeys() []*Passkey { @@ -1541,7 +1645,7 @@ type DeletePasskeyRequest struct { func (x *DeletePasskeyRequest) Reset() { *x = DeletePasskeyRequest{} - mi := &file_state_v1_account_proto_msgTypes[31] + mi := &file_state_v1_account_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1553,7 +1657,7 @@ func (x *DeletePasskeyRequest) String() string { func (*DeletePasskeyRequest) ProtoMessage() {} func (x *DeletePasskeyRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[31] + mi := &file_state_v1_account_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1566,7 +1670,7 @@ func (x *DeletePasskeyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeletePasskeyRequest.ProtoReflect.Descriptor instead. func (*DeletePasskeyRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{31} + return file_state_v1_account_proto_rawDescGZIP(), []int{33} } func (x *DeletePasskeyRequest) GetId() string { @@ -1584,7 +1688,7 @@ type DeletePasskeyResponse struct { func (x *DeletePasskeyResponse) Reset() { *x = DeletePasskeyResponse{} - mi := &file_state_v1_account_proto_msgTypes[32] + mi := &file_state_v1_account_proto_msgTypes[34] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1596,7 +1700,7 @@ func (x *DeletePasskeyResponse) String() string { func (*DeletePasskeyResponse) ProtoMessage() {} func (x *DeletePasskeyResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[32] + mi := &file_state_v1_account_proto_msgTypes[34] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1609,7 +1713,7 @@ func (x *DeletePasskeyResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeletePasskeyResponse.ProtoReflect.Descriptor instead. func (*DeletePasskeyResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{32} + return file_state_v1_account_proto_rawDescGZIP(), []int{34} } type OpenAccountSessionRequest struct { @@ -1621,7 +1725,7 @@ type OpenAccountSessionRequest struct { func (x *OpenAccountSessionRequest) Reset() { *x = OpenAccountSessionRequest{} - mi := &file_state_v1_account_proto_msgTypes[33] + mi := &file_state_v1_account_proto_msgTypes[35] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1633,7 +1737,7 @@ func (x *OpenAccountSessionRequest) String() string { func (*OpenAccountSessionRequest) ProtoMessage() {} func (x *OpenAccountSessionRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[33] + mi := &file_state_v1_account_proto_msgTypes[35] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1646,7 +1750,7 @@ func (x *OpenAccountSessionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OpenAccountSessionRequest.ProtoReflect.Descriptor instead. func (*OpenAccountSessionRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{33} + return file_state_v1_account_proto_rawDescGZIP(), []int{35} } func (x *OpenAccountSessionRequest) GetExpiresAt() *timestamppb.Timestamp { @@ -1667,7 +1771,7 @@ type OpenAccountSessionResponse struct { func (x *OpenAccountSessionResponse) Reset() { *x = OpenAccountSessionResponse{} - mi := &file_state_v1_account_proto_msgTypes[34] + mi := &file_state_v1_account_proto_msgTypes[36] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1679,7 +1783,7 @@ func (x *OpenAccountSessionResponse) String() string { func (*OpenAccountSessionResponse) ProtoMessage() {} func (x *OpenAccountSessionResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[34] + mi := &file_state_v1_account_proto_msgTypes[36] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1692,7 +1796,7 @@ func (x *OpenAccountSessionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use OpenAccountSessionResponse.ProtoReflect.Descriptor instead. func (*OpenAccountSessionResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{34} + return file_state_v1_account_proto_rawDescGZIP(), []int{36} } func (x *OpenAccountSessionResponse) GetIdentity() *Identity { @@ -1725,7 +1829,7 @@ type RequireFreshAccountSessionRequest struct { func (x *RequireFreshAccountSessionRequest) Reset() { *x = RequireFreshAccountSessionRequest{} - mi := &file_state_v1_account_proto_msgTypes[35] + mi := &file_state_v1_account_proto_msgTypes[37] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1737,7 +1841,7 @@ func (x *RequireFreshAccountSessionRequest) String() string { func (*RequireFreshAccountSessionRequest) ProtoMessage() {} func (x *RequireFreshAccountSessionRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[35] + mi := &file_state_v1_account_proto_msgTypes[37] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1750,7 +1854,7 @@ func (x *RequireFreshAccountSessionRequest) ProtoReflect() protoreflect.Message // Deprecated: Use RequireFreshAccountSessionRequest.ProtoReflect.Descriptor instead. func (*RequireFreshAccountSessionRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{35} + return file_state_v1_account_proto_rawDescGZIP(), []int{37} } func (x *RequireFreshAccountSessionRequest) GetToken() string { @@ -1768,7 +1872,7 @@ type RequireFreshAccountSessionResponse struct { func (x *RequireFreshAccountSessionResponse) Reset() { *x = RequireFreshAccountSessionResponse{} - mi := &file_state_v1_account_proto_msgTypes[36] + mi := &file_state_v1_account_proto_msgTypes[38] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1780,7 +1884,7 @@ func (x *RequireFreshAccountSessionResponse) String() string { func (*RequireFreshAccountSessionResponse) ProtoMessage() {} func (x *RequireFreshAccountSessionResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[36] + mi := &file_state_v1_account_proto_msgTypes[38] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1793,7 +1897,7 @@ func (x *RequireFreshAccountSessionResponse) ProtoReflect() protoreflect.Message // Deprecated: Use RequireFreshAccountSessionResponse.ProtoReflect.Descriptor instead. func (*RequireFreshAccountSessionResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{36} + return file_state_v1_account_proto_rawDescGZIP(), []int{38} } type CreateAccountRecoveryRequest struct { @@ -1804,7 +1908,7 @@ type CreateAccountRecoveryRequest struct { func (x *CreateAccountRecoveryRequest) Reset() { *x = CreateAccountRecoveryRequest{} - mi := &file_state_v1_account_proto_msgTypes[37] + mi := &file_state_v1_account_proto_msgTypes[39] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1816,7 +1920,7 @@ func (x *CreateAccountRecoveryRequest) String() string { func (*CreateAccountRecoveryRequest) ProtoMessage() {} func (x *CreateAccountRecoveryRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[37] + mi := &file_state_v1_account_proto_msgTypes[39] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1829,7 +1933,7 @@ func (x *CreateAccountRecoveryRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateAccountRecoveryRequest.ProtoReflect.Descriptor instead. func (*CreateAccountRecoveryRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{37} + return file_state_v1_account_proto_rawDescGZIP(), []int{39} } type CreateAccountRecoveryResponse struct { @@ -1841,7 +1945,7 @@ type CreateAccountRecoveryResponse struct { func (x *CreateAccountRecoveryResponse) Reset() { *x = CreateAccountRecoveryResponse{} - mi := &file_state_v1_account_proto_msgTypes[38] + mi := &file_state_v1_account_proto_msgTypes[40] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1853,7 +1957,7 @@ func (x *CreateAccountRecoveryResponse) String() string { func (*CreateAccountRecoveryResponse) ProtoMessage() {} func (x *CreateAccountRecoveryResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[38] + mi := &file_state_v1_account_proto_msgTypes[40] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1866,7 +1970,7 @@ func (x *CreateAccountRecoveryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CreateAccountRecoveryResponse.ProtoReflect.Descriptor instead. func (*CreateAccountRecoveryResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{38} + return file_state_v1_account_proto_rawDescGZIP(), []int{40} } func (x *CreateAccountRecoveryResponse) GetCode() string { @@ -1887,7 +1991,7 @@ type RecoverAccountRequest struct { func (x *RecoverAccountRequest) Reset() { *x = RecoverAccountRequest{} - mi := &file_state_v1_account_proto_msgTypes[39] + mi := &file_state_v1_account_proto_msgTypes[41] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1899,7 +2003,7 @@ func (x *RecoverAccountRequest) String() string { func (*RecoverAccountRequest) ProtoMessage() {} func (x *RecoverAccountRequest) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[39] + mi := &file_state_v1_account_proto_msgTypes[41] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1912,7 +2016,7 @@ func (x *RecoverAccountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RecoverAccountRequest.ProtoReflect.Descriptor instead. func (*RecoverAccountRequest) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{39} + return file_state_v1_account_proto_rawDescGZIP(), []int{41} } func (x *RecoverAccountRequest) GetEmail() string { @@ -1944,7 +2048,7 @@ type RecoverAccountResponse struct { func (x *RecoverAccountResponse) Reset() { *x = RecoverAccountResponse{} - mi := &file_state_v1_account_proto_msgTypes[40] + mi := &file_state_v1_account_proto_msgTypes[42] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1956,7 +2060,7 @@ func (x *RecoverAccountResponse) String() string { func (*RecoverAccountResponse) ProtoMessage() {} func (x *RecoverAccountResponse) ProtoReflect() protoreflect.Message { - mi := &file_state_v1_account_proto_msgTypes[40] + mi := &file_state_v1_account_proto_msgTypes[42] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1969,7 +2073,7 @@ func (x *RecoverAccountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RecoverAccountResponse.ProtoReflect.Descriptor instead. func (*RecoverAccountResponse) Descriptor() ([]byte, []int) { - return file_state_v1_account_proto_rawDescGZIP(), []int{40} + return file_state_v1_account_proto_rawDescGZIP(), []int{42} } var File_state_v1_account_proto protoreflect.FileDescriptor @@ -1997,7 +2101,15 @@ const file_state_v1_account_proto_rawDesc = "" + "\x06tokens\x18\x01 \x03(\v2\x17.state.v1.PersonalTokenR\x06tokens\",\n" + "\x1aRevokePersonalTokenRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\"\x1d\n" + - "\x1bRevokePersonalTokenResponse\"\x15\n" + + "\x1bRevokePersonalTokenResponse\"\xa2\x01\n" + + " BindIdentityPersonalTokenRequest\x12\x1f\n" + + "\videntity_id\x18\x01 \x01(\tR\n" + + "identityId\x12\x0e\n" + + "\x02id\x18\x02 \x01(\tR\x02id\x12\x12\n" + + "\x04name\x18\x03 \x01(\tR\x04name\x129\n" + + "\n" + + "expires_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\"#\n" + + "!BindIdentityPersonalTokenResponse\"\x15\n" + "\x13AccountSetupRequest\"2\n" + "\x14AccountSetupResponse\x12\x1a\n" + "\brequired\x18\x01 \x01(\bR\brequired\"\x92\x02\n" + @@ -2089,7 +2201,7 @@ const file_state_v1_account_proto_rawDesc = "" + "\x05email\x18\x01 \x01(\tR\x05email\x12\x12\n" + "\x04code\x18\x02 \x01(\tR\x04code\x12\x1a\n" + "\bpassword\x18\x03 \x01(\tR\bpassword\"\x18\n" + - "\x16RecoverAccountResponse2\x9c\x0e\n" + + "\x16RecoverAccountResponse2\x92\x0f\n" + "\x0eAccountService\x12t\n" + "\x19GetAuthenticationSettings\x12*.state.v1.GetAuthenticationSettingsRequest\x1a+.state.v1.GetAuthenticationSettingsResponse\x12w\n" + "\x1aSaveAuthenticationSettings\x12+.state.v1.SaveAuthenticationSettingsRequest\x1a,.state.v1.SaveAuthenticationSettingsResponse\x12M\n" + @@ -2109,7 +2221,8 @@ const file_state_v1_account_proto_rawDesc = "" + "\x15ChangeAccountPassword\x12&.state.v1.ChangeAccountPasswordRequest\x1a'.state.v1.ChangeAccountPasswordResponse\x12Y\n" + "\x10AddPersonalToken\x12!.state.v1.AddPersonalTokenRequest\x1a\".state.v1.AddPersonalTokenResponse\x12_\n" + "\x12ListPersonalTokens\x12#.state.v1.ListPersonalTokensRequest\x1a$.state.v1.ListPersonalTokensResponse\x12b\n" + - "\x13RevokePersonalToken\x12$.state.v1.RevokePersonalTokenRequest\x1a%.state.v1.RevokePersonalTokenResponseB\xa6\x01\n" + + "\x13RevokePersonalToken\x12$.state.v1.RevokePersonalTokenRequest\x1a%.state.v1.RevokePersonalTokenResponse\x12t\n" + + "\x19BindIdentityPersonalToken\x12*.state.v1.BindIdentityPersonalTokenRequest\x1a+.state.v1.BindIdentityPersonalTokenResponseB\xa6\x01\n" + "\fcom.state.v1B\fAccountProtoP\x01ZGgithub.com/samcharles93/archie-core/internal/contracts/state/v1;statev1\xa2\x02\x03SXX\xaa\x02\bState.V1\xca\x02\bState\\V1\xe2\x02\x14State\\V1\\GPBMetadata\xea\x02\tState::V1b\x06proto3" var ( @@ -2124,7 +2237,7 @@ func file_state_v1_account_proto_rawDescGZIP() []byte { return file_state_v1_account_proto_rawDescData } -var file_state_v1_account_proto_msgTypes = make([]protoimpl.MessageInfo, 41) +var file_state_v1_account_proto_msgTypes = make([]protoimpl.MessageInfo, 43) var file_state_v1_account_proto_goTypes = []any{ (*PersonalToken)(nil), // 0: state.v1.PersonalToken (*AddPersonalTokenRequest)(nil), // 1: state.v1.AddPersonalTokenRequest @@ -2133,104 +2246,109 @@ var file_state_v1_account_proto_goTypes = []any{ (*ListPersonalTokensResponse)(nil), // 4: state.v1.ListPersonalTokensResponse (*RevokePersonalTokenRequest)(nil), // 5: state.v1.RevokePersonalTokenRequest (*RevokePersonalTokenResponse)(nil), // 6: state.v1.RevokePersonalTokenResponse - (*AccountSetupRequest)(nil), // 7: state.v1.AccountSetupRequest - (*AccountSetupResponse)(nil), // 8: state.v1.AccountSetupResponse - (*RegisterAccountRequest)(nil), // 9: state.v1.RegisterAccountRequest - (*RegisterAccountResponse)(nil), // 10: state.v1.RegisterAccountResponse - (*SignInAccountRequest)(nil), // 11: state.v1.SignInAccountRequest - (*SignInAccountResponse)(nil), // 12: state.v1.SignInAccountResponse - (*ResolveAccountSessionRequest)(nil), // 13: state.v1.ResolveAccountSessionRequest - (*ResolveAccountSessionResponse)(nil), // 14: state.v1.ResolveAccountSessionResponse - (*SignOutAccountRequest)(nil), // 15: state.v1.SignOutAccountRequest - (*SignOutAccountResponse)(nil), // 16: state.v1.SignOutAccountResponse - (*ChangeAccountPasswordRequest)(nil), // 17: state.v1.ChangeAccountPasswordRequest - (*ChangeAccountPasswordResponse)(nil), // 18: state.v1.ChangeAccountPasswordResponse - (*AuthenticationSettings)(nil), // 19: state.v1.AuthenticationSettings - (*GetAuthenticationSettingsRequest)(nil), // 20: state.v1.GetAuthenticationSettingsRequest - (*GetAuthenticationSettingsResponse)(nil), // 21: state.v1.GetAuthenticationSettingsResponse - (*SaveAuthenticationSettingsRequest)(nil), // 22: state.v1.SaveAuthenticationSettingsRequest - (*SaveAuthenticationSettingsResponse)(nil), // 23: state.v1.SaveAuthenticationSettingsResponse - (*BeginPasskeyRequest)(nil), // 24: state.v1.BeginPasskeyRequest - (*BeginPasskeyResponse)(nil), // 25: state.v1.BeginPasskeyResponse - (*FinishPasskeyRequest)(nil), // 26: state.v1.FinishPasskeyRequest - (*FinishPasskeyResponse)(nil), // 27: state.v1.FinishPasskeyResponse - (*Passkey)(nil), // 28: state.v1.Passkey - (*ListPasskeysRequest)(nil), // 29: state.v1.ListPasskeysRequest - (*ListPasskeysResponse)(nil), // 30: state.v1.ListPasskeysResponse - (*DeletePasskeyRequest)(nil), // 31: state.v1.DeletePasskeyRequest - (*DeletePasskeyResponse)(nil), // 32: state.v1.DeletePasskeyResponse - (*OpenAccountSessionRequest)(nil), // 33: state.v1.OpenAccountSessionRequest - (*OpenAccountSessionResponse)(nil), // 34: state.v1.OpenAccountSessionResponse - (*RequireFreshAccountSessionRequest)(nil), // 35: state.v1.RequireFreshAccountSessionRequest - (*RequireFreshAccountSessionResponse)(nil), // 36: state.v1.RequireFreshAccountSessionResponse - (*CreateAccountRecoveryRequest)(nil), // 37: state.v1.CreateAccountRecoveryRequest - (*CreateAccountRecoveryResponse)(nil), // 38: state.v1.CreateAccountRecoveryResponse - (*RecoverAccountRequest)(nil), // 39: state.v1.RecoverAccountRequest - (*RecoverAccountResponse)(nil), // 40: state.v1.RecoverAccountResponse - (*timestamppb.Timestamp)(nil), // 41: google.protobuf.Timestamp - (*Identity)(nil), // 42: state.v1.Identity + (*BindIdentityPersonalTokenRequest)(nil), // 7: state.v1.BindIdentityPersonalTokenRequest + (*BindIdentityPersonalTokenResponse)(nil), // 8: state.v1.BindIdentityPersonalTokenResponse + (*AccountSetupRequest)(nil), // 9: state.v1.AccountSetupRequest + (*AccountSetupResponse)(nil), // 10: state.v1.AccountSetupResponse + (*RegisterAccountRequest)(nil), // 11: state.v1.RegisterAccountRequest + (*RegisterAccountResponse)(nil), // 12: state.v1.RegisterAccountResponse + (*SignInAccountRequest)(nil), // 13: state.v1.SignInAccountRequest + (*SignInAccountResponse)(nil), // 14: state.v1.SignInAccountResponse + (*ResolveAccountSessionRequest)(nil), // 15: state.v1.ResolveAccountSessionRequest + (*ResolveAccountSessionResponse)(nil), // 16: state.v1.ResolveAccountSessionResponse + (*SignOutAccountRequest)(nil), // 17: state.v1.SignOutAccountRequest + (*SignOutAccountResponse)(nil), // 18: state.v1.SignOutAccountResponse + (*ChangeAccountPasswordRequest)(nil), // 19: state.v1.ChangeAccountPasswordRequest + (*ChangeAccountPasswordResponse)(nil), // 20: state.v1.ChangeAccountPasswordResponse + (*AuthenticationSettings)(nil), // 21: state.v1.AuthenticationSettings + (*GetAuthenticationSettingsRequest)(nil), // 22: state.v1.GetAuthenticationSettingsRequest + (*GetAuthenticationSettingsResponse)(nil), // 23: state.v1.GetAuthenticationSettingsResponse + (*SaveAuthenticationSettingsRequest)(nil), // 24: state.v1.SaveAuthenticationSettingsRequest + (*SaveAuthenticationSettingsResponse)(nil), // 25: state.v1.SaveAuthenticationSettingsResponse + (*BeginPasskeyRequest)(nil), // 26: state.v1.BeginPasskeyRequest + (*BeginPasskeyResponse)(nil), // 27: state.v1.BeginPasskeyResponse + (*FinishPasskeyRequest)(nil), // 28: state.v1.FinishPasskeyRequest + (*FinishPasskeyResponse)(nil), // 29: state.v1.FinishPasskeyResponse + (*Passkey)(nil), // 30: state.v1.Passkey + (*ListPasskeysRequest)(nil), // 31: state.v1.ListPasskeysRequest + (*ListPasskeysResponse)(nil), // 32: state.v1.ListPasskeysResponse + (*DeletePasskeyRequest)(nil), // 33: state.v1.DeletePasskeyRequest + (*DeletePasskeyResponse)(nil), // 34: state.v1.DeletePasskeyResponse + (*OpenAccountSessionRequest)(nil), // 35: state.v1.OpenAccountSessionRequest + (*OpenAccountSessionResponse)(nil), // 36: state.v1.OpenAccountSessionResponse + (*RequireFreshAccountSessionRequest)(nil), // 37: state.v1.RequireFreshAccountSessionRequest + (*RequireFreshAccountSessionResponse)(nil), // 38: state.v1.RequireFreshAccountSessionResponse + (*CreateAccountRecoveryRequest)(nil), // 39: state.v1.CreateAccountRecoveryRequest + (*CreateAccountRecoveryResponse)(nil), // 40: state.v1.CreateAccountRecoveryResponse + (*RecoverAccountRequest)(nil), // 41: state.v1.RecoverAccountRequest + (*RecoverAccountResponse)(nil), // 42: state.v1.RecoverAccountResponse + (*timestamppb.Timestamp)(nil), // 43: google.protobuf.Timestamp + (*Identity)(nil), // 44: state.v1.Identity } var file_state_v1_account_proto_depIdxs = []int32{ - 41, // 0: state.v1.PersonalToken.created_at:type_name -> google.protobuf.Timestamp - 41, // 1: state.v1.PersonalToken.expires_at:type_name -> google.protobuf.Timestamp - 41, // 2: state.v1.PersonalToken.last_used_at:type_name -> google.protobuf.Timestamp - 41, // 3: state.v1.AddPersonalTokenRequest.expires_at:type_name -> google.protobuf.Timestamp + 43, // 0: state.v1.PersonalToken.created_at:type_name -> google.protobuf.Timestamp + 43, // 1: state.v1.PersonalToken.expires_at:type_name -> google.protobuf.Timestamp + 43, // 2: state.v1.PersonalToken.last_used_at:type_name -> google.protobuf.Timestamp + 43, // 3: state.v1.AddPersonalTokenRequest.expires_at:type_name -> google.protobuf.Timestamp 0, // 4: state.v1.ListPersonalTokensResponse.tokens:type_name -> state.v1.PersonalToken - 42, // 5: state.v1.RegisterAccountResponse.identity:type_name -> state.v1.Identity - 42, // 6: state.v1.SignInAccountResponse.identity:type_name -> state.v1.Identity - 41, // 7: state.v1.SignInAccountResponse.expires_at:type_name -> google.protobuf.Timestamp - 42, // 8: state.v1.ResolveAccountSessionResponse.identity:type_name -> state.v1.Identity - 19, // 9: state.v1.GetAuthenticationSettingsResponse.settings:type_name -> state.v1.AuthenticationSettings - 19, // 10: state.v1.SaveAuthenticationSettingsRequest.settings:type_name -> state.v1.AuthenticationSettings - 42, // 11: state.v1.FinishPasskeyResponse.identity:type_name -> state.v1.Identity - 41, // 12: state.v1.FinishPasskeyResponse.expires_at:type_name -> google.protobuf.Timestamp - 28, // 13: state.v1.ListPasskeysResponse.passkeys:type_name -> state.v1.Passkey - 41, // 14: state.v1.OpenAccountSessionRequest.expires_at:type_name -> google.protobuf.Timestamp - 42, // 15: state.v1.OpenAccountSessionResponse.identity:type_name -> state.v1.Identity - 41, // 16: state.v1.OpenAccountSessionResponse.expires_at:type_name -> google.protobuf.Timestamp - 20, // 17: state.v1.AccountService.GetAuthenticationSettings:input_type -> state.v1.GetAuthenticationSettingsRequest - 22, // 18: state.v1.AccountService.SaveAuthenticationSettings:input_type -> state.v1.SaveAuthenticationSettingsRequest - 24, // 19: state.v1.AccountService.BeginPasskey:input_type -> state.v1.BeginPasskeyRequest - 26, // 20: state.v1.AccountService.FinishPasskey:input_type -> state.v1.FinishPasskeyRequest - 29, // 21: state.v1.AccountService.ListPasskeys:input_type -> state.v1.ListPasskeysRequest - 31, // 22: state.v1.AccountService.DeletePasskey:input_type -> state.v1.DeletePasskeyRequest - 33, // 23: state.v1.AccountService.OpenAccountSession:input_type -> state.v1.OpenAccountSessionRequest - 35, // 24: state.v1.AccountService.RequireFreshAccountSession:input_type -> state.v1.RequireFreshAccountSessionRequest - 37, // 25: state.v1.AccountService.CreateAccountRecovery:input_type -> state.v1.CreateAccountRecoveryRequest - 39, // 26: state.v1.AccountService.RecoverAccount:input_type -> state.v1.RecoverAccountRequest - 7, // 27: state.v1.AccountService.AccountSetup:input_type -> state.v1.AccountSetupRequest - 9, // 28: state.v1.AccountService.RegisterAccount:input_type -> state.v1.RegisterAccountRequest - 11, // 29: state.v1.AccountService.SignInAccount:input_type -> state.v1.SignInAccountRequest - 13, // 30: state.v1.AccountService.ResolveAccountSession:input_type -> state.v1.ResolveAccountSessionRequest - 15, // 31: state.v1.AccountService.SignOutAccount:input_type -> state.v1.SignOutAccountRequest - 17, // 32: state.v1.AccountService.ChangeAccountPassword:input_type -> state.v1.ChangeAccountPasswordRequest - 1, // 33: state.v1.AccountService.AddPersonalToken:input_type -> state.v1.AddPersonalTokenRequest - 3, // 34: state.v1.AccountService.ListPersonalTokens:input_type -> state.v1.ListPersonalTokensRequest - 5, // 35: state.v1.AccountService.RevokePersonalToken:input_type -> state.v1.RevokePersonalTokenRequest - 21, // 36: state.v1.AccountService.GetAuthenticationSettings:output_type -> state.v1.GetAuthenticationSettingsResponse - 23, // 37: state.v1.AccountService.SaveAuthenticationSettings:output_type -> state.v1.SaveAuthenticationSettingsResponse - 25, // 38: state.v1.AccountService.BeginPasskey:output_type -> state.v1.BeginPasskeyResponse - 27, // 39: state.v1.AccountService.FinishPasskey:output_type -> state.v1.FinishPasskeyResponse - 30, // 40: state.v1.AccountService.ListPasskeys:output_type -> state.v1.ListPasskeysResponse - 32, // 41: state.v1.AccountService.DeletePasskey:output_type -> state.v1.DeletePasskeyResponse - 34, // 42: state.v1.AccountService.OpenAccountSession:output_type -> state.v1.OpenAccountSessionResponse - 36, // 43: state.v1.AccountService.RequireFreshAccountSession:output_type -> state.v1.RequireFreshAccountSessionResponse - 38, // 44: state.v1.AccountService.CreateAccountRecovery:output_type -> state.v1.CreateAccountRecoveryResponse - 40, // 45: state.v1.AccountService.RecoverAccount:output_type -> state.v1.RecoverAccountResponse - 8, // 46: state.v1.AccountService.AccountSetup:output_type -> state.v1.AccountSetupResponse - 10, // 47: state.v1.AccountService.RegisterAccount:output_type -> state.v1.RegisterAccountResponse - 12, // 48: state.v1.AccountService.SignInAccount:output_type -> state.v1.SignInAccountResponse - 14, // 49: state.v1.AccountService.ResolveAccountSession:output_type -> state.v1.ResolveAccountSessionResponse - 16, // 50: state.v1.AccountService.SignOutAccount:output_type -> state.v1.SignOutAccountResponse - 18, // 51: state.v1.AccountService.ChangeAccountPassword:output_type -> state.v1.ChangeAccountPasswordResponse - 2, // 52: state.v1.AccountService.AddPersonalToken:output_type -> state.v1.AddPersonalTokenResponse - 4, // 53: state.v1.AccountService.ListPersonalTokens:output_type -> state.v1.ListPersonalTokensResponse - 6, // 54: state.v1.AccountService.RevokePersonalToken:output_type -> state.v1.RevokePersonalTokenResponse - 36, // [36:55] is the sub-list for method output_type - 17, // [17:36] is the sub-list for method input_type - 17, // [17:17] is the sub-list for extension type_name - 17, // [17:17] is the sub-list for extension extendee - 0, // [0:17] is the sub-list for field type_name + 43, // 5: state.v1.BindIdentityPersonalTokenRequest.expires_at:type_name -> google.protobuf.Timestamp + 44, // 6: state.v1.RegisterAccountResponse.identity:type_name -> state.v1.Identity + 44, // 7: state.v1.SignInAccountResponse.identity:type_name -> state.v1.Identity + 43, // 8: state.v1.SignInAccountResponse.expires_at:type_name -> google.protobuf.Timestamp + 44, // 9: state.v1.ResolveAccountSessionResponse.identity:type_name -> state.v1.Identity + 21, // 10: state.v1.GetAuthenticationSettingsResponse.settings:type_name -> state.v1.AuthenticationSettings + 21, // 11: state.v1.SaveAuthenticationSettingsRequest.settings:type_name -> state.v1.AuthenticationSettings + 44, // 12: state.v1.FinishPasskeyResponse.identity:type_name -> state.v1.Identity + 43, // 13: state.v1.FinishPasskeyResponse.expires_at:type_name -> google.protobuf.Timestamp + 30, // 14: state.v1.ListPasskeysResponse.passkeys:type_name -> state.v1.Passkey + 43, // 15: state.v1.OpenAccountSessionRequest.expires_at:type_name -> google.protobuf.Timestamp + 44, // 16: state.v1.OpenAccountSessionResponse.identity:type_name -> state.v1.Identity + 43, // 17: state.v1.OpenAccountSessionResponse.expires_at:type_name -> google.protobuf.Timestamp + 22, // 18: state.v1.AccountService.GetAuthenticationSettings:input_type -> state.v1.GetAuthenticationSettingsRequest + 24, // 19: state.v1.AccountService.SaveAuthenticationSettings:input_type -> state.v1.SaveAuthenticationSettingsRequest + 26, // 20: state.v1.AccountService.BeginPasskey:input_type -> state.v1.BeginPasskeyRequest + 28, // 21: state.v1.AccountService.FinishPasskey:input_type -> state.v1.FinishPasskeyRequest + 31, // 22: state.v1.AccountService.ListPasskeys:input_type -> state.v1.ListPasskeysRequest + 33, // 23: state.v1.AccountService.DeletePasskey:input_type -> state.v1.DeletePasskeyRequest + 35, // 24: state.v1.AccountService.OpenAccountSession:input_type -> state.v1.OpenAccountSessionRequest + 37, // 25: state.v1.AccountService.RequireFreshAccountSession:input_type -> state.v1.RequireFreshAccountSessionRequest + 39, // 26: state.v1.AccountService.CreateAccountRecovery:input_type -> state.v1.CreateAccountRecoveryRequest + 41, // 27: state.v1.AccountService.RecoverAccount:input_type -> state.v1.RecoverAccountRequest + 9, // 28: state.v1.AccountService.AccountSetup:input_type -> state.v1.AccountSetupRequest + 11, // 29: state.v1.AccountService.RegisterAccount:input_type -> state.v1.RegisterAccountRequest + 13, // 30: state.v1.AccountService.SignInAccount:input_type -> state.v1.SignInAccountRequest + 15, // 31: state.v1.AccountService.ResolveAccountSession:input_type -> state.v1.ResolveAccountSessionRequest + 17, // 32: state.v1.AccountService.SignOutAccount:input_type -> state.v1.SignOutAccountRequest + 19, // 33: state.v1.AccountService.ChangeAccountPassword:input_type -> state.v1.ChangeAccountPasswordRequest + 1, // 34: state.v1.AccountService.AddPersonalToken:input_type -> state.v1.AddPersonalTokenRequest + 3, // 35: state.v1.AccountService.ListPersonalTokens:input_type -> state.v1.ListPersonalTokensRequest + 5, // 36: state.v1.AccountService.RevokePersonalToken:input_type -> state.v1.RevokePersonalTokenRequest + 7, // 37: state.v1.AccountService.BindIdentityPersonalToken:input_type -> state.v1.BindIdentityPersonalTokenRequest + 23, // 38: state.v1.AccountService.GetAuthenticationSettings:output_type -> state.v1.GetAuthenticationSettingsResponse + 25, // 39: state.v1.AccountService.SaveAuthenticationSettings:output_type -> state.v1.SaveAuthenticationSettingsResponse + 27, // 40: state.v1.AccountService.BeginPasskey:output_type -> state.v1.BeginPasskeyResponse + 29, // 41: state.v1.AccountService.FinishPasskey:output_type -> state.v1.FinishPasskeyResponse + 32, // 42: state.v1.AccountService.ListPasskeys:output_type -> state.v1.ListPasskeysResponse + 34, // 43: state.v1.AccountService.DeletePasskey:output_type -> state.v1.DeletePasskeyResponse + 36, // 44: state.v1.AccountService.OpenAccountSession:output_type -> state.v1.OpenAccountSessionResponse + 38, // 45: state.v1.AccountService.RequireFreshAccountSession:output_type -> state.v1.RequireFreshAccountSessionResponse + 40, // 46: state.v1.AccountService.CreateAccountRecovery:output_type -> state.v1.CreateAccountRecoveryResponse + 42, // 47: state.v1.AccountService.RecoverAccount:output_type -> state.v1.RecoverAccountResponse + 10, // 48: state.v1.AccountService.AccountSetup:output_type -> state.v1.AccountSetupResponse + 12, // 49: state.v1.AccountService.RegisterAccount:output_type -> state.v1.RegisterAccountResponse + 14, // 50: state.v1.AccountService.SignInAccount:output_type -> state.v1.SignInAccountResponse + 16, // 51: state.v1.AccountService.ResolveAccountSession:output_type -> state.v1.ResolveAccountSessionResponse + 18, // 52: state.v1.AccountService.SignOutAccount:output_type -> state.v1.SignOutAccountResponse + 20, // 53: state.v1.AccountService.ChangeAccountPassword:output_type -> state.v1.ChangeAccountPasswordResponse + 2, // 54: state.v1.AccountService.AddPersonalToken:output_type -> state.v1.AddPersonalTokenResponse + 4, // 55: state.v1.AccountService.ListPersonalTokens:output_type -> state.v1.ListPersonalTokensResponse + 6, // 56: state.v1.AccountService.RevokePersonalToken:output_type -> state.v1.RevokePersonalTokenResponse + 8, // 57: state.v1.AccountService.BindIdentityPersonalToken:output_type -> state.v1.BindIdentityPersonalTokenResponse + 38, // [38:58] is the sub-list for method output_type + 18, // [18:38] is the sub-list for method input_type + 18, // [18:18] is the sub-list for extension type_name + 18, // [18:18] is the sub-list for extension extendee + 0, // [0:18] is the sub-list for field type_name } func init() { file_state_v1_account_proto_init() } @@ -2245,7 +2363,7 @@ func file_state_v1_account_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_state_v1_account_proto_rawDesc), len(file_state_v1_account_proto_rawDesc)), NumEnums: 0, - NumMessages: 41, + NumMessages: 43, NumExtensions: 0, NumServices: 1, }, diff --git a/internal/contracts/state/v1/account_grpc.pb.go b/internal/contracts/state/v1/account_grpc.pb.go index 86c7f67e0..667fee1c9 100644 --- a/internal/contracts/state/v1/account_grpc.pb.go +++ b/internal/contracts/state/v1/account_grpc.pb.go @@ -38,6 +38,7 @@ const ( AccountService_AddPersonalToken_FullMethodName = "/state.v1.AccountService/AddPersonalToken" AccountService_ListPersonalTokens_FullMethodName = "/state.v1.AccountService/ListPersonalTokens" AccountService_RevokePersonalToken_FullMethodName = "/state.v1.AccountService/RevokePersonalToken" + AccountService_BindIdentityPersonalToken_FullMethodName = "/state.v1.AccountService/BindIdentityPersonalToken" ) // AccountServiceClient is the client API for AccountService service. @@ -65,6 +66,12 @@ type AccountServiceClient interface { AddPersonalToken(ctx context.Context, in *AddPersonalTokenRequest, opts ...grpc.CallOption) (*AddPersonalTokenResponse, error) ListPersonalTokens(ctx context.Context, in *ListPersonalTokensRequest, opts ...grpc.CallOption) (*ListPersonalTokensResponse, error) RevokePersonalToken(ctx context.Context, in *RevokePersonalTokenRequest, opts ...grpc.CallOption) (*RevokePersonalTokenResponse, error) + // BindIdentityPersonalToken binds a personal token to a NAMED identity + // instead of the caller's principal, which is how a service account gets + // its bearer credential. Only non-user targets are accepted: a person's + // token comes from AddPersonalToken. The audit actor is the caller's + // principal, never a request field. + BindIdentityPersonalToken(ctx context.Context, in *BindIdentityPersonalTokenRequest, opts ...grpc.CallOption) (*BindIdentityPersonalTokenResponse, error) } type accountServiceClient struct { @@ -265,6 +272,16 @@ func (c *accountServiceClient) RevokePersonalToken(ctx context.Context, in *Revo return out, nil } +func (c *accountServiceClient) BindIdentityPersonalToken(ctx context.Context, in *BindIdentityPersonalTokenRequest, opts ...grpc.CallOption) (*BindIdentityPersonalTokenResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(BindIdentityPersonalTokenResponse) + err := c.cc.Invoke(ctx, AccountService_BindIdentityPersonalToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // AccountServiceServer is the server API for AccountService service. // All implementations must embed UnimplementedAccountServiceServer // for forward compatibility. @@ -290,6 +307,12 @@ type AccountServiceServer interface { AddPersonalToken(context.Context, *AddPersonalTokenRequest) (*AddPersonalTokenResponse, error) ListPersonalTokens(context.Context, *ListPersonalTokensRequest) (*ListPersonalTokensResponse, error) RevokePersonalToken(context.Context, *RevokePersonalTokenRequest) (*RevokePersonalTokenResponse, error) + // BindIdentityPersonalToken binds a personal token to a NAMED identity + // instead of the caller's principal, which is how a service account gets + // its bearer credential. Only non-user targets are accepted: a person's + // token comes from AddPersonalToken. The audit actor is the caller's + // principal, never a request field. + BindIdentityPersonalToken(context.Context, *BindIdentityPersonalTokenRequest) (*BindIdentityPersonalTokenResponse, error) mustEmbedUnimplementedAccountServiceServer() } @@ -357,6 +380,9 @@ func (UnimplementedAccountServiceServer) ListPersonalTokens(context.Context, *Li func (UnimplementedAccountServiceServer) RevokePersonalToken(context.Context, *RevokePersonalTokenRequest) (*RevokePersonalTokenResponse, error) { return nil, status.Error(codes.Unimplemented, "method RevokePersonalToken not implemented") } +func (UnimplementedAccountServiceServer) BindIdentityPersonalToken(context.Context, *BindIdentityPersonalTokenRequest) (*BindIdentityPersonalTokenResponse, error) { + return nil, status.Error(codes.Unimplemented, "method BindIdentityPersonalToken not implemented") +} func (UnimplementedAccountServiceServer) mustEmbedUnimplementedAccountServiceServer() {} func (UnimplementedAccountServiceServer) testEmbeddedByValue() {} @@ -720,6 +746,24 @@ func _AccountService_RevokePersonalToken_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } +func _AccountService_BindIdentityPersonalToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BindIdentityPersonalTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AccountServiceServer).BindIdentityPersonalToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AccountService_BindIdentityPersonalToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AccountServiceServer).BindIdentityPersonalToken(ctx, req.(*BindIdentityPersonalTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + // AccountService_ServiceDesc is the grpc.ServiceDesc for AccountService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -803,6 +847,10 @@ var AccountService_ServiceDesc = grpc.ServiceDesc{ MethodName: "RevokePersonalToken", Handler: _AccountService_RevokePersonalToken_Handler, }, + { + MethodName: "BindIdentityPersonalToken", + Handler: _AccountService_BindIdentityPersonalToken_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "state/v1/account.proto", diff --git a/internal/domain/access/canary.go b/internal/domain/access/canary.go new file mode 100644 index 000000000..9423e93ed --- /dev/null +++ b/internal/domain/access/canary.go @@ -0,0 +1,29 @@ +package access + +import "github.com/samcharles93/archie-core/internal/domain/org" + +// CanaryGrantID is the ID the canary's scoped grant is known by in the policy +// store and in denial records. A stored policy must not reuse it: the store's +// seeding and the reset command overwrite shipped IDs, and this one is +// installed by the operator from CanaryGrantPolicy's text. +const CanaryGrantID = "org-canary-grant" + +// CanaryGrantPolicy is the grant a CI canary carries instead of instance +// admin: exactly one named identity may read the dashboard's signal surface +// (chat update, alerts, logs, tasks), read and write the update-settings +// resource, and trigger an update install or deferral. Every clause is +// guarded by the resource belonging to the principal's own org, which the +// engine enforces structurally anyway. +func CanaryGrantPolicy(orgID org.OrgID, identityID string) Policy { + text := `permit(principal, action, resource) when { + resource.org == principal.org && + principal == Archie::Identity::"` + identityID + `" && + ( + (action == Archie::Action::"read" && ["dashboard", "task"].contains(resource.kind)) || + (action == Archie::Action::"read" && resource == Archie::Object::"update-settings") || + (action == Archie::Action::"update" && resource == Archie::Object::"update") || + (action == Archie::Action::"manage_identities" && resource == Archie::Object::"update-settings") + ) +};` + return Policy{ID: CanaryGrantID, Level: LevelOrg, OrgID: orgID, Text: text} +} diff --git a/internal/domain/access/canary_test.go b/internal/domain/access/canary_test.go new file mode 100644 index 000000000..fc05e09ea --- /dev/null +++ b/internal/domain/access/canary_test.go @@ -0,0 +1,28 @@ +package access + +import ( + "strings" + "testing" + + "github.com/samcharles93/archie-core/internal/domain/org" +) + +// TestCanaryGrantPolicy pins the shape of the canary grant: it names exactly +// the one identity it is built for, scoped to the org it serves, so a token +// carrying it cannot act as anyone else or reach another org. +func TestCanaryGrantPolicy(t *testing.T) { + p := CanaryGrantPolicy(org.DefaultOrgID, "canary-svc") + if err := p.Validate(); err != nil { + t.Fatalf("Validate: %v", err) + } + if p.ID != CanaryGrantID || p.Level != LevelOrg || p.OrgID != org.DefaultOrgID { + t.Fatalf("policy = %+v, want ID %q at org level in %q", p, CanaryGrantID, org.DefaultOrgID) + } + if !strings.Contains(p.Text, `principal == Archie::Identity::"canary-svc"`) { + t.Fatalf("text does not name the canary identity:\n%s", p.Text) + } + other := CanaryGrantPolicy(org.DefaultOrgID, "another") + if strings.Contains(other.Text, "canary-svc") || !strings.Contains(other.Text, `Archie::Identity::"another"`) { + t.Fatalf("grant for another identity must name that identity only:\n%s", other.Text) + } +} diff --git a/internal/infrastructure/access/engine_test.go b/internal/infrastructure/access/engine_test.go index 47fecda4b..4cb1a69d3 100644 --- a/internal/infrastructure/access/engine_test.go +++ b/internal/infrastructure/access/engine_test.go @@ -112,3 +112,73 @@ func TestWorkspaceEnvironment(t *testing.T) { }) } } + +// TestCanaryGrant pins the scoped canary grant: the one identity it names, with +// no role, may read the signal surface, read and write update-settings, and +// trigger an install -- and nothing else, neither for it nor for anyone else. +func TestCanaryGrant(t *testing.T) { + const canaryID = identity.IdentityID("canary-svc") + grant := access.CanaryGrantPolicy(org.DefaultOrgID, string(canaryID)) + engine := New(append(access.ShippedOrgPolicies(org.DefaultOrgID), grant)) + if len(engine.Problems()) != 0 { + t.Fatalf("problems = %v, want the canary grant to compile", engine.Problems()) + } + canary := access.Principal{IdentityID: canaryID, Org: org.DefaultOrgID} + other := access.Principal{IdentityID: "someone-else", Org: org.DefaultOrgID} + at := func(kind access.ResourceKind, id string) access.Resource { + return access.Resource{Kind: kind, ID: id, Org: org.DefaultOrgID} + } + tests := []struct { + name string + principal access.Principal + action access.Action + resource access.Resource + allowed bool + }{ + {"read the dashboard", canary, access.ActionRead, at(access.KindDashboard, ""), true}, + {"read tasks", canary, access.ActionRead, at(access.KindTask, ""), true}, + {"read one task", canary, access.ActionRead, at(access.KindTask, "7"), true}, + {"read update-settings", canary, access.ActionRead, at(access.KindPolicy, "update-settings"), true}, + {"install an update", canary, access.ActionUpdate, at(access.KindDashboard, "update"), true}, + {"replace update-settings", canary, access.ActionManageIdentities, at(access.KindPolicy, "update-settings"), true}, + {"read a secret", canary, access.ActionReadSecret, at(access.KindSecret, "github-token"), false}, + {"delete a task", canary, access.ActionDelete, at(access.KindTask, "7"), false}, + {"manage policies", canary, access.ActionManagePolicies, at(access.KindPolicy, "org-role-read"), false}, + {"run a workflow", canary, access.ActionRun, at(access.KindWorkflow, "triage"), false}, + {"create anything", canary, access.ActionCreate, at(access.KindTask, ""), false}, + {"update another object", canary, access.ActionUpdate, at(access.KindDashboard, "other"), false}, + {"read another object", canary, access.ActionRead, at(access.KindPolicy, "other-policy"), false}, + {"manage identities on another object", canary, access.ActionManageIdentities, at(access.KindIdentity, "someone-else"), false}, + {"read logs", canary, access.ActionReadLogs, at(access.KindTask, "7"), false}, + {"read the audit feed", canary, access.ActionReadAudit, at(access.KindAudit, ""), false}, + {"a resource of another org", canary, access.ActionRead, access.Resource{Kind: access.KindDashboard, Org: "acme"}, false}, + {"another identity reads the dashboard", other, access.ActionRead, at(access.KindDashboard, ""), false}, + {"another identity installs an update", other, access.ActionUpdate, at(access.KindDashboard, "update"), false}, + {"another identity replaces update-settings", other, access.ActionManageIdentities, at(access.KindPolicy, "update-settings"), false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := engine.Authorize(tt.principal, tt.action, tt.resource, access.Context{}) + if got.Allowed != tt.allowed { + t.Fatalf("allowed = %v, want %v (%+v)", got.Allowed, tt.allowed, got) + } + }) + } +} + +// TestCanaryGrantValidates pins that the canary grant passes the domain's +// structural check and the engine's schema validation, so it can be installed +// through the policy store. +func TestCanaryGrantValidates(t *testing.T) { + grant := access.CanaryGrantPolicy(org.DefaultOrgID, "canary-svc") + if err := grant.Validate(); err != nil { + t.Fatalf("Validate: %v", err) + } + engine := New([]access.Policy{grant}) + if err := engine.Validate(grant); err != nil { + t.Fatalf("engine Validate: %v", err) + } + if len(engine.Problems()) != 0 { + t.Fatalf("problems = %v, want none", engine.Problems()) + } +} diff --git a/internal/infrastructure/staterpc/personal_tokens.go b/internal/infrastructure/staterpc/personal_tokens.go index c2ad1bf74..395aa3347 100644 --- a/internal/infrastructure/staterpc/personal_tokens.go +++ b/internal/infrastructure/staterpc/personal_tokens.go @@ -90,6 +90,40 @@ func (s *accountServer) RevokePersonalToken(ctx context.Context, r *pb.RevokePer return &pb.RevokePersonalTokenResponse{}, nil } +// BindIdentityPersonalToken binds a token to a named non-user identity, the +// credential a service account acts with. The audit actor is the caller's +// principal, so the request never names who did it. +func (s *accountServer) BindIdentityPersonalToken(ctx context.Context, r *pb.BindIdentityPersonalTokenRequest) (*pb.BindIdentityPersonalTokenResponse, error) { + if s.deps.PersonalTokens == nil { + return nil, status.Error(codes.Unavailable, "personal tokens unavailable") + } + if s.deps.Identities == nil { + return nil, status.Error(codes.Unavailable, "identity store unavailable") + } + caller, ok := access.PrincipalFromContext(ctx) + if !ok || caller.IdentityID == "" { + return nil, status.Error(codes.Unauthenticated, "binding an identity token requires a principal") + } + target, err := s.deps.Identities.Get(ctx, identity.IdentityID(r.GetIdentityId())) + if err != nil { + return nil, s.identityStatus(ctx, err) + } + if target.Kind == identity.KindUser { + return nil, s.identityStatus(ctx, fmt.Errorf("%w: personal tokens belong to a signed-in person", identity.ErrInvalid)) + } + if !target.CanAct() { + return nil, s.identityStatus(ctx, fmt.Errorf("%w: identity is not active", identity.ErrIllegalTransition)) + } + subject, err := tokenSubject(r.GetId()) + if err != nil { + return nil, err + } + if err := s.deps.PersonalTokens.BindPersonalToken(ctx, target.ID, subject, r.GetName(), optionalTime(r.GetExpiresAt()), tokenAudit(ctx, caller.IdentityID, "bind", r.GetId())); err != nil { + return nil, s.identityStatus(ctx, err) + } + return &pb.BindIdentityPersonalTokenResponse{}, nil +} + func (c *Client) AddPersonalToken(ctx context.Context, subject identity.Subject, name string, expiresAt *time.Time) error { _, err := c.account.AddPersonalToken(ctx, &pb.AddPersonalTokenRequest{Id: subject.Subject, Name: name, ExpiresAt: optionalTimestamp(expiresAt)}) return identityClientError(err) @@ -115,6 +149,15 @@ func (c *Client) RevokePersonalToken(ctx context.Context, id string) error { return identityClientError(err) } +// BindPersonalToken binds a token to a named identity rather than the caller's +// principal. The audit argument is accepted for the caller-side contract but +// never sent: the store attributes the bind to the caller's own principal, so +// a request cannot claim an actor. +func (c *Client) BindPersonalToken(ctx context.Context, id identity.IdentityID, subject identity.Subject, name string, expiresAt *time.Time, _ identity.Audit) error { + _, err := c.account.BindIdentityPersonalToken(ctx, &pb.BindIdentityPersonalTokenRequest{IdentityId: string(id), Id: subject.Subject, Name: name, ExpiresAt: optionalTimestamp(expiresAt)}) + return identityClientError(err) +} + func optionalTimestamp(t *time.Time) *timestamppb.Timestamp { if t == nil { return nil diff --git a/internal/infrastructure/staterpc/personal_tokens_test.go b/internal/infrastructure/staterpc/personal_tokens_test.go index 5977e097c..3318c752d 100644 --- a/internal/infrastructure/staterpc/personal_tokens_test.go +++ b/internal/infrastructure/staterpc/personal_tokens_test.go @@ -6,6 +6,10 @@ import ( "testing" "time" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + pb "github.com/samcharles93/archie-core/internal/contracts/state/v1" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/identity" @@ -49,3 +53,88 @@ func TestPersonalTokenOwner(t *testing.T) { }) } } + +type bindCalls struct { + identity.PersonalTokenStore + bound bool + id identity.IdentityID + subject identity.Subject + name string + expires *time.Time + audit identity.Audit +} + +func (b *bindCalls) BindPersonalToken(_ context.Context, id identity.IdentityID, subject identity.Subject, name string, expiresAt *time.Time, audit identity.Audit) error { + b.bound, b.id, b.subject, b.name, b.expires, b.audit = true, id, subject, name, expiresAt, audit + return nil +} + +type bindIdentityRepo struct { + identity.Repository + values map[identity.IdentityID]identity.Identity +} + +func (r bindIdentityRepo) Get(_ context.Context, id identity.IdentityID) (identity.Identity, error) { + if value, ok := r.values[id]; ok { + return value, nil + } + return identity.Identity{}, identity.ErrNotFound +} + +// TestBindIdentityPersonalToken pins the named-identity bind: a service +// account gets the token with the caller as audit actor, while a user target, +// an unknown or inactive identity, a malformed token id and a caller with no +// principal are all refused without binding. +func TestBindIdentityPersonalToken(t *testing.T) { + id := strings.Repeat("ab", 32) + sa := identity.Identity{ID: "sa1", Kind: identity.KindServiceAccount, DisplayName: "Canary", Lifecycle: identity.LifecycleActive} + user := identity.Identity{ID: "u1", Kind: identity.KindUser, DisplayName: "Alice", Lifecycle: identity.LifecycleActive} + suspended := identity.Identity{ID: "sa2", Kind: identity.KindBot, DisplayName: "Old", Lifecycle: identity.LifecycleSuspended} + repo := bindIdentityRepo{values: map[identity.IdentityID]identity.Identity{sa.ID: sa, user.ID: user, suspended.ID: suspended}} + tests := []struct { + name string + target identity.IdentityID + tokenID string + noPrincipal bool + wantCode codes.Code + wantBound bool + }{ + {"service account binds with the caller as actor", sa.ID, id, false, codes.OK, true}, + {"user target is refused", user.ID, id, false, codes.FailedPrecondition, false}, + {"unknown identity is refused", "nope", id, false, codes.NotFound, false}, + {"inactive identity is refused", suspended.ID, id, false, codes.FailedPrecondition, false}, + {"malformed token id is refused", sa.ID, "not-hex", false, codes.FailedPrecondition, false}, + {"no principal is refused", sa.ID, id, true, codes.Unauthenticated, false}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + store := &bindCalls{} + s := &accountServer{server: &server{deps: Deps{PersonalTokens: store, Identities: repo}}} + ctx := context.Background() + if !tt.noPrincipal { + ctx = access.WithPrincipal(ctx, access.Principal{IdentityID: "alice"}) + } + expires := time.Now().UTC().Add(30 * 24 * time.Hour).Truncate(time.Second) + _, err := s.BindIdentityPersonalToken(ctx, &pb.BindIdentityPersonalTokenRequest{IdentityId: string(tt.target), Id: tt.tokenID, Name: "ci", ExpiresAt: timestamppb.New(expires)}) + if got := status.Code(err); got != tt.wantCode { + t.Fatalf("code=%v want=%v err=%v", got, tt.wantCode, err) + } + if store.bound != tt.wantBound { + t.Fatalf("bound=%v want=%v", store.bound, tt.wantBound) + } + if !tt.wantBound { + return + } + wantSubject := identity.Subject{Issuer: identity.PersonalTokenIssuer, Subject: id} + if store.id != sa.ID || store.name != "ci" || store.subject != wantSubject { + t.Fatalf("bind id=%q name=%q subject=%+v, want %q %q %+v", store.id, store.name, store.subject, sa.ID, "ci", wantSubject) + } + if store.expires == nil || !store.expires.Equal(expires) { + t.Fatalf("expires=%v want %v", store.expires, expires) + } + if store.audit.ActorID != "alice" || store.audit.RequestID != "personal-token:bind:"+id { + t.Fatalf("audit=%+v, want actor alice request personal-token:bind:", store.audit) + } + }) + } +} diff --git a/internal/webui/accounts.go b/internal/webui/accounts.go index 35d1affc2..e120b7ba8 100644 --- a/internal/webui/accounts.go +++ b/internal/webui/accounts.go @@ -58,8 +58,12 @@ func (s *Server) accountIdentity(r *http.Request) (identity.Identity, error) { func (s *Server) requireAccount(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Any active identity may authenticate: a person, or a service + // account whose bearer token carries a scoped grant. What the + // identity may then do is the policy chain's call, not the + // credential kind's; an inactive identity is refused here. value, err := s.accountIdentity(r) - if err != nil || value.Kind != identity.KindUser || !value.CanAct() { + if err != nil || !value.CanAct() { if err == nil { err = identity.ErrCredentialRejected } diff --git a/internal/webui/accounts_test.go b/internal/webui/accounts_test.go index ff3a1538b..fca0b472f 100644 --- a/internal/webui/accounts_test.go +++ b/internal/webui/accounts_test.go @@ -2,6 +2,7 @@ package webui import ( "context" + "encoding/json" "errors" "net/http" "net/http/httptest" @@ -131,6 +132,149 @@ func TestAccountSessionFailureIsClosed(t *testing.T) { } } +// TestRequireAccountAdmitsAnyActiveIdentity pins the bearer-token gate: any +// active identity -- a person or a service account -- is admitted and rides +// the context as the acting identity, while an inactive one is refused, so a +// scoped service-account token can use the API without being a user. +func TestRequireAccountAdmitsAnyActiveIdentity(t *testing.T) { + tests := []struct { + name string + value identity.Identity + want int + }{ + {"active user", identity.Identity{ID: "u1", Kind: identity.KindUser, DisplayName: "User", Lifecycle: identity.LifecycleActive}, http.StatusOK}, + {"active service account", identity.Identity{ID: "sa1", Kind: identity.KindServiceAccount, DisplayName: "Canary", Lifecycle: identity.LifecycleActive}, http.StatusOK}, + {"active bot", identity.Identity{ID: "b1", Kind: identity.KindBot, DisplayName: "Bot", Lifecycle: identity.LifecycleActive}, http.StatusOK}, + {"suspended user", identity.Identity{ID: "u2", Kind: identity.KindUser, DisplayName: "User", Lifecycle: identity.LifecycleSuspended}, http.StatusUnauthorized}, + {"retired service account", identity.Identity{ID: "sa2", Kind: identity.KindServiceAccount, DisplayName: "Canary", Lifecycle: identity.LifecycleRetired}, http.StatusUnauthorized}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + srv := &Server{ + Authenticate: func(context.Context, string) (identity.Identity, error) { return tt.value, nil }, + } + var acting identity.IdentityID + handler := srv.requireAccount(http.HandlerFunc(func(_ http.ResponseWriter, r *http.Request) { + if value, ok := ActingIdentity(r.Context()); ok { + acting = value.ID + } + })) + req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://archie.example/api/summary", nil) + req.Header.Set("Authorization", "Bearer archie_pat_test") + rec := httptest.NewRecorder() + handler.ServeHTTP(rec, req) + if rec.Code != tt.want { + t.Fatalf("status=%d want=%d body=%s", rec.Code, tt.want, rec.Body.String()) + } + if tt.want == http.StatusOK && acting != tt.value.ID { + t.Fatalf("acting identity = %q, want %q", acting, tt.value.ID) + } + }) + } +} + +// identityRepo answers Get for the identities a test names. +type identityRepo struct { + identity.Repository + values map[identity.IdentityID]identity.Identity +} + +func (s identityRepo) Get(_ context.Context, id identity.IdentityID) (identity.Identity, error) { + value, ok := s.values[id] + if !ok { + return identity.Identity{}, identity.ErrNotFound + } + return value, nil +} + +// identityTokenStore carries both token contracts: the remote caller's view +// (embedded) and the store side, whose BindPersonalToken names an identity. +type identityTokenStore struct { + identity.PersonalTokens + bound bool + id identity.IdentityID + subject identity.Subject + name string +} + +func (s *identityTokenStore) BindPersonalToken(_ context.Context, id identity.IdentityID, subject identity.Subject, name string, _ *time.Time, _ identity.Audit) error { + s.bound, s.id, s.subject, s.name = true, id, subject, name + return nil +} + +func (s *identityTokenStore) SubjectsOf(context.Context, identity.IdentityID, string) ([]identity.PersonalToken, error) { + return nil, nil +} + +func (s *identityTokenStore) UnbindSubject(context.Context, identity.IdentityID, identity.Subject, identity.Audit) error { + return nil +} + +func (s *identityTokenStore) PersonalTokenOf(context.Context, identity.Subject) (identity.PersonalToken, error) { + return identity.PersonalToken{}, identity.ErrNotFound +} + +func (s *identityTokenStore) TouchPersonalToken(context.Context, identity.Subject, time.Time) error { + return nil +} + +// TestIdentityTokenCreate pins the per-identity token route: an active +// service account gets its raw token exactly once and the store binds only +// its hash, while an unknown or inactive identity is refused. +func TestIdentityTokenCreate(t *testing.T) { + active := identity.Identity{ID: "sa1", Kind: identity.KindServiceAccount, DisplayName: "Canary", Lifecycle: identity.LifecycleActive} + suspended := identity.Identity{ID: "sa2", Kind: identity.KindServiceAccount, DisplayName: "Old", Lifecycle: identity.LifecycleSuspended} + tests := []struct { + name, id, body string + want int + }{ + {"active service account", "sa1", `{"name":"ci","days":30}`, http.StatusCreated}, + {"unknown identity", "nope", `{"name":"ci","days":30}`, http.StatusBadRequest}, + {"inactive identity", "sa2", `{"name":"ci","days":30}`, http.StatusConflict}, + {"bad name", "sa1", `{"name":" ","days":30}`, http.StatusBadRequest}, + {"bad lifetime", "sa1", `{"name":"ci","days":10}`, http.StatusBadRequest}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + store := &identityTokenStore{} + srv := &Server{ + Identities: identityRepo{values: map[identity.IdentityID]identity.Identity{active.ID: active, suspended.ID: suspended}}, + PersonalTokens: store, + } + req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "https://archie.example/api/identities/"+tt.id+"/tokens", strings.NewReader(tt.body)) + req.Header.Set("Content-Type", "application/json") + req.SetPathValue("id", tt.id) + rec := httptest.NewRecorder() + srv.handleIdentityTokenCreate(rec, req) + if rec.Code != tt.want { + t.Fatalf("status=%d want=%d body=%s", rec.Code, tt.want, rec.Body.String()) + } + if tt.want != http.StatusCreated { + if store.bound { + t.Fatal("a refused request still bound a token") + } + return + } + var body struct { + ID string `json:"id"` + Token string `json:"token"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatalf("response: %v (%s)", err, rec.Body.String()) + } + if !strings.HasPrefix(body.Token, "archie_pat_") || body.ID == "" { + t.Fatalf("response must show the raw token once: %+v", body) + } + if !store.bound || store.id != active.ID || store.name != "ci" { + t.Fatalf("bound = %+v, want id %q name %q", store, active.ID, "ci") + } + if store.subject.Issuer != identity.PersonalTokenIssuer || store.subject.Subject != body.ID { + t.Fatalf("store kept subject %+v, want the token's hash %q under %q", store.subject, body.ID, identity.PersonalTokenIssuer) + } + }) + } +} + type unavailableAccounts struct{ identity.Accounts } func (unavailableAccounts) AccountSetupRequired(context.Context) (bool, error) { diff --git a/internal/webui/api_identities.go b/internal/webui/api_identities.go index 0ca892ab9..bc54ae0db 100644 --- a/internal/webui/api_identities.go +++ b/internal/webui/api_identities.go @@ -7,12 +7,25 @@ import ( "errors" "net/http" "strings" + "time" "github.com/samcharles93/archie-core/internal/domain/access" "github.com/samcharles93/archie-core/internal/domain/identity" "github.com/samcharles93/archie-core/internal/domain/org" + "github.com/samcharles93/archie-core/internal/infrastructure/staterpc" ) +// identityTokenBinder is the one store-side operation the per-identity token +// route needs: binding a token to a NAMED identity. The remote client's +// caller-scoped PersonalTokens view cannot express that, so the store fronts +// it as its own RPC and the Client carries it under this name. +type identityTokenBinder interface { + BindPersonalToken(ctx context.Context, id identity.IdentityID, subject identity.Subject, name string, expiresAt *time.Time, audit identity.Audit) error +} + +// The production store client satisfies the route's narrow contract. +var _ identityTokenBinder = (*staterpc.Client)(nil) + type identityRequest struct { DisplayName string `json:"display_name"` Kind identity.Kind `json:"kind"` @@ -81,6 +94,59 @@ func (s *Server) handleIdentityCommand(w http.ResponseWriter, r *http.Request) { writeJSON(w, value) } +// handleIdentityTokenCreate issues an API token for one named identity, which +// is how a non-user identity gets its bearer credential: a person's token +// comes from /api/tokens, a service account's from here. The raw token is +// returned exactly once; the store keeps only its hash. +func (s *Server) handleIdentityTokenCreate(w http.ResponseWriter, r *http.Request) { + id := identity.IdentityID(r.PathValue("id")) + if s.Identities == nil { + http.Error(w, "identity store unavailable", http.StatusServiceUnavailable) + return + } + value, err := s.Identities.Get(r.Context(), id) + if errors.Is(err, identity.ErrNotFound) { + http.Error(w, "No such identity.", http.StatusBadRequest) + return + } + if err != nil { + writeIdentityError(w, err) + return + } + if !value.CanAct() { + http.Error(w, "That identity may not act.", http.StatusConflict) + return + } + name, expiresAt, ok := decodeTokenRequest(w, r) + if !ok { + return + } + // The store side of the PersonalTokens contract binds a token to a named + // identity; the remote caller's view only ever names its own principal. + binder, ok := s.PersonalTokens.(identityTokenBinder) + if !ok { + http.Error(w, "identity token binding unavailable", http.StatusServiceUnavailable) + return + } + raw, subject, err := identity.NewPersonalToken() + if err != nil { + http.Error(w, "cannot create token", http.StatusInternalServerError) + return + } + audit, err := webAudit(r.Context()) + if err != nil { + http.Error(w, "cannot create request ID", http.StatusInternalServerError) + return + } + if err := binder.BindPersonalToken(r.Context(), id, subject, name, expiresAt, audit); err != nil { + writeIdentityError(w, err) + return + } + w.Header().Set("Cache-Control", "no-store") + w.WriteHeader(http.StatusCreated) + writeJSON(w, map[string]string{"id": subject.Subject, "token": raw}) +} + // webAudit attributes a dashboard write to the request's own principal: the // person the dashboard acts as. Only a request with no principal at all falls // back to the System identity, which is a real identity the repository diff --git a/internal/webui/api_personal_tokens.go b/internal/webui/api_personal_tokens.go index 7c8925a11..294549032 100644 --- a/internal/webui/api_personal_tokens.go +++ b/internal/webui/api_personal_tokens.go @@ -41,27 +41,8 @@ func (s *Server) handlePersonalTokenCreate(w http.ResponseWriter, r *http.Reques if !s.personalTokensReady(w, r) { return } - var body struct { - Name string `json:"name"` - Days int `json:"days"` - } - if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4<<10)).Decode(&body); err != nil { - http.Error(w, "invalid request", http.StatusBadRequest) - return - } - name := strings.TrimSpace(body.Name) - if name == "" || utf8.RuneCountInString(name) > maxTokenNameLength { - http.Error(w, "Name a token in up to 40 characters.", http.StatusBadRequest) - return - } - var expiresAt *time.Time - switch body.Days { - case 0: - case 7, 30, 90: - t := time.Now().UTC().AddDate(0, 0, body.Days) - expiresAt = &t - default: - http.Error(w, "Lifetime is 7, 30 or 90 days, or none.", http.StatusBadRequest) + name, expiresAt, ok := decodeTokenRequest(w, r) + if !ok { return } raw, subject, err := identity.NewPersonalToken() @@ -78,6 +59,35 @@ func (s *Server) handlePersonalTokenCreate(w http.ResponseWriter, r *http.Reques writeJSON(w, map[string]string{"id": subject.Subject, "token": raw}) } +// decodeTokenRequest reads a token request's name and lifetime, the shape the +// personal-token route and the per-identity token route share. +func decodeTokenRequest(w http.ResponseWriter, r *http.Request) (string, *time.Time, bool) { + var body struct { + Name string `json:"name"` + Days int `json:"days"` + } + if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4<<10)).Decode(&body); err != nil { + http.Error(w, "invalid request", http.StatusBadRequest) + return "", nil, false + } + name := strings.TrimSpace(body.Name) + if name == "" || utf8.RuneCountInString(name) > maxTokenNameLength { + http.Error(w, "Name a token in up to 40 characters.", http.StatusBadRequest) + return "", nil, false + } + var expiresAt *time.Time + switch body.Days { + case 0: + case 7, 30, 90: + t := time.Now().UTC().AddDate(0, 0, body.Days) + expiresAt = &t + default: + http.Error(w, "Lifetime is 7, 30 or 90 days, or none.", http.StatusBadRequest) + return "", nil, false + } + return name, expiresAt, true +} + func (s *Server) handlePersonalTokenRevoke(w http.ResponseWriter, r *http.Request) { if !s.personalTokensReady(w, r) { return diff --git a/internal/webui/authorize.go b/internal/webui/authorize.go index 423830b19..70ee566e2 100644 --- a/internal/webui/authorize.go +++ b/internal/webui/authorize.go @@ -318,16 +318,17 @@ func routeOverride(r *http.Request, action access.Action, path string) (access.A return actionManage(action), access.KindPolicy, segmentValue(path, 2), true case matchPrefix(path, "/api/control-plane/resources"): return controlPlaneResourceRoute(action, path) + case updateCommandRoute(action, path): + // Triggering or deferring an install changes the update object, not + // a workflow run: the dashboard kind carries the update's policy. + return access.ActionUpdate, access.KindDashboard, "update", true case matchPrefix(path, "/api/chat"): return chatRoute(action) case matchSegment(path, "/api/sources/", "/secret"): // Rotating a source's secret hands back its value. return access.ActionReadSecret, access.KindSecret, segmentValue(path, 2), true - case matchPrefix(path, "/api/harness/terminal"): - // Opening the setup terminal updates the binding's secret. - return access.ActionUpdate, access.KindSecret, "", true - case matchPrefix(path, "/api/harness/bindings"): - return access.ActionRead, access.KindSecret, "", true + case matchPrefix(path, "/api/harness/terminal"), matchPrefix(path, "/api/harness/bindings"): + return harnessSecretRoute(path) case matchPrefix(path, "/api/channels"), matchPrefix(path, "/api/config"), matchPrefix(path, "/api/logs"), matchPrefix(path, "/api/tokens"): return dashboardRoute(action, path) @@ -335,6 +336,15 @@ func routeOverride(r *http.Request, action access.Action, path string) (access.A return action, "", "", false } +// harnessSecretRoute maps the harness surfaces, which work with the binding's +// secret: opening the setup terminal updates it, the bindings view reads it. +func harnessSecretRoute(path string) (access.Action, access.ResourceKind, string, bool) { + if matchPrefix(path, "/api/harness/terminal") { + return access.ActionUpdate, access.KindSecret, "", true + } + return access.ActionRead, access.KindSecret, "", true +} + // dashboardRoute maps the dashboard's own routes: channel settings are // instance administration, while config, logs and a person's own tokens act // only as that person, needing no more than a dashboard read. @@ -395,6 +405,13 @@ func orgRouteAction(action access.Action, path string) access.Action { return access.ActionUpdate } +// updateCommandRoute reports whether the request is one of the chat update +// commands, which act on the update object rather than running a workflow. +func updateCommandRoute(action access.Action, path string) bool { + return action == access.ActionCreate && + (path == "/api/chat/update/install" || path == "/api/chat/update/defer") +} + // chatRoute maps a chat request: posting runs a workflow, anything else reads // the dashboard. func chatRoute(action access.Action) (access.Action, access.ResourceKind, string, bool) { diff --git a/internal/webui/authorize_test.go b/internal/webui/authorize_test.go index 835305282..34dc12c40 100644 --- a/internal/webui/authorize_test.go +++ b/internal/webui/authorize_test.go @@ -223,6 +223,35 @@ func TestChannelReloadRoute(t *testing.T) { } } +// TestChatRouteMapping pins the chat routes' actions: posting a message runs a +// workflow, while triggering or deferring an update changes the update object +// on the dashboard kind, so a scoped grant can carry it without any run right. +func TestChatRouteMapping(t *testing.T) { + tests := []struct { + method, path string + action access.Action + kind access.ResourceKind + id string + }{ + {http.MethodPost, "/api/chat/update/install", access.ActionUpdate, access.KindDashboard, "update"}, + {http.MethodPost, "/api/chat/update/defer", access.ActionUpdate, access.KindDashboard, "update"}, + {http.MethodPost, "/api/chat/message", access.ActionRun, access.KindWorkflow, ""}, + {http.MethodPost, "/api/chat/stream", access.ActionRun, access.KindWorkflow, ""}, + {http.MethodPost, "/api/chat/cancel", access.ActionRun, access.KindWorkflow, ""}, + {http.MethodPost, "/api/chat/answer", access.ActionRun, access.KindWorkflow, ""}, + {http.MethodGet, "/api/chat/update", access.ActionRead, access.KindDashboard, ""}, + {http.MethodGet, "/api/chat/sessions", access.ActionRead, access.KindDashboard, ""}, + } + for _, tt := range tests { + t.Run(tt.method+" "+tt.path, func(t *testing.T) { + action, kind, id := accessRequest(httptest.NewRequestWithContext(t.Context(), tt.method, tt.path, nil)) + if action != tt.action || kind != tt.kind || id != tt.id { + t.Fatalf("accessRequest = %q on %q (%q), want %q on %q (%q)", action, kind, id, tt.action, tt.kind, tt.id) + } + }) + } +} + func TestPersonalTokensWithoutPerson(t *testing.T) { for _, method := range []string{http.MethodGet, http.MethodPost, http.MethodDelete} { t.Run(method, func(t *testing.T) { diff --git a/internal/webui/server.go b/internal/webui/server.go index c824b6550..511b542b3 100644 --- a/internal/webui/server.go +++ b/internal/webui/server.go @@ -409,6 +409,7 @@ func (s *Server) registerConfigAndLogRoutes(mux *http.ServeMux) { mux.HandleFunc("DELETE /api/tokens/{id}", s.handlePersonalTokenRevoke) mux.HandleFunc("POST /api/identities", instanceOnly(s.handleIdentityCreate)) mux.HandleFunc("POST /api/identities/{id}/{command}", instanceOnly(s.handleIdentityCommand)) + mux.HandleFunc("POST /api/identities/{id}/tokens", instanceOnly(s.handleIdentityTokenCreate)) mux.HandleFunc("GET /api/config", instanceOnly(s.handleConfig)) mux.HandleFunc("GET /api/secret-engines", instanceOnly(s.handleSecretEngines)) mux.HandleFunc("POST /api/secret-references/check", instanceOnly(s.handleSecretCheck)) diff --git a/proto/state/v1/account.proto b/proto/state/v1/account.proto index a57dcc442..5ebe6e28a 100644 --- a/proto/state/v1/account.proto +++ b/proto/state/v1/account.proto @@ -27,6 +27,12 @@ service AccountService { rpc AddPersonalToken(AddPersonalTokenRequest) returns (AddPersonalTokenResponse); rpc ListPersonalTokens(ListPersonalTokensRequest) returns (ListPersonalTokensResponse); rpc RevokePersonalToken(RevokePersonalTokenRequest) returns (RevokePersonalTokenResponse); + // BindIdentityPersonalToken binds a personal token to a NAMED identity + // instead of the caller's principal, which is how a service account gets + // its bearer credential. Only non-user targets are accepted: a person's + // token comes from AddPersonalToken. The audit actor is the caller's + // principal, never a request field. + rpc BindIdentityPersonalToken(BindIdentityPersonalTokenRequest) returns (BindIdentityPersonalTokenResponse); } // PersonalToken identifies a token by the SHA-256 it binds as; the token @@ -48,6 +54,13 @@ message ListPersonalTokensRequest {} message ListPersonalTokensResponse { repeated PersonalToken tokens = 1; } message RevokePersonalTokenRequest { string id = 1; } message RevokePersonalTokenResponse {} +message BindIdentityPersonalTokenRequest { + string identity_id = 1; + string id = 2; + string name = 3; + google.protobuf.Timestamp expires_at = 4; // unset: never expires +} +message BindIdentityPersonalTokenResponse {} message AccountSetupRequest {} message AccountSetupResponse { bool required = 1; } message RegisterAccountRequest {