feat (auth): support for flow type authorization_code in oauth2-redirect.html (#6750)
This commit is contained in:
@@ -28,8 +28,9 @@
|
|||||||
isValid = qp.state === sentState
|
isValid = qp.state === sentState
|
||||||
|
|
||||||
if ((
|
if ((
|
||||||
oauth2.auth.schema.get("flow") === "accessCode"||
|
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||||
oauth2.auth.schema.get("flow") === "authorizationCode"
|
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||||
) && !oauth2.auth.code) {
|
) && !oauth2.auth.code) {
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
oauth2.errCb({
|
oauth2.errCb({
|
||||||
|
|||||||
5
dist/oauth2-redirect.html
vendored
5
dist/oauth2-redirect.html
vendored
@@ -31,8 +31,9 @@
|
|||||||
isValid = qp.state === sentState
|
isValid = qp.state === sentState
|
||||||
|
|
||||||
if ((
|
if ((
|
||||||
oauth2.auth.schema.get("flow") === "accessCode"||
|
oauth2.auth.schema.get("flow") === "accessCode" ||
|
||||||
oauth2.auth.schema.get("flow") === "authorizationCode"
|
oauth2.auth.schema.get("flow") === "authorizationCode" ||
|
||||||
|
oauth2.auth.schema.get("flow") === "authorization_code"
|
||||||
) && !oauth2.auth.code) {
|
) && !oauth2.auth.code) {
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
oauth2.errCb({
|
oauth2.errCb({
|
||||||
|
|||||||
@@ -27,6 +27,14 @@ describe("oauth2", () => {
|
|||||||
authConfigs: {}
|
authConfigs: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let authConfig3 = {
|
||||||
|
auth: { schema: { get: (key)=> mockSchema[key] }, scopes: Im.List(["scope4","scope5"]) },
|
||||||
|
authActions: {},
|
||||||
|
errActions: {},
|
||||||
|
configs: { oauth2RedirectUrl: "" },
|
||||||
|
authConfigs: {}
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
win.open = jest.fn()
|
win.open = jest.fn()
|
||||||
})
|
})
|
||||||
@@ -114,5 +122,17 @@ describe("oauth2", () => {
|
|||||||
|
|
||||||
windowOpenSpy.mockReset()
|
windowOpenSpy.mockReset()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should build authorize url for authorization_code flow", () => {
|
||||||
|
const windowOpenSpy = jest.spyOn(win, "open")
|
||||||
|
mockSchema.authorizationUrl = "https://testAuthorizationUrl"
|
||||||
|
mockSchema.flow = "authorization_code"
|
||||||
|
|
||||||
|
oauth2Authorize(authConfig3)
|
||||||
|
expect(windowOpenSpy.mock.calls.length).toEqual(1)
|
||||||
|
expect(windowOpenSpy.mock.calls[0][0]).toMatch("https://testAuthorizationUrl?response_type=code&redirect_uri=&scope=scope4%20scope5&state=")
|
||||||
|
|
||||||
|
windowOpenSpy.mockReset()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user