Revert "feat: Add hosted domain hint when signing in through Google SSO from subdomain (#2458)" (#2467)
This reverts commit e613ec732b
.
This commit is contained in:
@ -25,19 +25,11 @@ function filterProviders(team) {
|
|||||||
find(team.authenticationProviders, { name: provider.id, enabled: true })
|
find(team.authenticationProviders, { name: provider.id, enabled: true })
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.map((provider) => {
|
.map((provider) => ({
|
||||||
const authProvider = team
|
id: provider.id,
|
||||||
? find(team.authenticationProviders, {
|
name: provider.name,
|
||||||
name: provider.id,
|
authUrl: provider.authUrl,
|
||||||
})
|
}));
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: provider.id,
|
|
||||||
name: provider.name,
|
|
||||||
authUrl: `${provider.authUrl}?authProviderId=${authProvider?.id || ""}`,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
router.post("auth.config", async (ctx) => {
|
router.post("auth.config", async (ctx) => {
|
||||||
|
@ -56,7 +56,7 @@ describe("#auth.config", () => {
|
|||||||
it("should return available providers for team subdomain", async () => {
|
it("should return available providers for team subdomain", async () => {
|
||||||
process.env.URL = "http://localoutline.com";
|
process.env.URL = "http://localoutline.com";
|
||||||
|
|
||||||
const team = await buildTeam({
|
await buildTeam({
|
||||||
guestSignin: false,
|
guestSignin: false,
|
||||||
subdomain: "example",
|
subdomain: "example",
|
||||||
authenticationProviders: [
|
authenticationProviders: [
|
||||||
@ -74,9 +74,6 @@ describe("#auth.config", () => {
|
|||||||
expect(res.status).toEqual(200);
|
expect(res.status).toEqual(200);
|
||||||
expect(body.data.providers.length).toBe(1);
|
expect(body.data.providers.length).toBe(1);
|
||||||
expect(body.data.providers[0].name).toBe("Slack");
|
expect(body.data.providers[0].name).toBe("Slack");
|
||||||
expect(body.data.providers[0].authUrl).toContain(
|
|
||||||
`?authProviderId=${team.authenticationProviders[0].id}`
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return available providers for team custom domain", async () => {
|
it("should return available providers for team custom domain", async () => {
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
GoogleWorkspaceInvalidError,
|
GoogleWorkspaceInvalidError,
|
||||||
} from "../../errors";
|
} from "../../errors";
|
||||||
import passportMiddleware from "../../middlewares/passport";
|
import passportMiddleware from "../../middlewares/passport";
|
||||||
import { AuthenticationProvider } from "../../models";
|
|
||||||
import { getAllowedDomains } from "../../utils/authentication";
|
import { getAllowedDomains } from "../../utils/authentication";
|
||||||
import { StateStore } from "../../utils/passport";
|
import { StateStore } from "../../utils/passport";
|
||||||
|
|
||||||
@ -87,28 +86,13 @@ if (GOOGLE_CLIENT_ID) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
router.get("google", async (ctx) => {
|
router.get(
|
||||||
const { authProviderId } = ctx.request.query;
|
"google",
|
||||||
|
passport.authenticate(providerName, {
|
||||||
if (authProviderId) {
|
|
||||||
ctx.assertUuid(authProviderId, "authProviderId must be a UUID");
|
|
||||||
}
|
|
||||||
|
|
||||||
const authProvider = authProviderId
|
|
||||||
? await AuthenticationProvider.findOne({
|
|
||||||
where: {
|
|
||||||
id: authProviderId,
|
|
||||||
name: providerName,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
: undefined;
|
|
||||||
|
|
||||||
return passport.authenticate(providerName, {
|
|
||||||
accessType: "offline",
|
accessType: "offline",
|
||||||
prompt: "select_account consent",
|
prompt: "select_account consent",
|
||||||
hd: authProvider?.providerId,
|
})
|
||||||
})(ctx);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
router.get("google.callback", passportMiddleware(providerName));
|
router.get("google.callback", passportMiddleware(providerName));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user