Skip to content

Commit

Permalink
BC-8019 Switch to asymmetric signing of JWT (#5294)
Browse files Browse the repository at this point in the history
* Switch to asymmetric signing

* Adjust configs

* Fix tests

* Make secret combination of private and public key in feathers

* Add tests

* Update typ of JWT

* Update authConfig in tests

* Handle new lines in keys

* Clean up strategy tests

* Use JwtModuleOptionsFactory

* Use factory method instead of class

* Remove authConfig

* Remove unnecessary props in AuthGuardConfig

* Add AuthGuardConfig to files-storage

* Change setting of options in authn service

* Add authn test modules

* Fix authn service test

* Change iss and aud of JWT

* Fix reading of config for other apps

* Add JWT_SIGNING_ALGORITHM as env var

* Add check of algorithm in JWT validation

* Add check of issuer and audience in JWT validation

* Remove unnecessary consts

* Skip broken test

* Add SC_Domain to preview-generator-configmap

* Add values to top-level configs where forgotten

* Add factory for strategy options to satisfy SonarCloud

* Use getOrThrow to read values from ConfigService

* Define defaultMikroOrmOptions in for AdminApiServerModule separately to fix dependency problem

* Add JWT_PUBLIC_KEY to configmap of admin-api-server

* Add JWT_PUBLIC_KEY to configmap of preview-generator

---------

Co-authored-by: Max Bischof <[email protected]>
  • Loading branch information
dyedwiper and bischofmax authored Nov 5, 2024
1 parent b290804 commit 2016509
Show file tree
Hide file tree
Showing 34 changed files with 307 additions and 492 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ data:
IDENTITY_MANAGEMENT__TENANT: "{{ IDENTITY_MANAGEMENT__TENANT }}"
IDENTITY_MANAGEMENT__CLIENTID: "{{ IDENTITY_MANAGEMENT__CLIENTID }}"
TLDRAW__WEBSOCKET_URL: "wss://{{ DOMAIN }}/tldraw-server"
JWT_PUBLIC_KEY: "{{ JWT_PUBLIC_KEY }}"
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ metadata:
data:
NEST_LOG_LEVEL: "{{ NEST_LOG_LEVEL }}"
EXIT_ON_ERROR: "true"
SC_DOMAIN: "{{ DOMAIN }}"
JWT_PUBLIC_KEY: "{{ JWT_PUBLIC_KEY }}"
8 changes: 5 additions & 3 deletions apps/server/src/infra/auth-guard/auth-guard.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Algorithm } from 'jsonwebtoken';

export interface AuthGuardConfig {
ADMIN_API__ALLOWED_API_KEYS: string[];
JWT_AUD: string;
JWT_LIFETIME: string;
AUTHENTICATION: string;
JWT_PUBLIC_KEY: string;
JWT_SIGNING_ALGORITHM: Algorithm;
SC_DOMAIN: string;
}
10 changes: 0 additions & 10 deletions apps/server/src/infra/auth-guard/config/auth-config.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/server/src/infra/auth-guard/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './auth-config';
export * from './x-api-key.config';
2 changes: 1 addition & 1 deletion apps/server/src/infra/auth-guard/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export { JwtValidationAdapter } from './adapter';
export { AuthGuardModule } from './auth-guard.module';
export { AuthGuardConfig } from './auth-guard.config';
export { XApiKeyConfig, authConfig } from './config';
export { XApiKeyConfig } from './config';
export { CurrentUser, JWT, JwtAuthentication } from './decorator';
// JwtAuthGuard only exported because api tests still overried this guard.
// Use JwtAuthentication decorator for request validation
Expand Down
247 changes: 0 additions & 247 deletions apps/server/src/infra/auth-guard/mapper/authConfig.factory.spec.ts

This file was deleted.

76 changes: 0 additions & 76 deletions apps/server/src/infra/auth-guard/mapper/authConfig.factory.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/server/src/infra/auth-guard/mapper/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './authConfig.factory';
export * from './current-user.factory';
export * from './jwt.factory';
export * from './jwt-strategy-options.factory';
Loading

0 comments on commit 2016509

Please sign in to comment.