feat(identity): name, lifetime and last-used on personal API tokens

This commit is contained in:
sam committed 2026-10-27 15:37:44 +11:00
1 parent 3210e30ce4
commit 91be2114cf
23 files changed
+449 -99

No files matched your search

+110 -59
View File
@@ -28,6 +28,9 @@ type PersonalToken struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,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
LastUsedAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=last_used_at,json=lastUsedAt,proto3" json:"last_used_at,omitempty"` // unset: never used
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -76,9 +79,32 @@ func (x *PersonalToken) GetCreatedAt() *timestamppb.Timestamp {
return nil
}
func (x *PersonalToken) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *PersonalToken) GetExpiresAt() *timestamppb.Timestamp {
if x != nil {
return x.ExpiresAt
}
return nil
}
func (x *PersonalToken) GetLastUsedAt() *timestamppb.Timestamp {
if x != nil {
return x.LastUsedAt
}
return nil
}
type AddPersonalTokenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"` // unset: never expires
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -120,6 +146,20 @@ func (x *AddPersonalTokenRequest) GetId() string {
return ""
}
func (x *AddPersonalTokenRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *AddPersonalTokenRequest) GetExpiresAt() *timestamppb.Timestamp {
if x != nil {
return x.ExpiresAt
}
return nil
}
type AddPersonalTokenResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -1936,13 +1976,21 @@ var File_state_v1_account_proto protoreflect.FileDescriptor
const file_state_v1_account_proto_rawDesc = "" +
"\n" +
"\x16state/v1/account.proto\x12\bstate.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x14state/v1/types.proto\"Z\n" +
"\x16state/v1/account.proto\x12\bstate.v1\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x14state/v1/types.proto\"\xe7\x01\n" +
"\rPersonalToken\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x129\n" +
"\n" +
"created_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\")\n" +
"created_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12\x12\n" +
"\x04name\x18\x03 \x01(\tR\x04name\x129\n" +
"\n" +
"expires_at\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x12<\n" +
"\flast_used_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
"lastUsedAt\"x\n" +
"\x17AddPersonalTokenRequest\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\"\x1a\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x129\n" +
"\n" +
"expires_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\"\x1a\n" +
"\x18AddPersonalTokenResponse\"\x1b\n" +
"\x19ListPersonalTokensRequest\"M\n" +
"\x1aListPersonalTokensResponse\x12/\n" +
@@ -2124,62 +2172,65 @@ var file_state_v1_account_proto_goTypes = []any{
}
var file_state_v1_account_proto_depIdxs = []int32{
41, // 0: state.v1.PersonalToken.created_at:type_name -> google.protobuf.Timestamp
0, // 1: state.v1.ListPersonalTokensResponse.tokens:type_name -> state.v1.PersonalToken
42, // 2: state.v1.RegisterAccountResponse.identity:type_name -> state.v1.Identity
42, // 3: state.v1.SignInAccountResponse.identity:type_name -> state.v1.Identity
41, // 4: state.v1.SignInAccountResponse.expires_at:type_name -> google.protobuf.Timestamp
42, // 5: state.v1.ResolveAccountSessionResponse.identity:type_name -> state.v1.Identity
19, // 6: state.v1.GetAuthenticationSettingsResponse.settings:type_name -> state.v1.AuthenticationSettings
19, // 7: state.v1.SaveAuthenticationSettingsRequest.settings:type_name -> state.v1.AuthenticationSettings
42, // 8: state.v1.FinishPasskeyResponse.identity:type_name -> state.v1.Identity
41, // 9: state.v1.FinishPasskeyResponse.expires_at:type_name -> google.protobuf.Timestamp
28, // 10: state.v1.ListPasskeysResponse.passkeys:type_name -> state.v1.Passkey
41, // 11: state.v1.OpenAccountSessionRequest.expires_at:type_name -> google.protobuf.Timestamp
42, // 12: state.v1.OpenAccountSessionResponse.identity:type_name -> state.v1.Identity
41, // 13: state.v1.OpenAccountSessionResponse.expires_at:type_name -> google.protobuf.Timestamp
20, // 14: state.v1.AccountService.GetAuthenticationSettings:input_type -> state.v1.GetAuthenticationSettingsRequest
22, // 15: state.v1.AccountService.SaveAuthenticationSettings:input_type -> state.v1.SaveAuthenticationSettingsRequest
24, // 16: state.v1.AccountService.BeginPasskey:input_type -> state.v1.BeginPasskeyRequest
26, // 17: state.v1.AccountService.FinishPasskey:input_type -> state.v1.FinishPasskeyRequest
29, // 18: state.v1.AccountService.ListPasskeys:input_type -> state.v1.ListPasskeysRequest
31, // 19: state.v1.AccountService.DeletePasskey:input_type -> state.v1.DeletePasskeyRequest
33, // 20: state.v1.AccountService.OpenAccountSession:input_type -> state.v1.OpenAccountSessionRequest
35, // 21: state.v1.AccountService.RequireFreshAccountSession:input_type -> state.v1.RequireFreshAccountSessionRequest
37, // 22: state.v1.AccountService.CreateAccountRecovery:input_type -> state.v1.CreateAccountRecoveryRequest
39, // 23: state.v1.AccountService.RecoverAccount:input_type -> state.v1.RecoverAccountRequest
7, // 24: state.v1.AccountService.AccountSetup:input_type -> state.v1.AccountSetupRequest
9, // 25: state.v1.AccountService.RegisterAccount:input_type -> state.v1.RegisterAccountRequest
11, // 26: state.v1.AccountService.SignInAccount:input_type -> state.v1.SignInAccountRequest
13, // 27: state.v1.AccountService.ResolveAccountSession:input_type -> state.v1.ResolveAccountSessionRequest
15, // 28: state.v1.AccountService.SignOutAccount:input_type -> state.v1.SignOutAccountRequest
17, // 29: state.v1.AccountService.ChangeAccountPassword:input_type -> state.v1.ChangeAccountPasswordRequest
1, // 30: state.v1.AccountService.AddPersonalToken:input_type -> state.v1.AddPersonalTokenRequest
3, // 31: state.v1.AccountService.ListPersonalTokens:input_type -> state.v1.ListPersonalTokensRequest
5, // 32: state.v1.AccountService.RevokePersonalToken:input_type -> state.v1.RevokePersonalTokenRequest
21, // 33: state.v1.AccountService.GetAuthenticationSettings:output_type -> state.v1.GetAuthenticationSettingsResponse
23, // 34: state.v1.AccountService.SaveAuthenticationSettings:output_type -> state.v1.SaveAuthenticationSettingsResponse
25, // 35: state.v1.AccountService.BeginPasskey:output_type -> state.v1.BeginPasskeyResponse
27, // 36: state.v1.AccountService.FinishPasskey:output_type -> state.v1.FinishPasskeyResponse
30, // 37: state.v1.AccountService.ListPasskeys:output_type -> state.v1.ListPasskeysResponse
32, // 38: state.v1.AccountService.DeletePasskey:output_type -> state.v1.DeletePasskeyResponse
34, // 39: state.v1.AccountService.OpenAccountSession:output_type -> state.v1.OpenAccountSessionResponse
36, // 40: state.v1.AccountService.RequireFreshAccountSession:output_type -> state.v1.RequireFreshAccountSessionResponse
38, // 41: state.v1.AccountService.CreateAccountRecovery:output_type -> state.v1.CreateAccountRecoveryResponse
40, // 42: state.v1.AccountService.RecoverAccount:output_type -> state.v1.RecoverAccountResponse
8, // 43: state.v1.AccountService.AccountSetup:output_type -> state.v1.AccountSetupResponse
10, // 44: state.v1.AccountService.RegisterAccount:output_type -> state.v1.RegisterAccountResponse
12, // 45: state.v1.AccountService.SignInAccount:output_type -> state.v1.SignInAccountResponse
14, // 46: state.v1.AccountService.ResolveAccountSession:output_type -> state.v1.ResolveAccountSessionResponse
16, // 47: state.v1.AccountService.SignOutAccount:output_type -> state.v1.SignOutAccountResponse
18, // 48: state.v1.AccountService.ChangeAccountPassword:output_type -> state.v1.ChangeAccountPasswordResponse
2, // 49: state.v1.AccountService.AddPersonalToken:output_type -> state.v1.AddPersonalTokenResponse
4, // 50: state.v1.AccountService.ListPersonalTokens:output_type -> state.v1.ListPersonalTokensResponse
6, // 51: state.v1.AccountService.RevokePersonalToken:output_type -> state.v1.RevokePersonalTokenResponse
33, // [33:52] is the sub-list for method output_type
14, // [14:33] is the sub-list for method input_type
14, // [14:14] is the sub-list for extension type_name
14, // [14:14] is the sub-list for extension extendee
0, // [0:14] is the sub-list for field type_name
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
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
}
func init() { file_state_v1_account_proto_init() }