mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
grpc-js: Detect and error on multiple auth headers
This commit is contained in:
parent
1fc9825523
commit
03b70172e0
@ -20,6 +20,7 @@ import { Call } from './call-stream';
|
||||
import { Channel } from './channel';
|
||||
import { BaseFilter, Filter, FilterFactory } from './filter';
|
||||
import { Metadata } from './metadata';
|
||||
import { Status } from './constants';
|
||||
|
||||
export class CallCredentialsFilter extends BaseFilter implements Filter {
|
||||
private serviceUrl: string;
|
||||
@ -50,6 +51,12 @@ export class CallCredentialsFilter extends BaseFilter implements Filter {
|
||||
});
|
||||
const resultMetadata = await metadata;
|
||||
resultMetadata.merge(await credsMetadata);
|
||||
if (resultMetadata.get('authorization').length > 1) {
|
||||
this.stream.cancelWithStatus(
|
||||
Status.INTERNAL,
|
||||
'"authorization" metadata cannot have multiple values'
|
||||
);
|
||||
}
|
||||
return resultMetadata;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user