syntax = "proto3"; package codectrl.auth_service; import "google/protobuf/empty.proto"; enum TokenIntent { LOGGER = 0; FRONTEND = 1; } message Name { string inner = 1; } message TokenPermissions { bool read = 1; bool write = 2; } message Token { Name name = 1; TokenPermissions permissions = 2; TokenIntent intent = 3; } message GenerateTokenRequest { Name name = 1; TokenIntent intent = 2; } message VerifyTokenRequest { Token token = 1; TokenIntent intent = 2; } enum VerifyTokenRequestResultEnum { UNAUTHORISED = 0; NOTFOUND = 1; AUTHORISED = 2; } message VerifyTokenRequestResult { string message = 1; VerifyTokenRequestResultEnum status = 2; } enum GenerateTokenRequestResultEnum { NAME_ALREADY_EXISTS = 0; // If another token under this name is already present. TOKEN_ALREADY_EXISTS = 1; // If the exact token is already present. TOKEN_GENERATION_SUCCEEDED = 2; // If the token was successfully added. } enum RevokeTokenRequestResultEnum { TOKEN_NOT_FOUND = 0; // If the token is not found. TOKEN_REVOKATION_SUCCEEDED = 1; // If the token was successfully added. } message RevokeTokenRequestResult { string message = 1; RevokeTokenRequestResultEnum status = 2; } message GenerateTokenRequestResult { GenerateTokenRequestResultEnum status = 1; optional Token token = 2; } message LoginUrl{ string url = 1; } service Authentication { // Takes a token and verifies that it is: // a) In valid format // b) Present in the database/filesystem (down to implementation) // c) Has the correct permissions for the given intent rpc VerifyToken(VerifyTokenRequest) returns (VerifyTokenRequestResult) {} rpc GenerateToken(GenerateTokenRequest) returns (GenerateTokenRequestResult) {} rpc RevokeToken(Token) returns (RevokeTokenRequestResult) {} rpc RefreshToken(Token) returns (Token) {} rpc GithubLogin(google.protobuf.Empty) returns (LoginUrl) {} }