Browse Source

Rename Google OAuth and Security Token control variables

pull/5915/head
Germán Martín 2 months ago
committed by Thomas Kaul
parent
commit
4bf4e6d96b
  1. 9
      .env.example
  2. 8
      apps/api/src/app/info/info.service.ts
  3. 3
      apps/api/src/services/configuration/configuration.service.ts
  4. 3
      apps/api/src/services/interfaces/environment.interface.ts
  5. 15
      apps/client/src/app/components/header/header.component.ts
  6. 3
      apps/client/src/app/components/login-with-access-token-dialog/interfaces/interfaces.ts
  7. 13
      apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html
  8. 12
      apps/client/src/app/pages/register/register-page.component.ts
  9. 6
      apps/client/src/app/pages/register/register-page.html
  10. 5
      libs/common/src/lib/permissions.ts

9
.env.example

@ -14,3 +14,12 @@ POSTGRES_PASSWORD=<INSERT_POSTGRES_PASSWORD>
ACCESS_TOKEN_SALT=<INSERT_RANDOM_STRING> ACCESS_TOKEN_SALT=<INSERT_RANDOM_STRING>
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?connect_timeout=300&sslmode=prefer
JWT_SECRET_KEY=<INSERT_RANDOM_STRING> JWT_SECRET_KEY=<INSERT_RANDOM_STRING>
# AUTHENTICATION
# Enable authentication with Google OAuth (default: false)
# ENABLE_FEATURE_AUTH_GOOGLE=true
# GOOGLE_CLIENT_ID=<INSERT_GOOGLE_CLIENT_ID>
# GOOGLE_SECRET=<INSERT_GOOGLE_SECRET>
# Enable authentication with Security Token (default: true)
# ENABLE_FEATURE_AUTH_TOKEN=true

8
apps/api/src/app/info/info.service.ts

@ -70,8 +70,12 @@ export class InfoService {
); );
} }
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) { if (this.configurationService.get('ENABLE_FEATURE_AUTH_GOOGLE')) {
globalPermissions.push(permissions.enableSocialLogin); globalPermissions.push(permissions.enableAuthGoogle);
}
if (this.configurationService.get('ENABLE_FEATURE_AUTH_TOKEN')) {
globalPermissions.push(permissions.enableAuthToken);
} }
if (this.configurationService.get('ENABLE_FEATURE_STATISTICS')) { if (this.configurationService.get('ENABLE_FEATURE_STATISTICS')) {

3
apps/api/src/services/configuration/configuration.service.ts

@ -42,7 +42,8 @@ export class ConfigurationService {
}), }),
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }), ENABLE_FEATURE_FEAR_AND_GREED_INDEX: bool({ default: false }),
ENABLE_FEATURE_READ_ONLY_MODE: bool({ default: false }), ENABLE_FEATURE_READ_ONLY_MODE: bool({ default: false }),
ENABLE_FEATURE_SOCIAL_LOGIN: bool({ default: false }), ENABLE_FEATURE_AUTH_GOOGLE: bool({ default: false }),
ENABLE_FEATURE_AUTH_TOKEN: bool({ default: true }),
ENABLE_FEATURE_STATISTICS: bool({ default: false }), ENABLE_FEATURE_STATISTICS: bool({ default: false }),
ENABLE_FEATURE_SUBSCRIPTION: bool({ default: false }), ENABLE_FEATURE_SUBSCRIPTION: bool({ default: false }),
ENABLE_FEATURE_SYSTEM_MESSAGE: bool({ default: false }), ENABLE_FEATURE_SYSTEM_MESSAGE: bool({ default: false }),

3
apps/api/src/services/interfaces/environment.interface.ts

