Skip to content

Commit

Permalink
skip /admin/swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
benyam7 committed Jul 4, 2024
1 parent 925b109 commit 047a45f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/middleware/auth/auth-gaurd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class APIGuard {
private userInfoFetcher: IUserInfoFetcher;
private oauthProvider: IOAuthProvider;
private static bearerTokenIdentifier = 'Bearer';
private pathSkip = ['/swagger', '/static', '/logto', '/account/bootstrap', '/admin/webhook'];
private pathSkip = ['/swagger', '/admin/swagger', '/static', '/logto', '/account/bootstrap', '/admin/webhook'];

constructor(authRuleRepository: AuthRuleRepository, oauthProvider: IOAuthProvider) {
this.authRuleRepository = authRuleRepository;
Expand Down Expand Up @@ -95,6 +95,8 @@ export class APIGuard {
this.setUserInfoStrategy(new IdTokenUserInfoFetcher(bearerToken, this.oauthProvider));
return;
}

this.setUserInfoStrategy(new SwaggerUserInfoFetcher(this.oauthProvider));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/auth/user-info-fetcher/swagger-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class SwaggerUserInfoFetcher extends UserInfoHelper implements IUserInfoF
// If the user is not authenticated - return error
if (!request.user.isAuthenticated) {
return response.status(StatusCodes.UNAUTHORIZED).json({
error: "Unauthorized error: Seems like you are not authenticated. Please follow the authentication process using 'LogIn' button",
error: "Unauthorized error: Seems like you are not authenticated. Please follow the authentication process using 'Authorize' button",
} satisfies UnsuccessfulResponseBody);
}
// Tries to get customerId from the logTo user structure
Expand Down

0 comments on commit 047a45f

Please sign in to comment.