external_identity_auth.proto 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. // Desired display name. When omitted, the server uses a valid provider hint
  56. // and otherwise falls back to the requested username.
  57. string display_name = 3 [(buf.validate.field).string.max_len = 32];
  58. }
  59. // Result of creating an account from a pending provider identity.
  60. message CreateExternalIdentityAccountResponse {
  61. // Newly created user ID.
  62. string user_id = 1;
  63. // Newly created username.
  64. string login = 2;
  65. // Short-lived bearer access token for the new session.
  66. string token = 3;
  67. // Rotating refresh credential for renewing the bearer session.
  68. string refresh_token = 4;
  69. // Lifetime of the access token in seconds.
  70. int64 expires_in = 5;
  71. // Remaining lifetime of the current renewable-session window in seconds.
  72. // A successful refresh can advance this window for an active session.
  73. int64 refresh_token_expires_in = 6;
  74. }
  75. // Request to cancel a pending external identity flow.
  76. message CancelExternalIdentityFlowRequest {
  77. // Raw pending flow token.
  78. string token = 1 [(buf.validate.field).string.min_len = 1];
  79. }
  80. // Result of cancelling a pending external identity flow.
  81. message CancelExternalIdentityFlowResponse {
  82. reserved 1;
  83. reserved "cancelled";
  84. }
  85. // Request to confirm a pending provider link using the flow capability token.
  86. message ConfirmExternalIdentityLinkRequest {
  87. // Raw pending link token from the provider callback redirect.
  88. string token = 1 [(buf.validate.field).string.min_len = 1];
  89. }
  90. // Result of confirming a provider identity link.
  91. message ConfirmExternalIdentityLinkResponse {
  92. // Linked identity metadata.
  93. chatto.api.v1.LinkedExternalIdentity linked_identity = 1;
  94. }
  95. // Public external identity authentication operations.
  96. service ExternalIdentityAuthService {
  97. // Reads safe metadata for a pending create/link flow. This public RPC
  98. // requires a valid pending-flow capability token and returns NOT_FOUND when
  99. // the token is unknown or expired.
  100. rpc GetPendingExternalIdentity(GetPendingExternalIdentityRequest) returns (GetPendingExternalIdentityResponse);
  101. // Creates a passwordless account from a pending provider identity. This
  102. // public RPC requires a valid create-flow capability token.
  103. rpc CreateExternalIdentityAccount(CreateExternalIdentityAccountRequest) returns (CreateExternalIdentityAccountResponse);
  104. // Links a provider identity using a pending link-flow capability token. This
  105. // public RPC requires a valid link-flow capability token.
  106. rpc ConfirmExternalIdentityLink(ConfirmExternalIdentityLinkRequest) returns (ConfirmExternalIdentityLinkResponse);
  107. // Cancels a pending provider identity flow. This public RPC requires a valid
  108. // pending-flow capability token.
  109. rpc CancelExternalIdentityFlow(CancelExternalIdentityFlowRequest) returns (CancelExternalIdentityFlowResponse);
  110. }