Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial prototype of desired API #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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
Loading