https://github.com/codenoid/phoenix-auth-example
Phoenix authentication example with ETS, Multi Session & Single Session example
https://github.com/codenoid/phoenix-auth-example
authentication elixir phoenix
Last synced: 8 months ago
JSON representation
Phoenix authentication example with ETS, Multi Session & Single Session example
- Host: GitHub
- URL: https://github.com/codenoid/phoenix-auth-example
- Owner: codenoid
- Created: 2019-05-08T15:37:22.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T12:53:20.000Z (about 3 years ago)
- Last Synced: 2025-04-22T17:13:42.940Z (10 months ago)
- Topics: authentication, elixir, phoenix
- Language: Elixir
- Size: 2.1 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Phoenix Auth Example
so basically :
1. Multi Session is just like facebook, gmail or github, you can login anywhere without terminating other session
2. Single Session is, when you login (new session), your old session will be terminated (logged out)
Multi Session Tech :
- I only use phoenix session to save session data
https://github.com/codenoid/phoenix-auth-example/blob/master/multi/lib/multi_web/controllers/page_controller.ex
https://github.com/codenoid/phoenix-auth-example/blob/master/multi/lib/multi_web/helper/session.ex
Single Session Tech :
- I use ETS for saving where this username is assigned for (*for guid cookie)
- Phoenix session to save session data
- I prefer to use redis (ETS replacement for scaling)
https://github.com/codenoid/phoenix-auth-example/blob/master/single/lib/single/application.ex
https://github.com/codenoid/phoenix-auth-example/blob/master/single/lib/single_web/controllers/page_controller.ex
https://github.com/codenoid/phoenix-auth-example/blob/master/single/lib/single_web/helper/session.ex
## Usage
```bash
git clone https://github.com/codenoid/phoenix-auth-example
cd phoenix-auth-example
cd single # pick one
mix deps.get
cd assets && npm install
cd .. && mix phx.server
google-chrome "http://localhost:4000" # login 1
google-chrome "http://localhost:4000" --incognito # login 2, login 1 will be destroyed
```