PerlDancer / PerlDancer/Dancer2

Tying a session to a domain

Open
#1,035 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
604
Forks
288
Avg merge
1d 5h
Merged PRs (30d)
5

Description

Hi,

I'd like to be able to tie a session to the domain it originated from. E.g. if a user accesses an app using domain1.com (subsequently generating a session for that site), and then uses domain2.com to access the same site but using the cookie from domain1.com, I'd like that to fail.

The reason is that I am hosting multiple sites at the same app, and would like to prevent "strange" behaviour that results in the above (e.g. a user from the wrong site is returned when using Plugin::Auth::Extensible)

The best way I can see to do this would be to add an additional domain parameter to _flush and _retrieve in Dancer2::Core::Role::SessionFactory, and then (optionally) set and check the domain when interacting with sessions.

I've got most of the above working as a proof of concept, but it's occurred to me that it's quite a big change. So, I'd just like to request some feedback, before I spend any more time on this.

Thanks,

Andy

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing Dancer2::Core::Role::SessionFactory, especially the _flush and _retrieve entry points, and inspect how Plugin::Auth::Extensible uses sessions. Done means the design can associate a session with its originating domain and reject reuse from another hosted domain without breaking existing session behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
authentication, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.