@acequants/aegis-contracts 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/gen/auth/v1/auth.d.ts +76 -20
- package/dist/src/gen/auth/v1/auth.d.ts.map +1 -1
- package/dist/src/gen/auth/v1/auth.js +254 -24
- package/dist/src/index.js +0 -36
- package/package.json +1 -1
- package/proto/auth/v1/auth.proto +31 -10
|
@@ -2,44 +2,100 @@ import type { handleUnaryCall, UntypedServiceImplementation } from "@grpc/grpc-j
|
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
3
|
import { Observable } from "rxjs";
|
|
4
4
|
export declare const protobufPackage = "aegis.auth.v1";
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export interface AuthContext {
|
|
6
|
+
sessionId: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
email: string;
|
|
9
|
+
/** string tenant_id = 4; */
|
|
10
|
+
roles: string[];
|
|
11
|
+
permissions: string[];
|
|
8
12
|
}
|
|
9
|
-
export interface
|
|
13
|
+
export interface ValidateAccessRequest {
|
|
10
14
|
accessToken: string;
|
|
11
|
-
|
|
15
|
+
ip: string;
|
|
16
|
+
userAgent: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ValidateAccessResponse {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
/** "expired", "revoked", etc. */
|
|
21
|
+
reason: string;
|
|
22
|
+
context?: AuthContext | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface AuthorizeRequest {
|
|
25
|
+
context?: AuthContext | undefined;
|
|
26
|
+
/** e.g. "order.read" */
|
|
27
|
+
policy: string;
|
|
28
|
+
/** resource/user attributes for ABAC */
|
|
29
|
+
attributes: {
|
|
30
|
+
[key: string]: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface AuthorizeRequest_AttributesEntry {
|
|
34
|
+
key: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}
|
|
37
|
+
export interface AuthorizeResponse {
|
|
38
|
+
allowed: boolean;
|
|
39
|
+
reason: string;
|
|
12
40
|
}
|
|
13
41
|
export declare const AEGIS_AUTH_V1_PACKAGE_NAME = "aegis.auth.v1";
|
|
14
|
-
export declare const
|
|
15
|
-
encode(message:
|
|
16
|
-
decode(input: _m0.Reader | Uint8Array, length?: number):
|
|
42
|
+
export declare const AuthContext: {
|
|
43
|
+
encode(message: AuthContext, writer?: _m0.Writer): _m0.Writer;
|
|
44
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): AuthContext;
|
|
45
|
+
};
|
|
46
|
+
export declare const ValidateAccessRequest: {
|
|
47
|
+
encode(message: ValidateAccessRequest, writer?: _m0.Writer): _m0.Writer;
|
|
48
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): ValidateAccessRequest;
|
|
17
49
|
};
|
|
18
|
-
export declare const
|
|
19
|
-
encode(message:
|
|
20
|
-
decode(input: _m0.Reader | Uint8Array, length?: number):
|
|
50
|
+
export declare const ValidateAccessResponse: {
|
|
51
|
+
encode(message: ValidateAccessResponse, writer?: _m0.Writer): _m0.Writer;
|
|
52
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): ValidateAccessResponse;
|
|
53
|
+
};
|
|
54
|
+
export declare const AuthorizeRequest: {
|
|
55
|
+
encode(message: AuthorizeRequest, writer?: _m0.Writer): _m0.Writer;
|
|
56
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): AuthorizeRequest;
|
|
57
|
+
};
|
|
58
|
+
export declare const AuthorizeRequest_AttributesEntry: {
|
|
59
|
+
encode(message: AuthorizeRequest_AttributesEntry, writer?: _m0.Writer): _m0.Writer;
|
|
60
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): AuthorizeRequest_AttributesEntry;
|
|
61
|
+
};
|
|
62
|
+
export declare const AuthorizeResponse: {
|
|
63
|
+
encode(message: AuthorizeResponse, writer?: _m0.Writer): _m0.Writer;
|
|
64
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): AuthorizeResponse;
|
|
21
65
|
};
|
|
22
66
|
export interface AuthServiceClient {
|
|
23
|
-
|
|
67
|
+
validateAccess(request: ValidateAccessRequest): Observable<ValidateAccessResponse>;
|
|
68
|
+
authorize(request: AuthorizeRequest): Observable<AuthorizeResponse>;
|
|
24
69
|
}
|
|
25
70
|
export interface AuthServiceController {
|
|
26
|
-
|
|
71
|
+
validateAccess(request: ValidateAccessRequest): Promise<ValidateAccessResponse> | Observable<ValidateAccessResponse> | ValidateAccessResponse;
|
|
72
|
+
authorize(request: AuthorizeRequest): Promise<AuthorizeResponse> | Observable<AuthorizeResponse> | AuthorizeResponse;
|
|
27
73
|
}
|
|
28
74
|
export declare function AuthServiceControllerMethods(): (constructor: Function) => void;
|
|
29
75
|
export declare const AUTH_SERVICE_NAME = "AuthService";
|
|
30
76
|
export type AuthServiceService = typeof AuthServiceService;
|
|
31
77
|
export declare const AuthServiceService: {
|
|
32
|
-
readonly
|
|
33
|
-
readonly path: "/aegis.auth.v1.AuthService/
|
|
78
|
+
readonly validateAccess: {
|
|
79
|
+
readonly path: "/aegis.auth.v1.AuthService/ValidateAccess";
|
|
80
|
+
readonly requestStream: false;
|
|
81
|
+
readonly responseStream: false;
|
|
82
|
+
readonly requestSerialize: (value: ValidateAccessRequest) => Buffer<ArrayBuffer>;
|
|
83
|
+
readonly requestDeserialize: (value: Buffer) => ValidateAccessRequest;
|
|
84
|
+
readonly responseSerialize: (value: ValidateAccessResponse) => Buffer<ArrayBuffer>;
|
|
85
|
+
readonly responseDeserialize: (value: Buffer) => ValidateAccessResponse;
|
|
86
|
+
};
|
|
87
|
+
readonly authorize: {
|
|
88
|
+
readonly path: "/aegis.auth.v1.AuthService/Authorize";
|
|
34
89
|
readonly requestStream: false;
|
|
35
90
|
readonly responseStream: false;
|
|
36
|
-
readonly requestSerialize: (value:
|
|
37
|
-
readonly requestDeserialize: (value: Buffer) =>
|
|
38
|
-
readonly responseSerialize: (value:
|
|
39
|
-
readonly responseDeserialize: (value: Buffer) =>
|
|
91
|
+
readonly requestSerialize: (value: AuthorizeRequest) => Buffer<ArrayBuffer>;
|
|
92
|
+
readonly requestDeserialize: (value: Buffer) => AuthorizeRequest;
|
|
93
|
+
readonly responseSerialize: (value: AuthorizeResponse) => Buffer<ArrayBuffer>;
|
|
94
|
+
readonly responseDeserialize: (value: Buffer) => AuthorizeResponse;
|
|
40
95
|
};
|
|
41
96
|
};
|
|
42
97
|
export interface AuthServiceServer extends UntypedServiceImplementation {
|
|
43
|
-
|
|
98
|
+
validateAccess: handleUnaryCall<ValidateAccessRequest, ValidateAccessResponse>;
|
|
99
|
+
authorize: handleUnaryCall<AuthorizeRequest, AuthorizeResponse>;
|
|
44
100
|
}
|
|
45
101
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/gen/auth/v1/auth.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAEnF,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../../src/gen/auth/v1/auth.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAEnF,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,eAAO,MAAM,eAAe,kBAAkB,CAAC;AAE/C,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,4B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AAqB;6CACnB,MAAM;4CACP,sBAAsB;8CACpB,MAAM;;;;;;2CAMT,gBAAgB;6CACd,MAAM;4CACP,iBAAiB;8CACf,MAAM;;CAE7B,CAAC;AAEX,MAAM,WAAW,iBAAkB,SAAQ,4BAA4B;IACrE,cAAc,EAAE,eAAe,CAAC,qBAAqB,EAAE,sBAAsB,CAAC,CAAC;IAC/E,SAAS,EAAE,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,CAAC;CACjE"}
|
|
@@ -7,23 +7,32 @@ import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
|
7
7
|
import _m0 from "protobufjs/minimal";
|
|
8
8
|
export const protobufPackage = "aegis.auth.v1";
|
|
9
9
|
export const AEGIS_AUTH_V1_PACKAGE_NAME = "aegis.auth.v1";
|
|
10
|
-
function
|
|
11
|
-
return {
|
|
10
|
+
function createBaseAuthContext() {
|
|
11
|
+
return { sessionId: "", userId: "", email: "", roles: [], permissions: [] };
|
|
12
12
|
}
|
|
13
|
-
export const
|
|
13
|
+
export const AuthContext = {
|
|
14
14
|
encode(message, writer = _m0.Writer.create()) {
|
|
15
|
-
if (message.
|
|
16
|
-
writer.uint32(10).string(message.
|
|
15
|
+
if (message.sessionId !== "") {
|
|
16
|
+
writer.uint32(10).string(message.sessionId);
|
|
17
17
|
}
|
|
18
|
-
if (message.
|
|
19
|
-
writer.uint32(18).string(message.
|
|
18
|
+
if (message.userId !== "") {
|
|
19
|
+
writer.uint32(18).string(message.userId);
|
|
20
|
+
}
|
|
21
|
+
if (message.email !== "") {
|
|
22
|
+
writer.uint32(26).string(message.email);
|
|
23
|
+
}
|
|
24
|
+
for (const v of message.roles) {
|
|
25
|
+
writer.uint32(34).string(v);
|
|
26
|
+
}
|
|
27
|
+
for (const v of message.permissions) {
|
|
28
|
+
writer.uint32(42).string(v);
|
|
20
29
|
}
|
|
21
30
|
return writer;
|
|
22
31
|
},
|
|
23
32
|
decode(input, length) {
|
|
24
33
|
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
25
34
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
26
|
-
const message =
|
|
35
|
+
const message = createBaseAuthContext();
|
|
27
36
|
while (reader.pos < end) {
|
|
28
37
|
const tag = reader.uint32();
|
|
29
38
|
switch (tag >>> 3) {
|
|
@@ -31,13 +40,31 @@ export const LoginRequest = {
|
|
|
31
40
|
if (tag !== 10) {
|
|
32
41
|
break;
|
|
33
42
|
}
|
|
34
|
-
message.
|
|
43
|
+
message.sessionId = reader.string();
|
|
35
44
|
continue;
|
|
36
45
|
case 2:
|
|
37
46
|
if (tag !== 18) {
|
|
38
47
|
break;
|
|
39
48
|
}
|
|
40
|
-
message.
|
|
49
|
+
message.userId = reader.string();
|
|
50
|
+
continue;
|
|
51
|
+
case 3:
|
|
52
|
+
if (tag !== 26) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
message.email = reader.string();
|
|
56
|
+
continue;
|
|
57
|
+
case 4:
|
|
58
|
+
if (tag !== 34) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
message.roles.push(reader.string());
|
|
62
|
+
continue;
|
|
63
|
+
case 5:
|
|
64
|
+
if (tag !== 42) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
message.permissions.push(reader.string());
|
|
41
68
|
continue;
|
|
42
69
|
}
|
|
43
70
|
if ((tag & 7) === 4 || tag === 0) {
|
|
@@ -48,23 +75,26 @@ export const LoginRequest = {
|
|
|
48
75
|
return message;
|
|
49
76
|
},
|
|
50
77
|
};
|
|
51
|
-
function
|
|
52
|
-
return { accessToken: "",
|
|
78
|
+
function createBaseValidateAccessRequest() {
|
|
79
|
+
return { accessToken: "", ip: "", userAgent: "" };
|
|
53
80
|
}
|
|
54
|
-
export const
|
|
81
|
+
export const ValidateAccessRequest = {
|
|
55
82
|
encode(message, writer = _m0.Writer.create()) {
|
|
56
83
|
if (message.accessToken !== "") {
|
|
57
84
|
writer.uint32(10).string(message.accessToken);
|
|
58
85
|
}
|
|
59
|
-
if (message.
|
|
60
|
-
writer.uint32(18).string(message.
|
|
86
|
+
if (message.ip !== "") {
|
|
87
|
+
writer.uint32(18).string(message.ip);
|
|
88
|
+
}
|
|
89
|
+
if (message.userAgent !== "") {
|
|
90
|
+
writer.uint32(26).string(message.userAgent);
|
|
61
91
|
}
|
|
62
92
|
return writer;
|
|
63
93
|
},
|
|
64
94
|
decode(input, length) {
|
|
65
95
|
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
66
96
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
67
|
-
const message =
|
|
97
|
+
const message = createBaseValidateAccessRequest();
|
|
68
98
|
while (reader.pos < end) {
|
|
69
99
|
const tag = reader.uint32();
|
|
70
100
|
switch (tag >>> 3) {
|
|
@@ -78,7 +108,198 @@ export const LoginResponse = {
|
|
|
78
108
|
if (tag !== 18) {
|
|
79
109
|
break;
|
|
80
110
|
}
|
|
81
|
-
message.
|
|
111
|
+
message.ip = reader.string();
|
|
112
|
+
continue;
|
|
113
|
+
case 3:
|
|
114
|
+
if (tag !== 26) {
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
message.userAgent = reader.string();
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
reader.skipType(tag & 7);
|
|
124
|
+
}
|
|
125
|
+
return message;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
function createBaseValidateAccessResponse() {
|
|
129
|
+
return { valid: false, reason: "" };
|
|
130
|
+
}
|
|
131
|
+
export const ValidateAccessResponse = {
|
|
132
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
133
|
+
if (message.valid !== false) {
|
|
134
|
+
writer.uint32(8).bool(message.valid);
|
|
135
|
+
}
|
|
136
|
+
if (message.reason !== "") {
|
|
137
|
+
writer.uint32(18).string(message.reason);
|
|
138
|
+
}
|
|
139
|
+
if (message.context !== undefined) {
|
|
140
|
+
AuthContext.encode(message.context, writer.uint32(26).fork()).ldelim();
|
|
141
|
+
}
|
|
142
|
+
return writer;
|
|
143
|
+
},
|
|
144
|
+
decode(input, length) {
|
|
145
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
146
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
147
|
+
const message = createBaseValidateAccessResponse();
|
|
148
|
+
while (reader.pos < end) {
|
|
149
|
+
const tag = reader.uint32();
|
|
150
|
+
switch (tag >>> 3) {
|
|
151
|
+
case 1:
|
|
152
|
+
if (tag !== 8) {
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
message.valid = reader.bool();
|
|
156
|
+
continue;
|
|
157
|
+
case 2:
|
|
158
|
+
if (tag !== 18) {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
message.reason = reader.string();
|
|
162
|
+
continue;
|
|
163
|
+
case 3:
|
|
164
|
+
if (tag !== 26) {
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
message.context = AuthContext.decode(reader, reader.uint32());
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
reader.skipType(tag & 7);
|
|
174
|
+
}
|
|
175
|
+
return message;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
function createBaseAuthorizeRequest() {
|
|
179
|
+
return { policy: "", attributes: {} };
|
|
180
|
+
}
|
|
181
|
+
export const AuthorizeRequest = {
|
|
182
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
183
|
+
if (message.context !== undefined) {
|
|
184
|
+
AuthContext.encode(message.context, writer.uint32(10).fork()).ldelim();
|
|
185
|
+
}
|
|
186
|
+
if (message.policy !== "") {
|
|
187
|
+
writer.uint32(18).string(message.policy);
|
|
188
|
+
}
|
|
189
|
+
Object.entries(message.attributes).forEach(([key, value]) => {
|
|
190
|
+
AuthorizeRequest_AttributesEntry.encode({ key: key, value }, writer.uint32(26).fork()).ldelim();
|
|
191
|
+
});
|
|
192
|
+
return writer;
|
|
193
|
+
},
|
|
194
|
+
decode(input, length) {
|
|
195
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
196
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
197
|
+
const message = createBaseAuthorizeRequest();
|
|
198
|
+
while (reader.pos < end) {
|
|
199
|
+
const tag = reader.uint32();
|
|
200
|
+
switch (tag >>> 3) {
|
|
201
|
+
case 1:
|
|
202
|
+
if (tag !== 10) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
message.context = AuthContext.decode(reader, reader.uint32());
|
|
206
|
+
continue;
|
|
207
|
+
case 2:
|
|
208
|
+
if (tag !== 18) {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
message.policy = reader.string();
|
|
212
|
+
continue;
|
|
213
|
+
case 3:
|
|
214
|
+
if (tag !== 26) {
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
const entry3 = AuthorizeRequest_AttributesEntry.decode(reader, reader.uint32());
|
|
218
|
+
if (entry3.value !== undefined) {
|
|
219
|
+
message.attributes[entry3.key] = entry3.value;
|
|
220
|
+
}
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
reader.skipType(tag & 7);
|
|
227
|
+
}
|
|
228
|
+
return message;
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
function createBaseAuthorizeRequest_AttributesEntry() {
|
|
232
|
+
return { key: "", value: "" };
|
|
233
|
+
}
|
|
234
|
+
export const AuthorizeRequest_AttributesEntry = {
|
|
235
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
236
|
+
if (message.key !== "") {
|
|
237
|
+
writer.uint32(10).string(message.key);
|
|
238
|
+
}
|
|
239
|
+
if (message.value !== "") {
|
|
240
|
+
writer.uint32(18).string(message.value);
|
|
241
|
+
}
|
|
242
|
+
return writer;
|
|
243
|
+
},
|
|
244
|
+
decode(input, length) {
|
|
245
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
246
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
247
|
+
const message = createBaseAuthorizeRequest_AttributesEntry();
|
|
248
|
+
while (reader.pos < end) {
|
|
249
|
+
const tag = reader.uint32();
|
|
250
|
+
switch (tag >>> 3) {
|
|
251
|
+
case 1:
|
|
252
|
+
if (tag !== 10) {
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
message.key = reader.string();
|
|
256
|
+
continue;
|
|
257
|
+
case 2:
|
|
258
|
+
if (tag !== 18) {
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
message.value = reader.string();
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
reader.skipType(tag & 7);
|
|
268
|
+
}
|
|
269
|
+
return message;
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
function createBaseAuthorizeResponse() {
|
|
273
|
+
return { allowed: false, reason: "" };
|
|
274
|
+
}
|
|
275
|
+
export const AuthorizeResponse = {
|
|
276
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
277
|
+
if (message.allowed !== false) {
|
|
278
|
+
writer.uint32(8).bool(message.allowed);
|
|
279
|
+
}
|
|
280
|
+
if (message.reason !== "") {
|
|
281
|
+
writer.uint32(18).string(message.reason);
|
|
282
|
+
}
|
|
283
|
+
return writer;
|
|
284
|
+
},
|
|
285
|
+
decode(input, length) {
|
|
286
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
287
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
288
|
+
const message = createBaseAuthorizeResponse();
|
|
289
|
+
while (reader.pos < end) {
|
|
290
|
+
const tag = reader.uint32();
|
|
291
|
+
switch (tag >>> 3) {
|
|
292
|
+
case 1:
|
|
293
|
+
if (tag !== 8) {
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
message.allowed = reader.bool();
|
|
297
|
+
continue;
|
|
298
|
+
case 2:
|
|
299
|
+
if (tag !== 18) {
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
message.reason = reader.string();
|
|
82
303
|
continue;
|
|
83
304
|
}
|
|
84
305
|
if ((tag & 7) === 4 || tag === 0) {
|
|
@@ -91,7 +312,7 @@ export const LoginResponse = {
|
|
|
91
312
|
};
|
|
92
313
|
export function AuthServiceControllerMethods() {
|
|
93
314
|
return function (constructor) {
|
|
94
|
-
const grpcMethods = ["
|
|
315
|
+
const grpcMethods = ["validateAccess", "authorize"];
|
|
95
316
|
for (const method of grpcMethods) {
|
|
96
317
|
const descriptor = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
97
318
|
GrpcMethod("AuthService", method)(constructor.prototype[method], method, descriptor);
|
|
@@ -105,13 +326,22 @@ export function AuthServiceControllerMethods() {
|
|
|
105
326
|
}
|
|
106
327
|
export const AUTH_SERVICE_NAME = "AuthService";
|
|
107
328
|
export const AuthServiceService = {
|
|
108
|
-
|
|
109
|
-
path: "/aegis.auth.v1.AuthService/
|
|
329
|
+
validateAccess: {
|
|
330
|
+
path: "/aegis.auth.v1.AuthService/ValidateAccess",
|
|
331
|
+
requestStream: false,
|
|
332
|
+
responseStream: false,
|
|
333
|
+
requestSerialize: (value) => Buffer.from(ValidateAccessRequest.encode(value).finish()),
|
|
334
|
+
requestDeserialize: (value) => ValidateAccessRequest.decode(value),
|
|
335
|
+
responseSerialize: (value) => Buffer.from(ValidateAccessResponse.encode(value).finish()),
|
|
336
|
+
responseDeserialize: (value) => ValidateAccessResponse.decode(value),
|
|
337
|
+
},
|
|
338
|
+
authorize: {
|
|
339
|
+
path: "/aegis.auth.v1.AuthService/Authorize",
|
|
110
340
|
requestStream: false,
|
|
111
341
|
responseStream: false,
|
|
112
|
-
requestSerialize: (value) => Buffer.from(
|
|
113
|
-
requestDeserialize: (value) =>
|
|
114
|
-
responseSerialize: (value) => Buffer.from(
|
|
115
|
-
responseDeserialize: (value) =>
|
|
342
|
+
requestSerialize: (value) => Buffer.from(AuthorizeRequest.encode(value).finish()),
|
|
343
|
+
requestDeserialize: (value) => AuthorizeRequest.decode(value),
|
|
344
|
+
responseSerialize: (value) => Buffer.from(AuthorizeResponse.encode(value).finish()),
|
|
345
|
+
responseDeserialize: (value) => AuthorizeResponse.decode(value),
|
|
116
346
|
},
|
|
117
347
|
};
|
package/dist/src/index.js
CHANGED
|
@@ -8,8 +8,6 @@ npm i
|
|
|
8
8
|
npm run gen
|
|
9
9
|
npm build
|
|
10
10
|
|
|
11
|
-
# login and publish (scoped public package)
|
|
12
|
-
|
|
13
11
|
npm login
|
|
14
12
|
npm publish --access public
|
|
15
13
|
|
|
@@ -24,37 +22,3 @@ npm i @acequants/aegis-contracts @grpc/grpc-js protobufjs
|
|
|
24
22
|
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
|
25
23
|
|
|
26
24
|
*/
|
|
27
|
-
/*
|
|
28
|
-
|
|
29
|
-
Usage
|
|
30
|
-
|
|
31
|
-
Generate TS stubs:
|
|
32
|
-
|
|
33
|
-
pnpm gen
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Build:
|
|
37
|
-
|
|
38
|
-
pnpm build
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Publish privately (npm org must be private):
|
|
42
|
-
|
|
43
|
-
npm publish --access restricted
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
Consumers install:
|
|
47
|
-
|
|
48
|
-
npm install @acequants/contracts
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
Import in services:
|
|
52
|
-
|
|
53
|
-
import { userV1 } from "@acequants/contracts";
|
|
54
|
-
|
|
55
|
-
const client = new userV1.UserServiceClient(
|
|
56
|
-
"localhost:50051",
|
|
57
|
-
credentials.createInsecure()
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
*/
|
package/package.json
CHANGED
package/proto/auth/v1/auth.proto
CHANGED
|
@@ -4,18 +4,39 @@ package aegis.auth.v1;
|
|
|
4
4
|
|
|
5
5
|
option java_multiple_files = true;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
string password = 2;
|
|
7
|
+
service AuthService {
|
|
8
|
+
rpc ValidateAccess (ValidateAccessRequest) returns (ValidateAccessResponse);
|
|
9
|
+
rpc Authorize (AuthorizeRequest) returns (AuthorizeResponse);
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
message
|
|
14
|
-
string
|
|
15
|
-
string
|
|
12
|
+
message AuthContext {
|
|
13
|
+
string session_id = 1;
|
|
14
|
+
string user_id = 2;
|
|
15
|
+
string email = 3;
|
|
16
|
+
// string tenant_id = 4;
|
|
17
|
+
repeated string roles = 4;
|
|
18
|
+
repeated string permissions = 5;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
message ValidateAccessRequest {
|
|
22
|
+
string access_token = 1;
|
|
23
|
+
string ip = 2;
|
|
24
|
+
string user_agent = 3;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
message ValidateAccessResponse {
|
|
28
|
+
bool valid = 1;
|
|
29
|
+
string reason = 2; // "expired", "revoked", etc.
|
|
30
|
+
AuthContext context = 3;
|
|
21
31
|
}
|
|
32
|
+
|
|
33
|
+
message AuthorizeRequest {
|
|
34
|
+
AuthContext context = 1;
|
|
35
|
+
string policy = 2; // e.g. "order.read"
|
|
36
|
+
map<string, string> attributes = 3; // resource/user attributes for ABAC
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
message AuthorizeResponse {
|
|
40
|
+
bool allowed = 1;
|
|
41
|
+
string reason = 2;
|
|
42
|
+
}
|