mirror of https://github.com/grpc/grpc-node.git
Merge pull request #1275 from murgatroid99/grpc-js_auth_header_defense
grpc-js: Detect and error on multiple auth headers
This commit is contained in:
commit
086fb3d6a2
|
|
@ -20,6 +20,7 @@ import { Call } from './call-stream';
|
||||||
import { Channel } from './channel';
|
import { Channel } from './channel';
|
||||||
import { BaseFilter, Filter, FilterFactory } from './filter';
|
import { BaseFilter, Filter, FilterFactory } from './filter';
|
||||||
import { Metadata } from './metadata';
|
import { Metadata } from './metadata';
|
||||||
|
import { Status } from './constants';
|
||||||
|
|
||||||
export class CallCredentialsFilter extends BaseFilter implements Filter {
|
export class CallCredentialsFilter extends BaseFilter implements Filter {
|
||||||
private serviceUrl: string;
|
private serviceUrl: string;
|
||||||
|
|
@ -50,6 +51,12 @@ export class CallCredentialsFilter extends BaseFilter implements Filter {
|
||||||
});
|
});
|
||||||
const resultMetadata = await metadata;
|
const resultMetadata = await metadata;
|
||||||
resultMetadata.merge(await credsMetadata);
|
resultMetadata.merge(await credsMetadata);
|
||||||
|
if (resultMetadata.get('authorization').length > 1) {
|
||||||
|
this.stream.cancelWithStatus(
|
||||||
|
Status.INTERNAL,
|
||||||
|
'"authorization" metadata cannot have multiple values'
|
||||||
|
);
|
||||||
|
}
|
||||||
return resultMetadata;
|
return resultMetadata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue