Skip to content

Commit 7bcbab4

Browse files
authored
MS3 BE: Enhance Swagger Docs + Add RBAC (#55)
* Remove dependencies not required for ms3 * Complete swagger docs * Implement RBAC * Add remove admin role endpoint
1 parent b19c290 commit 7bcbab4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+327
-18528
lines changed

backend/auth-service/src/app.service.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class AppService {
5656
const tokens = await this.generateTokens({
5757
id: userId,
5858
email: newUser.email,
59+
roles: newUser.roles,
5960
});
6061
await this.updateRefreshToken({
6162
id: userId,
@@ -92,6 +93,7 @@ export class AppService {
9293
const tokens = await this.generateTokens({
9394
id: userId,
9495
email: user.email,
96+
roles: user.roles,
9597
});
9698
await this.updateRefreshToken({
9799
id: userId,
@@ -139,6 +141,7 @@ export class AppService {
139141
const tokens = await this.generateTokens({
140142
id: id,
141143
email: user.email,
144+
roles: user.roles,
142145
});
143146
await this.updateRefreshToken({ id, refreshToken: tokens.refresh_token });
144147

@@ -283,13 +286,14 @@ export class AppService {
283286

284287
// Could include other fields like roles in the future
285288
private async generateTokens(payload: TokenPayload): Promise<Token> {
286-
const { id, email } = payload;
289+
const { id, email, roles } = payload;
287290

288291
const [accessToken, refreshToken] = await Promise.all([
289292
this.jwtService.signAsync(
290293
{
291294
sub: id,
292295
email,
296+
roles,
293297
},
294298
{
295299
secret: process.env.JWT_SECRET,
@@ -300,6 +304,7 @@ export class AppService {
300304
{
301305
sub: id,
302306
email,
307+
roles,
303308
},
304309
{
305310
secret: process.env.JWT_REFRESH_SECRET,
@@ -360,6 +365,7 @@ export class AppService {
360365
const jwtTokens = await this.generateTokens({
361366
id: user._id.toString(),
362367
email: user.email,
368+
roles: user.roles,
363369
});
364370

365371
await this.updateRefreshToken({
@@ -461,6 +467,7 @@ export class AppService {
461467
const jwtTokens = await this.generateTokens({
462468
id: user._id.toString(),
463469
email: user.email,
470+
roles: user.roles,
464471
});
465472

466473
await this.updateRefreshToken({
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export interface TokenPayload {
22
id: string;
33
email: string;
4+
roles: string[];
45
}

backend/collaboration-service/.gitignore

Lines changed: 0 additions & 36 deletions
This file was deleted.

backend/collaboration-service/README.md

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)