This repository has been archived by the owner on Jun 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauth.proto
85 lines (68 loc) · 2.15 KB
/
auth.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
syntax = "proto3";
package codectrl.auth_service;
option go_package = "github.com/Authentura/codectrl-go-protobufs/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) {}
}