Skip to content

Commit

Permalink
fix: Hardcoded oidcKey
Browse files Browse the repository at this point in the history
  • Loading branch information
yosvelquintero committed Jun 21, 2024
1 parent 943b1d7 commit 8b7d7e2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
4 changes: 4 additions & 0 deletions apps/restorecommerce/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import { RoutesTitleStrategyService } from './routes-title-strategy.service';
VCLProgressBarModule,
],
providers: [
{
provide: 'oidcKey',
useValue: environment.oidcKey,
},
{
provide: 'apiUrl',
useValue: environment.urls.api,
Expand Down
14 changes: 6 additions & 8 deletions packages/core/config/src/lib/constants/authn.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { IAuthnConstant } from '@console-core/types';
import { TAuthnConstant } from '@console-core/types';

export const AUTH: Readonly<IAuthnConstant> = {
headers: {
Accept: 'application/json',
'Content-type': 'application/x-www-form-urlencoded',
Authorization: 'Basic VEVTVF9DTElFTlRfSUQ6VEVTVF9DTElFTlRfU0VDUkVU=',
},
};
export const AUTH = (key: string): Readonly<TAuthnConstant> => ({
Accept: 'application/json',
'Content-type': 'application/x-www-form-urlencoded',
Authorization: `Basic ${key}`,
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { MutationResult } from 'apollo-angular';
import { Observable } from 'rxjs';

Expand All @@ -21,9 +21,10 @@ import { ApiService } from '../api.service';
providedIn: 'root',
})
export class AuthnService {
private readonly headers = new HttpHeaders(AUTH.headers);
private readonly headers = new HttpHeaders(AUTH(this.oidcKey));

constructor(
@Inject('oidcKey') private oidcKey: string,
private readonly httpClient: HttpClient,
private readonly apiService: ApiService,
private readonly identityUserRegisterGQL: IdentityUserRegisterGQL
Expand Down
12 changes: 9 additions & 3 deletions packages/core/types/src/lib/types/authn.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { IAuthnState, IStoreConstant } from '../interfaces';

type AuthnStateKey = IStoreConstant['states']['authnState'];
type TAuthnStateKey = IStoreConstant['states']['authnState'];

export type IAuthnStateType = {
[key in AuthnStateKey]: IAuthnState;
export type TAuthnStateType = {
[key in TAuthnStateKey]: IAuthnState;
};

export type TAuthnConstant = (key: string) => {
Accept: string;
'Content-type': string;
Authorization: string;
};

0 comments on commit 8b7d7e2

Please sign in to comment.