@@ -6,7 +6,7 @@ import { MatIconModule } from '@angular/material/icon';
66import { MatToolbarModule } from '@angular/material/toolbar' ;
77import { MatProgressSpinnerModule } from '@angular/material/progress-spinner' ;
88import { Subscription } from 'rxjs' ;
9- import { loginIfNecessary , logout , sdkSetAuthHeader } from '@pega/auth/lib/sdk-auth-manager' ;
9+ import { loginIfNecessary , logout , sdkSetAuthHeader , sdkSetCustomTokenParamsCB } from '@pega/auth/lib/sdk-auth-manager' ;
1010
1111import { ProgressSpinnerService } from '../../../../../../../packages/angular-sdk-components/src/lib/_messages/progress-spinner.service' ;
1212import { UpdateWorklistService } from '../../../../../../../packages/angular-sdk-components/src/lib/_messages/update-worklist.service' ;
@@ -89,13 +89,13 @@ export class MCNavComponent implements OnInit, OnDestroy {
8989
9090 const sdkConfigAuth = await this . scservice . getSdkConfigAuth ( ) ;
9191
92- if ( ! sdkConfigAuth . mashupClientId && sdkConfigAuth . customAuthType === 'Basic' ) {
92+ if ( ( sdkConfigAuth . mashupGrantType === 'none' || ! sdkConfigAuth . mashupClientId ) && sdkConfigAuth . customAuthType === 'Basic' ) {
9393 // Service package to use custom auth with Basic
9494 const sB64 = window . btoa ( `${ sdkConfigAuth . mashupUserIdentifier } :${ window . atob ( sdkConfigAuth . mashupPassword ) } ` ) ;
9595 sdkSetAuthHeader ( `Basic ${ sB64 } ` ) ;
9696 }
9797
98- if ( ! sdkConfigAuth . mashupClientId && sdkConfigAuth . customAuthType === 'BasicTO' ) {
98+ if ( ( sdkConfigAuth . mashupGrantType === 'none' || ! sdkConfigAuth . mashupClientId ) && sdkConfigAuth . customAuthType === 'BasicTO' ) {
9999 const now = new Date ( ) ;
100100 const expTime = new Date ( now . getTime ( ) + 5 * 60 * 1000 ) ;
101101 let sISOTime = `${ expTime . toISOString ( ) . split ( '.' ) [ 0 ] } Z` ;
@@ -106,6 +106,14 @@ export class MCNavComponent implements OnInit, OnDestroy {
106106 sdkSetAuthHeader ( `Basic ${ sB64 } ` ) ;
107107 }
108108
109+ if ( sdkConfigAuth . mashupGrantType === 'customBearer' && sdkConfigAuth . customAuthType === 'CustomIdentifier' ) {
110+ // Use custom bearer with specific custom parameter to set the desired operator via
111+ // a userIdentifier property. (Caution: highly insecure...being used for simple demonstration)
112+ sdkSetCustomTokenParamsCB ( ( ) => {
113+ return { userIdentifier : sdkConfigAuth . mashupUserIdentifier } ;
114+ } ) ;
115+ }
116+
109117 // Login if needed, without doing an initial main window redirect
110118 // eslint-disable-next-line no-restricted-globals
111119 const sAppName = location . pathname . substring ( location . pathname . indexOf ( '/' ) + 1 ) ;
0 commit comments