-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
344 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './entity' | ||
export * from './unauthenticated' |
15 changes: 15 additions & 0 deletions
15
apps/levansy-access-service/src/domain/entity/user/unauthenticated.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { User } from './entity' | ||
|
||
export const unauthenticatedUser: User = { | ||
_id: 'unauthenticated', | ||
name: 'Unauthenticated', | ||
username: 'unauthenticated', | ||
password: 'XXXXXXXXXXXXXXX', | ||
|
||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
} | ||
|
||
export function isUnauthenticatedUser(user: User) { | ||
return user._id === unauthenticatedUser._id | ||
} |
14 changes: 0 additions & 14 deletions
14
apps/levansy-access-service/src/domain/exception/authentication/base.ts
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
apps/levansy-access-service/src/domain/exception/authentication/payload.ts
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
apps/levansy-access-service/src/domain/exception/authn/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HttpStatus } from '@nestjs/common' | ||
import { DomainErrorCode } from '@diut/levansy-common' | ||
|
||
import { EDomain } from '../base' | ||
|
||
export class EAuthn extends EDomain { | ||
constructor( | ||
errorCode?: DomainErrorCode, | ||
message?: string, | ||
cause?: unknown, | ||
httpStatus?: HttpStatus, | ||
) { | ||
super(errorCode ?? DomainErrorCode.AUTHN, message, cause, httpStatus) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../domain/exception/authentication/index.ts → ...rvice/src/domain/exception/authn/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './base' | ||
export * from './payload' | ||
export * from './jwt' |
15 changes: 15 additions & 0 deletions
15
apps/levansy-access-service/src/domain/exception/authn/jwt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HttpStatus } from '@nestjs/common' | ||
import { DomainErrorCode } from '@diut/levansy-common' | ||
|
||
import { EAuthn } from './base' | ||
|
||
export class EAuthnInvalidJwtToken extends EAuthn { | ||
constructor() { | ||
super( | ||
DomainErrorCode.AUTHN_INVALID_JWT_TOKEN, | ||
'Invalid JWT token', | ||
undefined, | ||
HttpStatus.UNAUTHORIZED, | ||
) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
apps/levansy-access-service/src/domain/exception/authn/payload.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HttpStatus } from '@nestjs/common' | ||
import { DomainErrorCode } from '@diut/levansy-common' | ||
|
||
import { EAuthn } from './base' | ||
|
||
export class EAuthnPayloadNotFound extends EAuthn { | ||
constructor() { | ||
super( | ||
DomainErrorCode.AUTHN_PAYLOAD_NOT_FOUND, | ||
'Payload not found', | ||
undefined, | ||
HttpStatus.BAD_REQUEST, | ||
) | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
apps/levansy-access-service/src/domain/exception/authorization/base.ts
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
apps/levansy-access-service/src/domain/exception/authz/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HttpStatus } from '@nestjs/common' | ||
import { DomainErrorCode } from '@diut/levansy-common' | ||
|
||
import { EDomain } from '../base' | ||
|
||
export class EAuthz extends EDomain { | ||
constructor( | ||
errorCode?: DomainErrorCode, | ||
message?: string, | ||
cause?: unknown, | ||
httpStatus?: HttpStatus, | ||
) { | ||
super(errorCode ?? DomainErrorCode.AUTHZ, message, cause, httpStatus) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
apps/levansy-access-service/src/domain/exception/entity/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { HttpStatus } from '@nestjs/common' | ||
import { DomainErrorCode } from '@diut/levansy-common' | ||
|
||
import { EDomain } from '../base' | ||
|
||
export class EEntity extends EDomain { | ||
constructor( | ||
errorCode?: string, | ||
errorCode?: DomainErrorCode, | ||
message?: string, | ||
cause?: unknown, | ||
httpStatus?: HttpStatus, | ||
) { | ||
super(errorCode ?? 'E3000', message, cause, httpStatus) | ||
super(errorCode ?? DomainErrorCode.ENTITY, message, cause, httpStatus) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export * from './base' | ||
export * from './authentication' | ||
export * from './authorization' | ||
export * from './authn' | ||
export * from './authz' | ||
export * from './entity' | ||
export * from './service' |
5 changes: 3 additions & 2 deletions
5
apps/levansy-access-service/src/domain/exception/service/base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
import { HttpStatus } from '@nestjs/common' | ||
import { DomainErrorCode } from '@diut/levansy-common' | ||
|
||
import { EDomain } from '../base' | ||
|
||
export class EService extends EDomain { | ||
constructor( | ||
errorCode?: string, | ||
errorCode?: DomainErrorCode, | ||
message?: string, | ||
cause?: unknown, | ||
httpStatus?: HttpStatus, | ||
) { | ||
super(errorCode ?? 'E4000', message, cause, httpStatus) | ||
super(errorCode ?? DomainErrorCode.SERVICE, message, cause, httpStatus) | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
apps/levansy-access-service/src/domain/interface/authorization/context.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
apps/levansy-access-service/src/domain/interface/authorization/exception.ts
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
apps/levansy-access-service/src/domain/interface/authorization/index.ts
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
apps/levansy-access-service/src/domain/interface/authz/context.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { User } from 'src/domain/entity' | ||
|
||
export const AuthzContextToken = Symbol('AuthzContext') | ||
|
||
export interface IAuthzContext { | ||
prepareData(authPayload: AuthPayload | undefined): Promise<void> | ||
getData(): ContextData | ||
} | ||
|
||
export type AuthPayload = { | ||
userId: string | ||
} | ||
|
||
export type ContextData = { | ||
user: User | ||
} |
1 change: 1 addition & 0 deletions
1
apps/levansy-access-service/src/domain/interface/authz/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './context' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from './repository' | ||
export * from './service' | ||
export * from './authorization' | ||
export * from './authz' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
apps/levansy-access-service/src/infrastructure/authentication/common.ts
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
apps/levansy-access-service/src/infrastructure/authentication/index.ts
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
apps/levansy-access-service/src/infrastructure/authentication/jwt/common.ts
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
apps/levansy-access-service/src/infrastructure/authentication/jwt/guard.ts
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
apps/levansy-access-service/src/infrastructure/authentication/module.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.