Fix api keys (#2116)

* Distinguish local env variables

* Remove api token secret
This commit is contained in:
martmull
2023-10-19 11:07:40 +02:00
committed by GitHub
parent 09fe29e559
commit b904397599
6 changed files with 4 additions and 14 deletions

View File

@ -26,8 +26,6 @@ services:
generateValue: true generateValue: true
- key: LOGIN_TOKEN_SECRET - key: LOGIN_TOKEN_SECRET
generateValue: true generateValue: true
- key: API_TOKEN_SECRET
generateValue: true
- key: REFRESH_TOKEN_SECRET - key: REFRESH_TOKEN_SECRET
generateValue: true generateValue: true
- key: PG_DATABASE_HOST - key: PG_DATABASE_HOST

View File

@ -4,10 +4,9 @@ PG_DATABASE_URL=postgres://twenty:twenty@localhost:5432/default?connection_limit
# PG_DATABASE_URL=postgres://twenty:twenty@postgres:5432/default?connection_limit=1 # PG_DATABASE_URL=postgres://twenty:twenty@postgres:5432/default?connection_limit=1
FRONT_BASE_URL=http://localhost:3001 FRONT_BASE_URL=http://localhost:3001
ACCESS_TOKEN_SECRET=replace_me_with_a_random_string ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access
LOGIN_TOKEN_SECRET=replace_me_with_a_random_string LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login
API_TOKEN_SECRET=replace_me_with_a_random_string REFRESH_TOKEN_SECRET=replace_me_with_a_random_string_refresh
REFRESH_TOKEN_SECRET=replace_me_with_a_random_string
SIGN_IN_PREFILLED=true SIGN_IN_PREFILLED=true
# ———————— Optional ———————— # ———————— Optional ————————

View File

@ -8,7 +8,6 @@ FRONT_BASE_URL=http://localhost:3001
# random keys used to generate JWT tokens # random keys used to generate JWT tokens
ACCESS_TOKEN_SECRET=secret_jwt ACCESS_TOKEN_SECRET=secret_jwt
LOGIN_TOKEN_SECRET=secret_login_tokens LOGIN_TOKEN_SECRET=secret_login_tokens
API_TOKEN_SECRET=secret_api_tokens
REFRESH_TOKEN_SECRET=secret_refresh_token REFRESH_TOKEN_SECRET=secret_refresh_token

View File

@ -29,7 +29,7 @@ export class ApiKeyService {
name: string, name: string,
expiresAt?: Date | string, expiresAt?: Date | string,
): Promise<AuthToken> { ): Promise<AuthToken> {
const secret = this.environmentService.getApiTokenSecret(); const secret = this.environmentService.getAccessTokenSecret();
let expiresIn: string | number; let expiresIn: string | number;
let expirationDate: Date; let expirationDate: Date;
const now = new Date().getTime(); const now = new Date().getTime();

View File

@ -69,10 +69,6 @@ export class EnvironmentService {
return this.configService.get<string>('LOGIN_TOKEN_SECRET')!; return this.configService.get<string>('LOGIN_TOKEN_SECRET')!;
} }
getApiTokenSecret(): string {
return this.configService.get<string>('API_TOKEN_SECRET')!;
}
getLoginTokenExpiresIn(): string { getLoginTokenExpiresIn(): string {
return this.configService.get<string>('LOGIN_TOKEN_EXPIRES_IN') ?? '15m'; return this.configService.get<string>('LOGIN_TOKEN_EXPIRES_IN') ?? '15m';
} }

View File

@ -82,8 +82,6 @@ export class EnvironmentVariables {
@IsString() @IsString()
LOGIN_TOKEN_SECRET: string; LOGIN_TOKEN_SECRET: string;
@IsString()
API_TOKEN_SECRET: string;
@IsDuration() @IsDuration()
@IsOptional() @IsOptional()
LOGIN_TOKEN_EXPIRES_IN: string; LOGIN_TOKEN_EXPIRES_IN: string;