/
auth.proto
67 lines (57 loc) 路 1.74 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
/**
* MIT License
* Copyright (c) 2021 Fonoster Inc
*
* The Auth proto contains procedures to obtain authentication
* data.
*/
syntax = "proto3";
package fonos.auth.v1beta1;
option go_package = "github.com/fonoster/fonos/mods/auth/fonos/services/protos/auth";
import "protoc-gen-openapiv2/options/annotations.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
service Auth {
// Gets a role by name
rpc GetRole (GetRoleRequest) returns (Role) {
option (google.api.http) = { get: "/v1beta1/auth/role/{name}" };
};
// Verifies if a token was issue by Fonos
rpc ValidateToken (ValidateTokenRequest) returns (ValidateTokenResponse) {
option (google.api.http) = { get: "/v1beta1/auth/token/{token}" };
}
// Creates a new token for a given accessKeyId
rpc CreateToken (CreateTokenRequest) returns (CreateTokenResponse) {
option (google.api.http) = {
get: "/v1beta1/auth/token"
body: "*"
};
}
// Creates a special token that has no access but serves a signature
rpc CreateNoAccessToken (CreateTokenRequest) returns (CreateTokenResponse) {}
}
message GetRoleRequest {
string name = 1;
}
message Role {
string name = 1;
string description = 2;
repeated string access = 3;
}
message ValidateTokenRequest {
string token = 1;
}
message ValidateTokenResponse {
bool valid = 1;
}
message CreateTokenRequest {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_schema) = {
example: "{\"roleName\": \"USER\", \"accessKeyId\": \"4e9f2cdf4387\"}"
};
string role_name = 1 [(google.api.field_behavior) = REQUIRED];
string access_key_id = 2 [(google.api.field_behavior) = REQUIRED];
string expiration = 3;
}
message CreateTokenResponse {
string token = 1;
}