Browse Source

Feature/separate Google OAuth and token authentication (#5915)

* Separate Google OAuth and token authentication

* Update changelog
pull/5417/merge
Germán Martín 2 weeks ago
committed by GitHub
parent
commit
66a3e319a8
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      CHANGELOG.md
  2. 12
      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. 67
      apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html
  8. 6
      apps/client/src/app/pages/features/features-page.component.ts
  9. 2
      apps/client/src/app/pages/features/features-page.html
  10. 1
      apps/client/src/app/pages/landing/landing-page.component.ts
  11. 12
      apps/client/src/app/pages/pricing/pricing-page.component.ts
  12. 2
      apps/client/src/app/pages/pricing/pricing-page.html
  13. 12
      apps/client/src/app/pages/register/register-page.component.ts
  14. 22
      apps/client/src/app/pages/register/register-page.html
  15. 5
      libs/common/src/lib/permissions.ts

5
CHANGELOG.md

@ -11,9 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactored the get holding functionality in the portfolio service - Refactored the get holding functionality in the portfolio service
- Changed the user data loading in the user detail dialog of the admin control panel’s users section to fetch data on demand - Changed the user data loading in the user detail dialog of the admin control panel’s users section to fetch data on demand
- Exposed the authentication with access token as an environment variable (`ENABLE_FEATURE_AUTH_TOKEN`)
- Improved the language localization for German (`de`) - Improved the language localization for German (`de`)
- Upgraded `prisma` from version `6.18.0` to `6.19.0` - Upgraded `prisma` from version `6.18.0` to `6.19.0`
### Todo
- Rename the environment variable from `ENABLE_FEATURE_SOCIAL_LOGIN` to `ENABLE_FEATURE_AUTH_GOOGLE`
## 2.216.0 - 2025-11-10 ## 2.216.0 - 2025-11-10
### Changed ### Changed

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

@ -51,6 +51,14 @@ export class InfoService {
const globalPermissions: string[] = []; const globalPermissions: string[] = [];
if (this.configurationService.get('ENABLE_FEATURE_AUTH_GOOGLE')) {
globalPermissions.push(permissions.enableAuthGoogle);
}
if (this.configurationService.get('ENABLE_FEATURE_AUTH_TOKEN')) {
globalPermissions.push(permissions.enableAuthToken);
}
if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) { if (this.configurationService.get('ENABLE_FEATURE_FEAR_AND_GREED_INDEX')) {
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
info.fearAndGreedDataSource = encodeDataSource( info.fearAndGreedDataSource = encodeDataSource(
@ -70,10 +78,6 @@ export class InfoService {
); );
} }
if (this.configurationService.get('ENABLE_FEATURE_SOCIAL_LOGIN')) {
globalPermissions.push(permissions.enableSocialLogin);
}
if (this.configurationService.get('ENABLE_FEATURE_STATISTICS')) { if (this.configurationService.get('ENABLE_FEATURE_STATISTICS')) {
globalPermissions.push(permissions.enableStatistics); globalPermissions.push(permissions.enableStatistics);
} }

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

@ -40,9 +40,10 @@ export class ConfigurationService {
DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: json({ DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: json({
default: [] default: []
}), }),
ENABLE_FEATURE_AUTH_GOOGLE: bool({ default: false }),
ENABLE_FEATURE_AUTH_TOKEN: bool({ default: true }),
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_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

@ -16,9 +16,10 @@ export interface Environment extends CleanedEnvAccessors {
DATA_SOURCE_IMPORT: string; DATA_SOURCE_IMPORT: string;
DATA_SOURCES: string[]; DATA_SOURCES: string[];
DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: string[]; DATA_SOURCES_GHOSTFOLIO_DATA_PROVIDER: string[];
ENABLE_FEATURE_AUTH_GOOGLE: boolean;
ENABLE_FEATURE_AUTH_TOKEN: boolean;
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_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;
} }

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

@ -3,28 +3,35 @@
<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">
<mat-form-field appearance="outline" class="without-hint w-100"> @if (data.hasPermissionToUseAuthToken) {
<mat-label i18n>Security Token</mat-label> <mat-form-field appearance="outline" class="without-hint w-100">
<input <mat-label i18n>Security Token</mat-label>
matInput <input
[formControl]="accessTokenFormControl" matInput
[type]="isAccessTokenHidden ? 'password' : 'text'" [formControl]="accessTokenFormControl"
(keydown.enter)="onLoginWithAccessToken(); $event.preventDefault()" [type]="isAccessTokenHidden ? 'password' : 'text'"
/> (keydown.enter)="onLoginWithAccessToken(); $event.preventDefault()"
<button
mat-button
matSuffix
type="button"
(click)="isAccessTokenHidden = !isAccessTokenHidden"
>
<ion-icon
[name]="isAccessTokenHidden ? 'eye-outline' : 'eye-off-outline'"
/> />
</button> <button
</mat-form-field> mat-button
matSuffix
type="button"
(click)="isAccessTokenHidden = !isAccessTokenHidden"
>
<ion-icon
[name]="isAccessTokenHidden ? 'eye-outline' : 'eye-off-outline'"
/>
</button>
</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"
@ -49,15 +56,17 @@
> >
</div> </div>
<div> <div>
<button @if (data.hasPermissionToUseAuthToken) {
color="primary" <button
mat-flat-button color="primary"
[disabled]=" mat-flat-button
!(accessTokenFormControl.dirty && accessTokenFormControl.valid) [disabled]="
" !(accessTokenFormControl.dirty && accessTokenFormControl.valid)
(click)="onLoginWithAccessToken()" "
> (click)="onLoginWithAccessToken()"
<ng-container i18n>Sign in</ng-container> >
</button> <ng-container i18n>Sign in</ng-container>
</button>
}
</div> </div>
</div> </div>

6
apps/client/src/app/pages/features/features-page.component.ts

@ -25,6 +25,7 @@ import { Subject, takeUntil } from 'rxjs';
}) })
export class GfFeaturesPageComponent implements OnDestroy { export class GfFeaturesPageComponent implements OnDestroy {
public hasPermissionForSubscription: boolean; public hasPermissionForSubscription: boolean;
public hasPermissionToCreateUser: boolean;
public info: InfoItem; public info: InfoItem;
public routerLinkRegister = publicRoutes.register.routerLink; public routerLinkRegister = publicRoutes.register.routerLink;
public routerLinkResources = publicRoutes.resources.routerLink; public routerLinkResources = publicRoutes.resources.routerLink;
@ -55,6 +56,11 @@ export class GfFeaturesPageComponent implements OnDestroy {
this.info?.globalPermissions, this.info?.globalPermissions,
permissions.enableSubscription permissions.enableSubscription
); );
this.hasPermissionToCreateUser = hasPermission(
this.info?.globalPermissions,
permissions.createUserAccount
);
} }
public ngOnDestroy() { public ngOnDestroy() {

2
apps/client/src/app/pages/features/features-page.html

@ -309,7 +309,7 @@
</div> </div>
</div> </div>
</div> </div>
@if (!user) { @if (hasPermissionToCreateUser && !user) {
<div class="row"> <div class="row">
<div class="col mt-3 text-center"> <div class="col mt-3 text-center">
<a <a

1
apps/client/src/app/pages/landing/landing-page.component.ts

@ -127,6 +127,7 @@ export class GfLandingPageComponent implements OnDestroy, OnInit {
} }
this.hasPermissionForDemo = !!demoAuthToken; this.hasPermissionForDemo = !!demoAuthToken;
this.hasPermissionForStatistics = hasPermission( this.hasPermissionForStatistics = hasPermission(
globalPermissions, globalPermissions,
permissions.enableStatistics permissions.enableStatistics

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

@ -52,6 +52,7 @@ export class GfPricingPageComponent implements OnDestroy, OnInit {
public coupon: number; public coupon: number;
public couponId: string; public couponId: string;
public durationExtension: StringValue; public durationExtension: StringValue;
public hasPermissionToCreateUser: boolean;
public hasPermissionToUpdateUserSettings: boolean; public hasPermissionToUpdateUserSettings: boolean;
public importAndExportTooltipBasic = translate( public importAndExportTooltipBasic = translate(
'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC' 'DATA_IMPORT_AND_EXPORT_TOOLTIP_BASIC'
@ -100,11 +101,18 @@ export class GfPricingPageComponent implements OnDestroy, OnInit {
} }
public ngOnInit() { public ngOnInit() {
const { baseCurrency, subscriptionOffer } = this.dataService.fetchInfo(); const { baseCurrency, globalPermissions, subscriptionOffer } =
this.baseCurrency = baseCurrency; this.dataService.fetchInfo();
this.baseCurrency = baseCurrency;
this.coupon = subscriptionOffer?.coupon; this.coupon = subscriptionOffer?.coupon;
this.durationExtension = subscriptionOffer?.durationExtension; this.durationExtension = subscriptionOffer?.durationExtension;
this.hasPermissionToCreateUser = hasPermission(
globalPermissions,
permissions.createUserAccount
);
this.label = subscriptionOffer?.label; this.label = subscriptionOffer?.label;
this.price = subscriptionOffer?.price; this.price = subscriptionOffer?.price;

2
apps/client/src/app/pages/pricing/pricing-page.html

@ -367,7 +367,7 @@
</p> </p>
</div> </div>
</div> </div>
} @else if (!user) { } @else if (hasPermissionToCreateUser && !user) {
<div class="row"> <div class="row">
<div class="col mt-3 text-center"> <div class="col mt-3 text-center">
<a <a

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(

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

@ -18,16 +18,20 @@
<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">
<button @if (hasPermissionForAuthToken) {
class="d-inline-block" <button
color="primary" class="d-inline-block"
mat-flat-button color="primary"
(click)="openShowAccessTokenDialog()" mat-flat-button
> (click)="openShowAccessTokenDialog()"
<ng-container i18n>Create Account</ng-container> >
</button> <ng-container i18n>Create Account</ng-container>
@if (hasPermissionForSocialLogin) { </button>
}
@if (hasPermissionForAuthToken && hasPermissionForAuthGoogle) {
<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

@ -28,11 +28,12 @@ export const permissions = {
deleteTag: 'deleteTag', deleteTag: 'deleteTag',
deleteUser: 'deleteUser', deleteUser: 'deleteUser',
deleteWatchlistItem: 'deleteWatchlistItem', deleteWatchlistItem: 'deleteWatchlistItem',
enableAuthGoogle: 'enableAuthGoogle',
enableAuthToken: 'enableAuthToken',
enableDataProviderGhostfolio: 'enableDataProviderGhostfolio', enableDataProviderGhostfolio: 'enableDataProviderGhostfolio',
enableFearAndGreedIndex: 'enableFearAndGreedIndex', enableFearAndGreedIndex: 'enableFearAndGreedIndex',
enableImport: 'enableImport', enableImport: 'enableImport',
enableBlog: 'enableBlog', enableBlog: 'enableBlog',
enableSocialLogin: 'enableSocialLogin',
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