@ -18,7 +18,8 @@ export interface Environment extends CleanedEnvAccessors {
DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: string[]; DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: string[];
ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean; ENABLE_FEATURE_FEAR_AND_GREED_INDEX: boolean;
ENABLE_FEATURE_READ_ONLY_MODE: boolean; ENABLE_FEATURE_READ_ONLY_MODE: boolean;
ENABLE_FEATURE_SOCIAL_LOGIN: boolean; ENABLE_FEATURE_AUTH_GOOGLE: boolean;
ENABLE_FEATURE_AUTH_TOKEN: boolean;
ENABLE_FEATURE_STATISTICS: boolean; ENABLE_FEATURE_STATISTICS: boolean;
ENABLE_FEATURE_SUBSCRIPTION: boolean; ENABLE_FEATURE_SUBSCRIPTION: boolean;
ENABLE_FEATURE_SYSTEM_MESSAGE: boolean; ENABLE_FEATURE_SYSTEM_MESSAGE: boolean;

15
apps/client/src/app/components/header/header.component.ts

@ -105,7 +105,8 @@ export class GfHeaderComponent implements OnChanges {
public hasFilters: boolean; public hasFilters: boolean;
public hasImpersonationId: boolean; public hasImpersonationId: boolean;
public hasPermissionForSocialLogin: boolean; public hasPermissionForAuthGoogle: boolean;
public hasPermissionForAuthToken: boolean;
public hasPermissionForSubscription: boolean; public hasPermissionForSubscription: boolean;
public hasPermissionToAccessAdminControl: boolean; public hasPermissionToAccessAdminControl: boolean;
public hasPermissionToAccessAssistant: boolean; public hasPermissionToAccessAssistant: boolean;
@ -165,9 +166,14 @@ export class GfHeaderComponent implements OnChanges {
public ngOnChanges() { public ngOnChanges() {
this.hasFilters = this.userService.hasFilters(); this.hasFilters = this.userService.hasFilters();
this.hasPermissionForSocialLogin = hasPermission( this.hasPermissionForAuthGoogle = hasPermission(
this.info?.globalPermissions, this.info?.globalPermissions,
permissions.enableSocialLogin permissions.enableAuthGoogle
);
this.hasPermissionForAuthToken = hasPermission(
this.info?.globalPermissions,
permissions.enableAuthToken
); );
this.hasPermissionForSubscription = hasPermission( this.hasPermissionForSubscription = hasPermission(
@ -280,7 +286,8 @@ export class GfHeaderComponent implements OnChanges {
autoFocus: false, autoFocus: false,
data: { data: {
accessToken: '', accessToken: '',
hasPermissionToUseSocialLogin: this.hasPermissionForSocialLogin, hasPermissionToUseAuthGoogle: this.hasPermissionForAuthGoogle,
hasPermissionToUseAuthToken: this.hasPermissionForAuthToken,
title: $localize`Sign in` title: $localize`Sign in`
}, },
width: '30rem' width: '30rem'

3
apps/client/src/app/components/login-with-access-token-dialog/interfaces/interfaces.ts

@ -1,5 +1,6 @@
export interface LoginWithAccessTokenDialogParams { export interface LoginWithAccessTokenDialogParams {
accessToken: string; accessToken: string;
hasPermissionToUseSocialLogin: boolean; hasPermissionToUseAuthGoogle: boolean;
hasPermissionToUseAuthToken: boolean;
title: string; title: string;
} }

13
apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html

@ -3,6 +3,7 @@
<div class="py-3" mat-dialog-content> <div class="py-3" mat-dialog-content>
<div class="align-items-center d-flex flex-column"> <div class="align-items-center d-flex flex-column">
<form class="w-100"> <form class="w-100">
@if (data.hasPermissionToUseAuthToken) {
<mat-form-field appearance="outline" class="without-hint w-100"> <mat-form-field appearance="outline" class="without-hint w-100">
<mat-label i18n>Security Token</mat-label> <mat-label i18n>Security Token</mat-label>
<input <input
@ -22,9 +23,15 @@
/> />
</button> </button>
</mat-form-field> </mat-form-field>
}
@if (data.hasPermissionToUseSocialLogin) { @if (
data.hasPermissionToUseAuthGoogle && data.hasPermissionToUseAuthToken
) {
<div class="my-3 text-center text-muted" i18n>or</div> <div class="my-3 text-center text-muted" i18n>or</div>
}
@if (data.hasPermissionToUseAuthGoogle) {
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<a <a
class="px-4 rounded-pill" class="px-4 rounded-pill"
@ -44,11 +51,14 @@
<div mat-dialog-actions> <div mat-dialog-actions>
<div class="flex-grow-1"> <div class="flex-grow-1">
@if (data.hasPermissionToUseAuthToken) {
<mat-checkbox color="primary" i18n (change)="onChangeStaySignedIn($event)" <mat-checkbox color="primary" i18n (change)="onChangeStaySignedIn($event)"
>Stay signed in</mat-checkbox >Stay signed in</mat-checkbox
> >
}
</div> </div>
<div> <div>
@if (data.hasPermissionToUseAuthToken) {
<button <button
color="primary" color="primary"
mat-flat-button mat-flat-button
@ -59,5 +69,6 @@
> >
<ng-container i18n>Sign in</ng-container> <ng-container i18n>Sign in</ng-container>
</button> </button>
}
</div> </div>
</div> </div>

12
apps/client/src/app/pages/register/register-page.component.ts

@ -30,7 +30,8 @@ import { GfUserAccountRegistrationDialogComponent } from './user-account-registr
}) })
export class GfRegisterPageComponent implements OnDestroy, OnInit { export class GfRegisterPageComponent implements OnDestroy, OnInit {
public deviceType: string; public deviceType: string;
public hasPermissionForSocialLogin: boolean; public hasPermissionForAuthGoogle: boolean;
public hasPermissionForAuthToken: boolean;
public hasPermissionForSubscription: boolean; public hasPermissionForSubscription: boolean;
public hasPermissionToCreateUser: boolean; public hasPermissionToCreateUser: boolean;
public historicalDataItems: LineChartItem[]; public historicalDataItems: LineChartItem[];
@ -55,9 +56,14 @@ export class GfRegisterPageComponent implements OnDestroy, OnInit {
this.deviceType = this.deviceService.getDeviceInfo().deviceType; this.deviceType = this.deviceService.getDeviceInfo().deviceType;
this.hasPermissionForSocialLogin = hasPermission( this.hasPermissionForAuthGoogle = hasPermission(
globalPermissions, globalPermissions,
permissions.enableSocialLogin permissions.enableAuthGoogle
);
this.hasPermissionForAuthToken = hasPermission(
globalPermissions,
permissions.enableAuthToken
); );
this.hasPermissionForSubscription = hasPermission( this.hasPermissionForSubscription = hasPermission(

6
apps/client/src/app/pages/register/register-page.html

@ -18,6 +18,7 @@
<div class="button-container row"> <div class="button-container row">
<div class="align-items-center col d-flex justify-content-center"> <div class="align-items-center col d-flex justify-content-center">
<div class="py-5 text-center"> <div class="py-5 text-center">
@if (hasPermissionForAuthToken) {
<button <button
class="d-inline-block" class="d-inline-block"
color="primary" color="primary"
@ -26,8 +27,11 @@
> >
<ng-container i18n>Create Account</ng-container> <ng-container i18n>Create Account</ng-container>
</button> </button>
@if (hasPermissionForSocialLogin) { }
@if (hasPermissionForAuthGoogle && hasPermissionForAuthToken) {
<div class="my-3 text-muted" i18n>or</div> <div class="my-3 text-muted" i18n>or</div>
}
@if (hasPermissionForAuthGoogle) {
<a <a
class="px-4 rounded-pill w-100" class="px-4 rounded-pill w-100"
href="../api/v1/auth/google" href="../api/v1/auth/google"

5
libs/common/src/lib/permissions.ts

@ -32,7 +32,8 @@ export const permissions = {
enableFearAndGreedIndex: 'enableFearAndGreedIndex', enableFearAndGreedIndex: 'enableFearAndGreedIndex',
enableImport: 'enableImport', enableImport: 'enableImport',
enableBlog: 'enableBlog', enableBlog: 'enableBlog',
enableSocialLogin: 'enableSocialLogin', enableAuthGoogle: 'enableAuthGoogle',
enableAuthToken: 'enableAuthToken',
enableStatistics: 'enableStatistics', enableStatistics: 'enableStatistics',
enableSubscription: 'enableSubscription', enableSubscription: 'enableSubscription',
enableSubscriptionInterstitial: 'enableSubscriptionInterstitial', enableSubscriptionInterstitial: 'enableSubscriptionInterstitial',
@ -157,7 +158,7 @@ export function filterGlobalPermissions(
if (aUtmSource === 'ios') { if (aUtmSource === 'ios') {
return globalPermissions.filter((permission) => { return globalPermissions.filter((permission) => {
return ( return (
permission !== permissions.enableSocialLogin && permission !== permissions.enableAuthGoogle &&
permission !== permissions.enableSubscription permission !== permissions.enableSubscription
); );
}); });

Loading…
Cancel
Save