diff --git a/config.template.yml b/config.template.yml index 6457bbf8f..70889e4af 100644 --- a/config.template.yml +++ b/config.template.yml @@ -173,6 +173,9 @@ access_control: # # The session cookies identify the user once logged in. session: + # The name of the session cookie. (default: authelia_session). + name: authelia_session + # The secret to encrypt the session cookie. secret: unsecure_session_secret diff --git a/server/src/lib/configuration/SessionConfigurationBuilder.spec.ts b/server/src/lib/configuration/SessionConfigurationBuilder.spec.ts index 0d5cc11fe..a03507d64 100644 --- a/server/src/lib/configuration/SessionConfigurationBuilder.spec.ts +++ b/server/src/lib/configuration/SessionConfigurationBuilder.spec.ts @@ -39,6 +39,7 @@ describe("configuration/SessionConfigurationBuilder", function () { }, port: 8080, session: { + name: "authelia_session", domain: "example.com", expiration: 3600, secret: "secret" @@ -73,6 +74,7 @@ describe("configuration/SessionConfigurationBuilder", function () { const options = SessionConfigurationBuilder.build(configuration, deps); const expectedOptions = { + name: "authelia_session", secret: "secret", resave: false, saveUninitialized: true, @@ -118,6 +120,7 @@ describe("configuration/SessionConfigurationBuilder", function () { }, port: 8080, session: { + name: "authelia_session", domain: "example.com", expiration: 3600, secret: "secret", @@ -165,6 +168,7 @@ describe("configuration/SessionConfigurationBuilder", function () { secret: "secret", resave: false, saveUninitialized: true, + name: "authelia_session", cookie: { secure: true, httpOnly: true, diff --git a/server/src/lib/configuration/SessionConfigurationBuilder.ts b/server/src/lib/configuration/SessionConfigurationBuilder.ts index 427cec728..716a1f74a 100644 --- a/server/src/lib/configuration/SessionConfigurationBuilder.ts +++ b/server/src/lib/configuration/SessionConfigurationBuilder.ts @@ -7,6 +7,7 @@ export class SessionConfigurationBuilder { static build(configuration: Configuration, deps: GlobalDependencies): ExpressSession.SessionOptions { const sessionOptions: ExpressSession.SessionOptions = { + name: configuration.session.name, secret: configuration.session.secret, resave: false, saveUninitialized: true, diff --git a/server/src/lib/configuration/schema/SessionConfiguration.spec.ts b/server/src/lib/configuration/schema/SessionConfiguration.spec.ts index b63e7eede..e54010837 100644 --- a/server/src/lib/configuration/schema/SessionConfiguration.spec.ts +++ b/server/src/lib/configuration/schema/SessionConfiguration.spec.ts @@ -9,6 +9,7 @@ describe("configuration/schema/SessionConfiguration", function() { }; const newConfiguration = complete(configuration); + Assert.equal(newConfiguration.name, 'authelia_session'); Assert.equal(newConfiguration.expiration, 3600000); Assert.equal(newConfiguration.inactivity, undefined); }); diff --git a/server/src/lib/configuration/schema/SessionConfiguration.ts b/server/src/lib/configuration/schema/SessionConfiguration.ts index e628cb0d1..4b5d555b6 100644 --- a/server/src/lib/configuration/schema/SessionConfiguration.ts +++ b/server/src/lib/configuration/schema/SessionConfiguration.ts @@ -4,6 +4,7 @@ export interface SessionRedisOptions { } export interface SessionConfiguration { + name?: string; domain: string; secret: string; expiration?: number; @@ -14,6 +15,10 @@ export interface SessionConfiguration { export function complete(configuration: SessionConfiguration): SessionConfiguration { const newConfiguration: SessionConfiguration = (configuration) ? JSON.parse(JSON.stringify(configuration)) : {}; + if (!newConfiguration.name) { + newConfiguration.name = "authelia_session"; + } + if (!newConfiguration.expiration) { newConfiguration.expiration = 3600000; // 1 hour } diff --git a/test/features/forward-headers.feature b/test/features/forward-headers.feature index b5bbc0b5c..3e45c1356 100644 --- a/test/features/forward-headers.feature +++ b/test/features/forward-headers.feature @@ -1,4 +1,4 @@ -Feature: User and groups headers are correctly forwarded to backend +Feature: Headers are correctly forwarded to backend @need-authenticated-user-john Scenario: Custom-Forwarded-User and Custom-Forwarded-Groups are correctly forwarded to protected backend When I visit "https://public.example.com:8080/headers" diff --git a/test/features/step_definitions/forward-headers.ts b/test/features/step_definitions/forward-headers.ts index cbefd1a79..a459a4bfa 100644 --- a/test/features/step_definitions/forward-headers.ts +++ b/test/features/step_definitions/forward-headers.ts @@ -2,7 +2,8 @@ import {Then} from "cucumber"; import seleniumWebdriver = require("selenium-webdriver"); import CustomWorld = require("../support/world"); import Util = require("util"); -import BluebirdPromise = require("bluebird"); +import Bluebird = require("bluebird"); +import Request = require("request-promise"); Then("I see header {string} set to {string}", { timeout: 5000 }, @@ -11,8 +12,8 @@ Then("I see header {string} set to {string}", .then(function (txt: string) { const expectedLine = Util.format("\"%s\": \"%s\"", expectedHeaderName, expectedValue); if (txt.indexOf(expectedLine) > 0) - return BluebirdPromise.resolve(); + return Bluebird.resolve(); else - return BluebirdPromise.reject(new Error(Util.format("No such header or with unexpected value."))); + return Bluebird.reject(new Error(Util.format("No such header or with unexpected value."))); }); - }) + }) \ No newline at end of file