Pass query params to authorize endpoint during OIDC login (#5129)
This commit is contained in:
14
plugins/oidc/server/auth/oidc.test.ts
Normal file
14
plugins/oidc/server/auth/oidc.test.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { getTestServer } from "@server/test/support";
|
||||
|
||||
const server = getTestServer();
|
||||
|
||||
describe("oidc", () => {
|
||||
it("should pass query params along with auth redirect", async () => {
|
||||
const res = await server.get("/auth/oidc?myParam=someParam", {
|
||||
redirect: "manual",
|
||||
});
|
||||
const redirectLocation = new URL(res.headers.get("location"));
|
||||
expect(res.status).toEqual(302);
|
||||
expect(redirectLocation.searchParams.get("myParam")).toEqual("someParam");
|
||||
});
|
||||
});
|
||||
@@ -33,6 +33,20 @@ Strategy.prototype.userProfile = async function (accessToken, done) {
|
||||
}
|
||||
};
|
||||
|
||||
const authorizationParams = Strategy.prototype.authorizationParams;
|
||||
Strategy.prototype.authorizationParams = function (options) {
|
||||
return {
|
||||
...(options.originalQuery || {}),
|
||||
...(authorizationParams.bind(this)(options) || {}),
|
||||
};
|
||||
};
|
||||
|
||||
const authenticate = Strategy.prototype.authenticate;
|
||||
Strategy.prototype.authenticate = function (req, options) {
|
||||
options.originalQuery = req.query;
|
||||
authenticate.bind(this)(req, options);
|
||||
};
|
||||
|
||||
if (
|
||||
env.OIDC_CLIENT_ID &&
|
||||
env.OIDC_CLIENT_SECRET &&
|
||||
|
||||
Reference in New Issue
Block a user