This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
auth.proto
208 lines (179 loc) · 5.31 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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package magistrala;
option go_package = "./magistrala";
// AuthzService is a service that provides authentication and authorization
// functionalities for the things service.
service AuthzService {
// Authorize checks if the subject is authorized to perform
// the action on the object.
rpc Authorize(AuthorizeReq) returns (AuthorizeRes) {}
}
// AuthService is a service that provides authentication and authorization
// functionalities for the users service.
service AuthService {
rpc Issue(IssueReq) returns (Token) {}
rpc Refresh(RefreshReq) returns (Token) {}
rpc Identify(IdentityReq) returns (IdentityRes) {}
rpc Authorize(AuthorizeReq) returns (AuthorizeRes) {}
rpc AddPolicy(AddPolicyReq) returns (AddPolicyRes) {}
rpc AddPolicies(AddPoliciesReq) returns (AddPoliciesRes) {}
rpc DeletePolicy(DeletePolicyReq) returns (DeletePolicyRes) {}
rpc DeletePolicies(DeletePoliciesReq) returns (DeletePoliciesRes) {}
rpc ListObjects(ListObjectsReq) returns (ListObjectsRes) {}
rpc ListAllObjects(ListObjectsReq) returns (ListObjectsRes) {}
rpc CountObjects(CountObjectsReq) returns (CountObjectsRes) {}
rpc ListSubjects(ListSubjectsReq) returns (ListSubjectsRes) {}
rpc ListAllSubjects(ListSubjectsReq) returns (ListSubjectsRes) {}
rpc CountSubjects(CountSubjectsReq) returns (CountSubjectsRes) {}
rpc ListPermissions(ListPermissionsReq) returns (ListPermissionsRes) {}
}
// If a token is not carrying any information itself, the type
// field can be used to determine how to validate the token.
// Also, different tokens can be encoded in different ways.
message Token {
string accessToken = 1;
optional string refreshToken = 2;
string accessType = 3;
}
message IdentityReq {
string token = 1;
}
message IdentityRes {
string id = 1; // IMPROVEMENT NOTE: change name from "id" to "subject" , sub in jwt = user id + domain id //
string user_id = 2; // user id
string domain_id = 3; // domain id
}
message IssueReq {
string user_id = 1;
optional string domain_id = 2;
uint32 type = 3;
}
message RefreshReq {
string refresh_token = 1;
optional string domain_id = 2;
}
message AuthorizeReq {
string domain = 1; // Domain
string subject_type = 2; // Thing or User
string subject_kind = 3; // ID or Token
string subject_relation = 4; // Subject relation
string subject = 5; // Subject value (id or token, depending on kind)
string relation = 6; // Relation to filter
string permission = 7; // Action
string object = 8; // Object ID
string object_type = 9; // Thing, User, Group
}
message AuthorizeRes {
bool authorized = 1;
string id = 2;
}
message AddPolicyReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject_kind = 4;
string subject = 5;
string relation = 6;
string permission = 7;
string object = 8;
string object_kind = 9;
string object_type = 10;
}
message AddPoliciesReq{
repeated AddPolicyReq addPoliciesReq= 1;
}
message AddPolicyRes { bool added = 1; }
message AddPoliciesRes { bool added = 1; }
message DeletePolicyReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject_kind = 4;
string subject = 5;
string relation = 6;
string permission = 7;
string object = 8;
string object_kind = 9;
string object_type = 10;
}
message DeletePoliciesReq {
repeated DeletePolicyReq deletePoliciesReq = 1;
}
message DeletePolicyRes { bool deleted = 1; }
message DeletePoliciesRes { bool deleted = 1; }
message ListObjectsReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject = 4;
string relation = 5;
string permission = 6;
string object = 7;
string object_type = 8;
string nextPageToken = 9;
int32 limit = 10;
}
message ListObjectsRes {
repeated string policies = 1;
string nextPageToken = 2;
}
message CountObjectsReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject = 4;
string relation = 5;
string permission = 6;
string object = 7;
string object_type = 8;
string nextPageToken = 9;
}
message CountObjectsRes { int64 count = 1; }
message ListSubjectsReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject = 4;
string relation = 5;
string permission = 6;
string object = 7;
string object_type = 8;
string nextPageToken = 9;
int32 limit = 10;
}
message ListSubjectsRes {
repeated string policies = 1;
string nextPageToken = 2;
}
message CountSubjectsReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject = 4;
string relation = 5;
string permission = 6;
string object = 7;
string object_type = 8;
string nextPageToken = 9;
}
message CountSubjectsRes { int64 count = 1; }
message ListPermissionsReq {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject = 4;
string object = 5;
string object_type = 6;
repeated string filter_permissions = 7;
}
message ListPermissionsRes {
string domain = 1;
string subject_type = 2;
string subject_relation = 3;
string subject = 4;
string object = 5;
string object_type = 6;
repeated string permissions = 7;
}