-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprincipal.proto
130 lines (120 loc) · 3.5 KB
/
principal.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright 2021 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
package cacheroach.principal;
import "capabilities.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
option go_package = "github.com/bobvawter/cacheroach/api/principal";
message ID {
bytes data = 1;
}
enum TokenStatus {
// The token has not (yet) been validated.
UNKNOWN = 0;
// The token should be considered valid until the refresh_after time.
VALID = 1;
// The token is being refreshed by another instance. It should be
// considered valid until the listed refresh time, at which point it
// should be refreshed again.
REFRESHING = 2;
// The token could not be revalidated and no further attempts should
// be made.
PERMANENT_FAILURE = 3;
}
message Principal {
option (capabilities.msg_rule).or = {
rule: {direction: RESPONSE}
rule: {
message: "must be able to read the principal"
may: {
capabilities: {read: true}
scope: {on_principal: {field: 1}}
}}
};
ID ID = 1;
string label = 2;
int64 version = 3;
// OIDC claims as provided by an authentication server.
bytes claims = 4 [
(capabilities.field_rule) = {
message: "must have pii access"
or : {
rule: {
and: {
rule: {direction: REQUEST}
rule : {auth_status: SUPER}
}
}
rule: {
and: {
rule: {direction: RESPONSE}
rule: {may: {
capabilities: {pii: true}
scope: {on_principal: {field: 1}}
}}
}
}
}
}
];
// If present, indicates that the principal represents all users whose
// email address are in the given domain.
string email_domain = 5;
string refresh_token = 66 [
(capabilities.field_rule).never = true
];
google.protobuf.Timestamp refresh_after = 67 [
(capabilities.field_rule).never = true
];
TokenStatus refresh_status = 68 [
(capabilities.field_rule).never = true
];
}
message LoadRequest {
oneof Kind {
// Load a Principal based on ID.
ID ID = 1;
// Load a Principal by email address.
string email = 2;
// Load a domain-level Principal.
string email_domain = 3;
}
}
message WatchRequest {
ID principal = 1;
google.protobuf.Duration duration = 2;
}
message EnsureRequest {
Principal principal = 1;
bool delete = 2;
}
message EnsureResponse {
Principal principal = 1;
}
service Principals {
rpc Ensure (EnsureRequest) returns (EnsureResponse) {
option idempotency_level = IDEMPOTENT;
}
rpc List (google.protobuf.Empty) returns (stream Principal) {
option idempotency_level = NO_SIDE_EFFECTS;
}
rpc Load (LoadRequest) returns (Principal) {
option idempotency_level = NO_SIDE_EFFECTS;
option (capabilities.method_rule).auth_status = LOGGED_IN;
}
rpc Watch (WatchRequest) returns (stream Principal) {
option idempotency_level = NO_SIDE_EFFECTS;
}
}