Skip to content

Commit

Permalink
fix(authentication-service): add security spec
Browse files Browse the repository at this point in the history
RPMS-0
  • Loading branch information
samarpan-b committed Dec 20, 2020
1 parent 92e6738 commit d829a85
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
10 changes: 9 additions & 1 deletion services/audit-service/src/controllers/audit.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
Where,
} from '@loopback/repository';
import {get, getModelSchemaRef, param, post, requestBody} from '@loopback/rest';
import {CONTENT_TYPE, STATUS_CODE} from '@sourceloop/core';
import {
CONTENT_TYPE,
OPERATION_SECURITY_SPEC,
STATUS_CODE,
} from '@sourceloop/core';
import {authenticate, STRATEGY} from 'loopback4-authentication';
import {authorize} from 'loopback4-authorization';

Expand All @@ -26,6 +30,7 @@ export class AuditController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.CreateAudit]})
@post(basePath, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuditLog model instance',
Expand All @@ -52,6 +57,7 @@ export class AuditController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.ViewAudit]})
@get(`${basePath}/count`, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuditLog model count',
Expand All @@ -66,6 +72,7 @@ export class AuditController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.ViewAudit]})
@get(basePath, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'Array of AuditLog model instances',
Expand All @@ -89,6 +96,7 @@ export class AuditController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.ViewAudit]})
@get(`${basePath}/{id}`, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuditLog model instance',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import {AuthClient} from '../models';
import {AuthClientRepository} from '../repositories';
import {authorize} from 'loopback4-authorization';
import {authenticate, STRATEGY} from 'loopback4-authentication';
import {STATUS_CODE, CONTENT_TYPE} from '@sourceloop/core';
import {
STATUS_CODE,
CONTENT_TYPE,
OPERATION_SECURITY_SPEC,
} from '@sourceloop/core';
import {PermissionKey} from '../permission-key.enum';

const baseUrl = '/auth-clients';
Expand All @@ -34,6 +38,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@post(baseUrl, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuthClient model instance',
Expand All @@ -57,6 +62,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@get(`${baseUrl}/count`, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuthClient model count',
Expand All @@ -74,6 +80,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@get(baseUrl, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'Array of AuthClient model instances',
Expand All @@ -95,6 +102,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@patch(baseUrl, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuthClient PATCH success count',
Expand All @@ -120,6 +128,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@get(`${baseUrl}/{id}`, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'AuthClient model instance',
Expand All @@ -134,6 +143,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@patch(`${baseUrl}/{id}`, {
security: OPERATION_SECURITY_SPEC,
responses: {
'204': {
description: 'AuthClient PATCH success',
Expand All @@ -157,6 +167,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@put(`${baseUrl}/{id}`, {
security: OPERATION_SECURITY_SPEC,
responses: {
'204': {
description: 'AuthClient PUT success',
Expand All @@ -173,6 +184,7 @@ export class AuthClientController {
@authenticate(STRATEGY.BEARER)
@authorize({permissions: [PermissionKey.NotAllowed]})
@del(`${baseUrl}/{id}`, {
security: OPERATION_SECURITY_SPEC,
responses: {
'204': {
description: 'AuthClient DELETE success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
IAuthUserWithPermissions,
ILogger,
LOGGER,
OPERATION_SECURITY_SPEC,
STATUS_CODE,
SuccessResponse,
UserStatus,
Expand Down Expand Up @@ -542,6 +543,7 @@ export class LoginController {
@authenticate(STRATEGY.BEARER, {passReqToCallback: true})
@authorize({permissions: ['*']})
@patch(`auth/change-password`, {
security: OPERATION_SECURITY_SPEC,
responses: {
[STATUS_CODE.OK]: {
description: 'If User password successfully changed.',
Expand Down Expand Up @@ -628,6 +630,7 @@ export class LoginController {
})
@authorize({permissions: ['*']})
@get('/auth/me', {
security: OPERATION_SECURITY_SPEC,
description: 'To get the user details',
responses: {
[STATUS_CODE.OK]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AuthenticateErrorKeys,
CONTENT_TYPE,
ErrorCodes,
OPERATION_SECURITY_SPEC,
STATUS_CODE,
SuccessResponse,
} from '@sourceloop/core';
Expand All @@ -39,6 +40,7 @@ export class LogoutController {
})
@authorize({permissions: ['*']})
@post('/logout', {
security: OPERATION_SECURITY_SPEC,
description: 'To logout',
responses: {
[STATUS_CODE.OK]: {
Expand Down

0 comments on commit d829a85

Please sign in to comment.