File tree Expand file tree Collapse file tree
packages/api-gateway/src/Controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,11 +44,19 @@ export class SubscriptionTokenAuthMiddleware extends BaseMiddleware {
4444 } as SubscriptionResponseLocals
4545 Object . assign ( response . locals , locals )
4646
47+ if ( typeof subscriptionToken !== 'string' || ! / ^ [ a - f 0 - 9 ] + $ / i. test ( subscriptionToken ) ) {
48+ response . status ( 401 ) . send ( { error : { tag : 'invalid-auth' , message : 'Invalid login credentials.' } } )
49+
50+ return
51+ }
52+
53+ const encodedSubscriptionToken = encodeURIComponent ( subscriptionToken )
54+
4755 try {
4856 const url =
4957 locals . tokenAuthenticationMethod == TokenAuthenticationMethod . OfflineSubscriptionToken
50- ? `${ this . authServerUrl } /offline/subscription-tokens/${ subscriptionToken } /validate`
51- : `${ this . authServerUrl } /subscription-tokens/${ subscriptionToken } /validate`
58+ ? `${ this . authServerUrl } /offline/subscription-tokens/${ encodedSubscriptionToken } /validate`
59+ : `${ this . authServerUrl } /subscription-tokens/${ encodedSubscriptionToken } /validate`
5260
5361 const authResponse = await this . httpClient . request ( {
5462 method : 'POST' ,
@@ -86,7 +94,7 @@ export class SubscriptionTokenAuthMiddleware extends BaseMiddleware {
8694 : ( error as Error ) . message
8795
8896 this . logger . error (
89- `Could not pass the request to ${ this . authServerUrl } /subscription-tokens/${ subscriptionToken } /validate on underlying service: ${ errorMessage } ` ,
97+ `Could not pass the request to ${ this . authServerUrl } /subscription-tokens/${ encodedSubscriptionToken } /validate on underlying service: ${ errorMessage } ` ,
9098 )
9199
92100 this . logger . debug ( 'Response error: %O' , ( error as AxiosError ) . response ?? error )
You can’t perform that action at this time.
0 commit comments