Skip to content

Commit

Permalink
SPSH-387: Added the auth exception filter in every controller in orde…
Browse files Browse the repository at this point in the history
…r to map and deliver KeycloakUserNotFoundError to the FE
  • Loading branch information
phaelcg committed Jun 28, 2024
1 parent f6b9715 commit 57efcee
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/modules/organisation/api/organisation.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ import { OrganisationExceptionFilter } from './organisation-exception-filter.js'
import { OrganisationSpecificationError } from '../specification/error/organisation-specification.error.js';
import { OrganisationByIdQueryParams } from './organisation-by-id.query.js';
import { OrganisationsTyp } from '../domain/organisation.enums.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(new SchulConnexValidationErrorFilter(), new OrganisationExceptionFilter())
@UseFilters(
new SchulConnexValidationErrorFilter(),
new OrganisationExceptionFilter(),
new AuthenticationExceptionFilter(),
)
@ApiTags('organisationen')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
7 changes: 6 additions & 1 deletion src/modules/person/api/dbiam-person.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ import { DBiamPersonResponse } from './dbiam-person.response.js';
import { DbiamPersonenkontextError } from '../../personenkontext/api/dbiam-personenkontext.error.js';
import { PersonenkontextExceptionFilter } from '../../personenkontext/api/personenkontext-exception-filter.js';
import { PersonenkontextSpecificationError } from '../../personenkontext/specification/error/personenkontext-specification.error.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(new SchulConnexValidationErrorFilter(), new PersonenkontextExceptionFilter())
@UseFilters(
new SchulConnexValidationErrorFilter(),
new PersonenkontextExceptionFilter(),
new AuthenticationExceptionFilter(),
)
@ApiTags('dbiam-personen')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
3 changes: 2 additions & 1 deletion src/modules/person/api/person-info.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import { PersonDo } from '../domain/person.do.js';
import { PersonenkontextRepo } from '../../personenkontext/persistence/personenkontext.repo.js';
import { PersonenkontextScope } from '../../personenkontext/persistence/personenkontext.scope.js';
import { PersonenkontextDo } from '../../personenkontext/domain/personenkontext.do.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiBearerAuth()
@ApiOAuth2(['openid'])
@ApiTags('person-info')
Expand Down
3 changes: 2 additions & 1 deletion src/modules/person/api/person.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ import { OrganisationID } from '../../../shared/types/index.js';
import { RollenSystemRecht } from '../../rolle/domain/rolle.enums.js';
import { DataConfig, ServerConfig } from '../../../shared/config/index.js';
import { ConfigService } from '@nestjs/config';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiTags('personen')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
3 changes: 2 additions & 1 deletion src/modules/person/api/person.frontend.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { ServerConfig } from '../../../shared/config/server.config.js';
import { ConfigService } from '@nestjs/config';
import { DataConfig } from '../../../shared/config/data.config.js';
import { RollenSystemRecht } from '../../rolle/domain/rolle.enums.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiTags('personen-frontend')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import { ServerConfig, DataConfig } from '../../../../shared/config/index.js';
import { RollenSystemRecht } from '../../../rolle/domain/rolle.enums.js';
import { DbiamPersonenuebersicht } from '../../domain/dbiam-personenuebersicht.js';
import { OrganisationRepository } from '../../../organisation/persistence/organisation.repository.js';
import { AuthenticationExceptionFilter } from '../../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiTags('dbiam-personenuebersicht')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import { getMapperToken } from '@automapper/nestjs';
import { Mapper } from '@automapper/core';
import { Permissions } from '../../authentication/api/permissions.decorator.js';
import { PersonPermissions } from '../../authentication/domain/person-permissions.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiTags('personenkontext')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ import { DbiamPersonenkontexteUpdateError } from './dbiam-personenkontexte-updat
import { OrganisationMatchesRollenartError } from '../specification/error/organisation-matches-rollenart.error.js';
import { PersonenkontexteUpdateError } from '../domain/error/personenkontexte-update.error.js';
import { PersonenkontexteUpdateResponse } from './response/personenkontexte-update.response.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(
new SchulConnexValidationErrorFilter(),
new PersonenkontextExceptionFilter(),
new PersonenkontexteUpdateExceptionFilter(),
new AuthenticationExceptionFilter(),
)
@ApiTags('dbiam-personenkontexte')
@ApiBearerAuth()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ import { Permissions } from '../../authentication/api/permissions.decorator.js';
import { PersonPermissions } from '../../authentication/domain/person-permissions.js';
import { DBiamPersonenkontextRepo } from '../persistence/dbiam-personenkontext.repo.js';
import { OrganisationID } from '../../../shared/types/aggregate-ids.types.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiTags('personenkontexte')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
3 changes: 2 additions & 1 deletion src/modules/rolle/api/rolle.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ import { ServiceProviderResponse } from '../../service-provider/api/service-prov
import { SchulConnexError } from '../../../shared/error/schul-connex.error.js';
import { RolleExceptionFilter } from './rolle-exception-filter.js';
import { Paged, PagedResponse, PagingHeadersObject } from '../../../shared/paging/index.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(new SchulConnexValidationErrorFilter(), new RolleExceptionFilter())
@UseFilters(new SchulConnexValidationErrorFilter(), new RolleExceptionFilter(), new AuthenticationExceptionFilter())
@ApiTags('rolle')
@ApiBearerAuth()
@ApiOAuth2(['openid'])
Expand Down
3 changes: 2 additions & 1 deletion src/modules/service-provider/api/provider.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import { PersonPermissions } from '../../authentication/domain/person-permission
import { RolleRepo } from '../../rolle/repo/rolle.repo.js';
import { Rolle } from '../../rolle/domain/rolle.js';
import { Permissions } from '../../authentication/api/permissions.decorator.js';
import { AuthenticationExceptionFilter } from '../../authentication/api/authentication-exception-filter.js';

@UseFilters(SchulConnexValidationErrorFilter)
@UseFilters(SchulConnexValidationErrorFilter, new AuthenticationExceptionFilter())
@ApiTags('provider')
@ApiOAuth2(['openid'])
@ApiBearerAuth()
Expand Down

0 comments on commit 57efcee

Please sign in to comment.