Skip to content

lib/anubis: support setting extended cookie flags#120

Merged
Xe merged 3 commits intomainfrom
Xe/cookie-settings
Mar 26, 2025
Merged

lib/anubis: support setting extended cookie flags#120
Xe merged 3 commits intomainfrom
Xe/cookie-settings

Conversation

@Xe
Copy link
Copy Markdown
Contributor

@Xe Xe commented Mar 25, 2025

Closes #73

Checklist:

  • Added a description of the changes to the [Unreleased] section of docs/docs/CHANGELOG.md
  • Tested this at least manually
  • Added a dedicated test case

Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe Xe requested a review from Copilot March 25, 2025 22:08
@Xe Xe self-assigned this Mar 25, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances Anubis by enabling extended cookie configuration (domain, name, and partitioned flag) to support CHIPS and better customization.

  • Updated test cases to validate extended cookie settings.
  • Added new CLI flags for cookie parameters in the main command.
  • Modified cookie handling in lib/anubis.go and lib/http.go to apply the new options.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/anubis_test.go Updated tests to load policies and verify cookie properties.
cmd/anubis/main.go Introduced new flags for cookie-domain, cookie-name, and cookie-partitioned.
docs/docs/CHANGELOG.md Documented the addition of extended cookie options.
lib/anubis.go Integrated new cookie options into server initialization and handling.
lib/http.go Modified ClearCookie to use the extended cookie options from server config.
Files not reviewed (1)
  • docs/docs/admin/installation.mdx: Language not supported
Comments suppressed due to low confidence (1)

lib/anubis.go:250

  • The cookie is retrieved using the constant anubis.CookieName, but when setting the cookie the code uses s.opts.CookieName. To ensure consistency when custom cookie names are configured, update the cookie retrieval to use s.opts.CookieName.
ckie, err := r.Cookie(anubis.CookieName)

Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe Xe requested a review from Copilot March 26, 2025 00:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for extended cookie flags to Anubis by introducing new configuration options and updating both server logic and tests.

  • Adds new Options fields for cookie configuration (domain, name, partitioned).
  • Updates cookie handling in the server and HTTP layers to use the new options.
  • Introduces corresponding command-line flags and updates the test to verify cookie settings.

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/anubis_test.go Updates test helper functions and cookie validation logic
cmd/anubis/main.go Adds new command-line flag options for cookie configuration
docs/docs/CHANGELOG.md Documents the addition of cookie configuration options
lib/anubis.go Integrates new cookie options into server creation and request handling
lib/http.go Refactors ClearCookie into a method, using the new cookie options
Files not reviewed (1)
  • docs/docs/admin/installation.mdx: Language not supported

Comment thread lib/anubis_test.go
| :------------------------ | :--------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `BIND` | `:8923` | The network address that Anubis listens on. For `unix`, set this to a path: `/run/anubis/instance.sock` |
| `BIND_NETWORK` | `tcp` | The address family that Anubis listens on. Accepts `tcp`, `unix` and anything Go's [`net.Listen`](https://pkg.go.dev/net#Listen) supports. |
| `COOKIE_DOMAIN` | unset | The domain the Anubis challenge pass cookie should be set to. This should be set to the domain you bought from your registrar (EG: `techaro.lol` if your webapp is running on `anubis.techaro.lol`). See [here](https://stackoverflow.com/a/1063760) for more information. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to mention that under all domains the same anubis or the same secrets should be used?

Signed-off-by: Xe Iaso <me@xeiaso.net>
@Xe Xe merged commit e7cbd34 into main Mar 26, 2025
2 checks passed
Xe added a commit that referenced this pull request Mar 27, 2025
Xe added a commit that referenced this pull request Mar 27, 2025
Xe added a commit that referenced this pull request Mar 27, 2025
JasonLovesDoggo pushed a commit to JasonLovesDoggo/anubis that referenced this pull request Jun 17, 2025
* lib/anubis: support setting extended cookie flags

Signed-off-by: Xe Iaso <me@xeiaso.net>

* lib: use cookie name consistently

Signed-off-by: Xe Iaso <me@xeiaso.net>

---------

Signed-off-by: Xe Iaso <me@xeiaso.net>
JasonLovesDoggo pushed a commit to JasonLovesDoggo/anubis that referenced this pull request Jun 17, 2025
@Xe Xe deleted the Xe/cookie-settings branch July 2, 2025 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cookie: domain-wide cookies

4 participants