external_identity_auth.proto 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. syntax = "proto3";
  2. package chatto.auth.v1;
  3. import "buf/validate/validate.proto";
  4. import "chatto/api/v1/external_identities.proto";
  5. // Mode of a pending external identity confirmation flow.
  6. enum ExternalIdentityFlowKind {
  7. // The flow kind was not specified.
  8. EXTERNAL_IDENTITY_FLOW_KIND_UNSPECIFIED = 0;
  9. // Create a new passwordless account and link the provider identity.
  10. EXTERNAL_IDENTITY_FLOW_KIND_CREATE_ACCOUNT = 1;
  11. // Link the provider identity to the authenticated account.
  12. EXTERNAL_IDENTITY_FLOW_KIND_LINK_ACCOUNT = 2;
  13. }
  14. // Metadata about a pending external identity flow. The provider subject is not
  15. // exposed; clients only need user-facing provider/profile hints.
  16. message PendingExternalIdentity {
  17. // Pending flow kind.
  18. ExternalIdentityFlowKind kind = 1;
  19. // Provider ID that produced the identity.
  20. string provider_id = 2;
  21. // Provider type that produced the identity.
  22. string provider_type = 3;
  23. // Provider label shown to the user.
  24. string provider_label = 4;
  25. // Verified email supplied by the provider, when available.
  26. string verified_email = 5;
  27. // Suggested username derived from provider profile hints.
  28. string login_hint = 6;
  29. // Suggested display name derived from provider profile hints.
  30. string display_name_hint = 7;
  31. // User ID this link flow is bound to. Empty for create flows.
  32. string bound_user_id = 8;
  33. // Internal path the client should return to after confirmation.
  34. string redirect_path = 9;
  35. }
  36. // Request to inspect a pending external identity flow.
  37. message GetPendingExternalIdentityRequest {
  38. // Raw pending flow token from the provider callback redirect.
  39. string token = 1 [(buf.validate.field).string.min_len = 1];
  40. }
  41. // Result of inspecting a pending external identity flow.
  42. message GetPendingExternalIdentityResponse {
  43. // Pending flow metadata.
  44. PendingExternalIdentity pending = 1;
  45. }
  46. // Request to create a new passwordless account from a pending provider identity.
  47. message CreateExternalIdentityAccountRequest {
  48. // Raw pending create token from the provider callback redirect.
  49. string token = 1 [(buf.validate.field).string.min_len = 1];
  50. // Desired username.
  51. string login = 2 [(buf.validate.field).string = {
  52. min_len: 2
  53. max_len: 32
  54. }];
  55. }
  56. // Result of creating an account from a pending provider identity.
  57. message CreateExternalIdentityAccountResponse {
  58. // Newly created user ID.
  59. string user_id = 1;
  60. // Newly created username.
  61. string login = 2;
  62. // Bearer token for the new session.
  63. string token = 3;
  64. }
  65. // Request to cancel a pending external identity flow.
  66. message CancelExternalIdentityFlowRequest {
  67. // Raw pending flow token.
  68. string token = 1 [(buf.validate.field).string.min_len = 1];
  69. }
  70. // Result of cancelling a pending external identity flow.
  71. message CancelExternalIdentityFlowResponse {
  72. // True when a pending flow was removed or already absent.
  73. bool cancelled = 1;
  74. }
  75. // Request to confirm a pending provider link using the flow capability token.
  76. message ConfirmExternalIdentityLinkRequest {
  77. // Raw pending link token from the provider callback redirect.
  78. string token = 1 [(buf.validate.field).string.min_len = 1];
  79. }
  80. // Result of confirming a provider identity link.
  81. message ConfirmExternalIdentityLinkResponse {
  82. // Linked identity metadata.
  83. chatto.api.v1.LinkedExternalIdentity linked_identity = 1;
  84. }
  85. // Public external identity authentication operations.
  86. service ExternalIdentityAuthService {
  87. // Reads safe metadata for a pending create/link flow. This public RPC
  88. // requires a valid pending-flow capability token and returns NOT_FOUND when
  89. // the token is unknown or expired.
  90. rpc GetPendingExternalIdentity(GetPendingExternalIdentityRequest) returns (GetPendingExternalIdentityResponse);
  91. // Creates a passwordless account from a pending provider identity. This
  92. // public RPC requires a valid create-flow capability token.
  93. rpc CreateExternalIdentityAccount(CreateExternalIdentityAccountRequest) returns (CreateExternalIdentityAccountResponse);
  94. // Links a provider identity using a pending link-flow capability token. This
  95. // public RPC requires a valid link-flow capability token.
  96. rpc ConfirmExternalIdentityLink(ConfirmExternalIdentityLinkRequest) returns (ConfirmExternalIdentityLinkResponse);
  97. // Cancels a pending provider identity flow. This public RPC requires a valid
  98. // pending-flow capability token.
  99. rpc CancelExternalIdentityFlow(CancelExternalIdentityFlowRequest) returns (CancelExternalIdentityFlowResponse);
  100. }