Skip to content

Commit e04b771

Browse files
committed
add isOpenIdConnect helper to signin response
1 parent 4ba4629 commit e04b771

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/SigninResponse.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Log from './Log';
55
import UrlUtility from './UrlUtility';
66
import ErrorResponse from './ErrorResponse';
77

8+
const OidcScope = "openid";
9+
810
export default class SigninResponse {
911
constructor(url) {
1012

@@ -48,4 +50,8 @@ export default class SigninResponse {
4850
get scopes() {
4951
return (this.scope || "").split(" ");
5052
}
53+
54+
get isOpenIdConnect(){
55+
return this.scopes.indexOf(OidcScope) >= 0;
56+
}
5157
}

test/unit/SigninResponse.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,5 +121,21 @@ describe("SigninResponse", function() {
121121
Date.now = oldNow;
122122
});
123123
});
124+
125+
describe("isOpenIdConnect", function() {
126+
it("should detect openid scope", function() {
127+
let subject = new SigninResponse("scope=foo%20openid%20bar");
128+
subject.isOpenIdConnect.should.be.true;
129+
130+
subject = new SigninResponse("scope=openid%20foo%20bar");
131+
subject.isOpenIdConnect.should.be.true;
132+
133+
subject = new SigninResponse("scope=foo%20bar%20openid");
134+
subject.isOpenIdConnect.should.be.true;
135+
136+
subject = new SigninResponse("scope=foo%20bar");
137+
subject.isOpenIdConnect.should.be.false;
138+
});
139+
});
124140

125141
});

0 commit comments

Comments
 (0)