diff --git a/anubis.go b/anubis.go index 5d3b8c4..6b219ca 100644 --- a/anubis.go +++ b/anubis.go @@ -11,9 +11,11 @@ var Version = "devel" // CookieName is the name of the cookie that Anubis uses in order to validate // access. -const CookieName = "techaro.lol-anubis-auth" +var CookieName = "techaro.lol-anubis-auth" -const TestCookieName = "techaro.lol-anubis-cookie-test-if-you-block-this-anubis-wont-work" +// TestCookieName is the name of the cookie that Anubis uses in order to check +// if cookies are enabled on the client's browser. +var TestCookieName = "techaro.lol-anubis-cookie-verification" // CookieDefaultExpirationTime is the amount of time before the cookie/JWT expires. const CookieDefaultExpirationTime = 7 * 24 * time.Hour diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index aeb8b85..7bb20c6 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -48,6 +48,7 @@ var ( cookieDomain = flag.String("cookie-domain", "", "if set, the top-level domain that the Anubis cookie will be valid for") cookieDynamicDomain = flag.Bool("cookie-dynamic-domain", false, "if set, automatically set the cookie Domain value based on the request domain") cookieExpiration = flag.Duration("cookie-expiration-time", anubis.CookieDefaultExpirationTime, "The amount of time the authorization cookie is valid for") + cookiePrefix = flag.String("cookie-prefix", "techaro.lol-anubis", "prefix for browser cookies created by Anubis") cookiePartitioned = flag.Bool("cookie-partitioned", false, "if true, sets the partitioned flag on Anubis cookies, enabling CHIPS support") hs512Secret = flag.String("hs512-secret", "", "secret used to sign JWTs, uses ed25519 if not set") ed25519PrivateKeyHex = flag.String("ed25519-private-key-hex", "", "private key used to sign JWTs, if not set a random one will be assigned") @@ -374,6 +375,9 @@ func main() { slog.Warn("REDIRECT_DOMAINS is not set, Anubis will only redirect to the same domain a request is coming from, see https://anubis.techaro.lol/docs/admin/configuration/redirect-domains") } + anubis.CookieName = *cookiePrefix + "-auth" + anubis.TestCookieName = *cookiePrefix + "-cookie-verification" + // If OpenGraph configuration values are not set in the config file, use the // values from flags / envvars. if !policy.OpenGraph.Enabled { diff --git a/docs/docs/CHANGELOG.md b/docs/docs/CHANGELOG.md index d74e538..04836fb 100644 --- a/docs/docs/CHANGELOG.md +++ b/docs/docs/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Determine the `BIND_NETWORK`/`--bind-network` value from the bind address ([#677](https://github.com/TecharoHQ/anubis/issues/677)) - Implement localization system. Find locale files in lib/localization/locales/. - Fix dynamic cookie domains functionality ([#731](https://github.com/TecharoHQ/anubis/pull/731)) +- Add option for custom cookie prefix ([#732](https://github.com/TecharoHQ/anubis/pull/732)) ## v1.20.0: Thancred Waters