feat: scope login attempts to specific subdomains if available - do not switch subdomains (#3741)

* make the user lookup in user creator sensitive to team
* add team specific logic to oidc strat
* factor out slugifyDomain
* change type of req during auth to Koa.Context
This commit is contained in:
Nan Yu
2022-07-19 06:50:55 -07:00
committed by GitHub
parent 4ee3929e9d
commit c3f5563e7f
12 changed files with 148 additions and 64 deletions

View File

@@ -1,5 +1,5 @@
import env from "@shared/env";
import { parseDomain, getCookieDomain } from "./domains";
import { parseDomain, getCookieDomain, slugifyDomain } from "./domains";
// test suite is based on subset of parse-domain module we want to support
// https://github.com/peerigon/parse-domain/blob/master/test/parseDomain.test.js
@@ -158,6 +158,14 @@ describe("#parseDomain", () => {
});
});
describe("#slugifyDomain", () => {
it("strips the last . delineated segment from strings", () => {
expect(slugifyDomain("foo.co")).toBe("foo");
expect(slugifyDomain("foo.co.uk")).toBe("foo-co");
expect(slugifyDomain("www.foo.co.uk")).toBe("www-foo-co");
});
});
describe("#getCookieDomain", () => {
beforeEach(() => {
env.URL = "https://example.com";