File tree 4 files changed +8
-10
lines changed
api/src/app/auth/framework
libs/application-generic/src/http
4 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,18 @@ import { HttpRequestHeaderKeysEnum } from '@novu/application-generic';
4
4
@Injectable ( )
5
5
export class SelfHostSecretGuard implements CanActivate {
6
6
canActivate ( context : ExecutionContext ) : boolean {
7
- const secretKey = process . env . SELF_HOSTED_SECRET_KEY ;
7
+ const secretKey = process . env . SELF_HOSTED_TOKEN ;
8
8
if ( ! secretKey ) return true ;
9
9
10
10
const request = context . switchToHttp ( ) . getRequest ( ) ;
11
- const headerKey = request . headers [ HttpRequestHeaderKeysEnum . NOVU_SELF_HOSTED_SECRET_KEY . toLowerCase ( ) ] ;
11
+ const headerKey = request . headers [ HttpRequestHeaderKeysEnum . NOVU_SELF_HOSTED_TOKEN . toLowerCase ( ) ] ;
12
12
13
13
if ( ! headerKey ) {
14
- throw new UnauthorizedException ( 'Missing self-host secret key ' ) ;
14
+ throw new UnauthorizedException ( 'Missing self-host token ' ) ;
15
15
}
16
16
17
17
if ( headerKey !== secretKey ) {
18
- throw new UnauthorizedException ( 'Invalid self-host secret key ' ) ;
18
+ throw new UnauthorizedException ( 'Invalid self-host token ' ) ;
19
19
}
20
20
21
21
return true ;
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export const ONBOARDING_DEMO_WORKFLOW_ID = 'onboarding-demo-workflow';
32
32
33
33
export const IS_SELF_HOSTED = import . meta. env . VITE_SELF_HOSTED ;
34
34
35
- export const SELF_HOSTED_SECRET_KEY = import . meta. env . VITE_SELF_HOSTED_SECRET_KEY ;
35
+ export const SELF_HOSTED_TOKEN = import . meta. env . VITE_SELF_HOSTED_TOKEN ;
36
36
37
37
if ( ! IS_SELF_HOSTED && ! CLERK_PUBLISHABLE_KEY ) {
38
38
throw new Error ( 'Missing Clerk Publishable Key' ) ;
Original file line number Diff line number Diff line change 1
1
import { get } from '../../api/api.client' ;
2
- import { SELF_HOSTED_SECRET_KEY } from '../../config' ;
2
+ import { SELF_HOSTED_TOKEN } from '../../config' ;
3
3
4
4
const JWT_STORAGE_KEY = 'self-hosted-jwt' ;
5
5
6
6
export async function refreshJwt ( ) : Promise < string | null > {
7
7
try {
8
- const headers : HeadersInit = SELF_HOSTED_SECRET_KEY
9
- ? { 'novu-self-hosted-secret-key' : SELF_HOSTED_SECRET_KEY }
10
- : { } ;
8
+ const headers : HeadersInit = SELF_HOSTED_TOKEN ? { 'novu-self-hosted-token' : SELF_HOSTED_TOKEN } : { } ;
11
9
const result = await get < { data : { token : string } } > ( '/auth/self-hosted' , { headers } ) ;
12
10
const token = result ?. data ?. token ;
13
11
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ export enum HttpRequestHeaderKeysEnum {
12
12
NOVU_USER_AGENT = 'Novu-User-Agent' ,
13
13
BYPASS_TUNNEL_REMINDER = 'Bypass-Tunnel-Reminder' ,
14
14
IDEMPOTENCY_KEY = 'Idempotency-Key' ,
15
- NOVU_SELF_HOSTED_SECRET_KEY = 'Novu-Self-Hosted-Secret-Key ' ,
15
+ NOVU_SELF_HOSTED_TOKEN = 'Novu-Self-Hosted-Token ' ,
16
16
}
17
17
testHttpHeaderEnumValidity ( HttpRequestHeaderKeysEnum ) ;
18
18
You can’t perform that action at this time.
0 commit comments