Skip to content

Commit

Permalink
Initial prototype of desired API
Browse files Browse the repository at this point in the history
  • Loading branch information
y9vad9 committed Jun 10, 2024
1 parent ae64089 commit b751f8f
Show file tree
Hide file tree
Showing 53 changed files with 426 additions and 264 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
syntax = "proto3";

import "/timemates/auth/core/requests/ObtainAuthRequest.proto";
import "/timemates/auth/core/requests/GetAuthorizationsRequest.proto";
import "/timemates/auth/core/requests/RenewAuthorizationRequest.proto";
import "/timemates/auth/core/requests/LinkAuthMethodRequest.proto";
import "/timemates/auth/core/types/Authorization.proto";
import "google/protobuf/empty.proto";

option java_package = "org.timemates.api.auth.core";

// Core authentication service responsible for managing user authentication and authorizations.
service CoreAuthService {
// Retrieves the authentication status of the user.
// This method returns the authentication status of the user.
rpc ObtainAuth(ObtainAuthRequest) returns (ObtainAuthRequest.Response);

// Links a new auth method / replaces existing with the given one that was used in the
// auth session.
rpc LinkAuthMethod(LinkAuthMethodRequest) returns (LinkAuthMethodRequest.Response);

// Creates a new authorization from refresh token of old authorization that is expired
// or is about to be expired.
rpc RenewAuth(RenewAuthorizationRequest) returns (RenewAuthorizationRequest.Response);

// Gets all active authorizations.
// This method retrieves all active authorizations.
rpc GetAuthList(GetAuthorizationsRequest) returns (GetAuthorizationsRequest.Response);

// Terminates authorization by given identifier.
// This method terminates authorization by the given identifier.
// It returns an empty response upon successful termination.
rpc TerminateAuth(google.protobuf.Empty) returns (google.protobuf.Empty);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto3";

import "/timemates/auth/core/types/Authorization.proto";
import "/timemates/auth/core/types/AuthorizationView.proto";


option java_package = "org.timemates.api.auth.core.requests";

message GetAuthorizationsRequest {
// null if it's start of pagination
optional string pageToken = 1;
optional int32 pageSize = 2;

message Response {
repeated AuthorizationView authorizations = 1;
string nextPageToken = 2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

import "/timemates/auth/core/types/Authorization.proto";

option java_package = "org.timemates.api.auth.core.requests";

message LinkAuthMethodRequest {
// Verification hash obtained in the corresponding service (TelegramAuthService, EmailAuthService)
string verificationHash = 1;
// Access hash of the authorized user that wants to link an auth method
string accessHash = 2;

message Response {
Status status = 1;

enum Status {
// Linking is successful, a new auth method is added or is replaced with.
SUCCESSFULLY_LINKED = 0;
// Linking is failed: given auth method is already linked to the another account.
ALREADY_LINKED = 1;
// Linking is failed: given auth method is
AUTH_IS_NOT_FINISHED = 2;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
syntax = "proto3";

option java_package = "org.timemates.api.auth.core";

import "/timemates/auth/core/types/Authorization.proto";

message ObtainAuthRequest {
string verificationHash = 1;

message Response {
oneof status {
Unfinished unfinished = 1;
Authorized authorized = 2;
Expired expired = 3;
}

message Unfinished {}
message Authorized {
bool hasAccount = 1;
// Authorization is present if [hasAccount] is true.
// Otherwise, client should proceed to profile configuration to obtain authorization.
Authorization authorization = 2;
}
message Expired {}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";

import "org/timemates/api/authorizations/types/Authorization.proto";
import "/timemates/auth/core/types/Authorization.proto";

option java_package = "org.timemates.api.authorizations.requests";
option java_package = "org.timemates.api.auth.requests";

message RenewAuthorizationRequest {
string refreshHash = 1;
Expand Down
Loading

0 comments on commit b751f8f

Please sign in to comment.