Add normalized state compare for CLI (#211)
This commit is contained in:
parent
ea6fd5ac38
commit
abb54f0073
|
@ -262,7 +262,7 @@ export class LoginCommand {
|
|||
const code = url.searchParams.get('code');
|
||||
const receivedState = url.searchParams.get('state');
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
if (code != null && receivedState != null && receivedState === state) {
|
||||
if (code != null && receivedState != null && this.checkState(receivedState, state)) {
|
||||
res.writeHead(200);
|
||||
res.end('<html><head><title>Success | Bitwarden CLI</title></head><body>' +
|
||||
'<h1>Successfully authenticated with the Bitwarden CLI</h1>' +
|
||||
|
@ -300,4 +300,17 @@ export class LoginCommand {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
private checkState(state: string, checkState: string): boolean {
|
||||
if (state === null || state === undefined) {
|
||||
return false;
|
||||
}
|
||||
if (checkState === null || checkState === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const stateSplit = state.split('_identifier=');
|
||||
const checkStateSplit = checkState.split('_identifier=');
|
||||
return stateSplit[0] === checkStateSplit[0];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue