mirror of
https://github.com/0rangebananaspy/authelia.git
synced 2024-09-14 22:47:21 +07:00
c061dbfda4
One can now customize the default authentication method for all sub-domains, i.e., either 'two_factor' or 'basic_auth' and define specific authentication method per sub-domain. For example, one can specify that every sub-domain must be authenticated with two factor except one sub-domain that must be authenticated with basic auth.
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { AuthenticationMethodCalculator } from "../src/lib/AuthenticationMethodCalculator";
|
|
import { AuthenticationMethodsConfiguration } from "../src/lib/configuration/Configuration";
|
|
import Assert = require("assert");
|
|
|
|
describe("test authentication method calculator", function() {
|
|
it("should return default method when sub domain not overriden", function() {
|
|
const options1: AuthenticationMethodsConfiguration = {
|
|
default_method: "two_factor",
|
|
per_subdomain_methods: {}
|
|
};
|
|
const options2: AuthenticationMethodsConfiguration = {
|
|
default_method: "basic_auth",
|
|
per_subdomain_methods: {}
|
|
};
|
|
const calculator1 = new AuthenticationMethodCalculator(options1);
|
|
const calculator2 = new AuthenticationMethodCalculator(options2);
|
|
Assert.equal(calculator1.compute("www.example.com"), "two_factor");
|
|
Assert.equal(calculator2.compute("www.example.com"), "basic_auth");
|
|
});
|
|
|
|
it("should return overridden method when sub domain method is defined", function() {
|
|
const options1: AuthenticationMethodsConfiguration = {
|
|
default_method: "two_factor",
|
|
per_subdomain_methods: {
|
|
"www.example.com": "basic_auth"
|
|
}
|
|
};
|
|
const calculator1 = new AuthenticationMethodCalculator(options1);
|
|
Assert.equal(calculator1.compute("www.example.com"), "basic_auth");
|
|
});
|
|
}); |