Giter VIP home page Giter VIP logo

ermahgerd-rails-api-jwt's People

Contributors

nadnoslen avatar

Watchers

 avatar  avatar

ermahgerd-rails-api-jwt's Issues

Session Tracking Information

New table off of a session that tracks user last seen. Can write this information using sidekiq task. What information to store with each record?

  • ip_address - the ip address that the session originated from
  • resource_path - the resource request path

Authentication TODO

  • Logout Action
  • Refresh token expiry should prevent access token refreshes but it doesn't
  • Blacklist a refresh token
  • Do we store the session creation payload in the user table
  • Do we keep a history of sessions? Store host name, browser name, and browser signature?

Table To Record Refresh Attempts

It would be ideal to create a worker that tracks the success or failure of refresh tokens. On malicious refresh attempts, we should also find the Session from the supplied RUID and mark it as invalidated.

UserResource - Some Changes & Improvements

On Update, we should permit the password and password_confirmed fields. Put it in the self.updatable_fields override. Test it.

On Create, we should build a before a hook that automatically creates a password and password_confirmed field should it have not been passed in the payload. Put it in the self.creatable_fields override.

Last Activities VIEW

It's always nice to have the last of some user. For example, last seen would be the USERS' most recently created SESSION_ACTIVITIES record. This could be a column derived in a VIEW and could easily be rendered as a relationship to a USERS record.

CREATE VIEW users_last_activities AS
SELECT users.id,
(
  SELECT MAX(sa.created_at) 
  FROM session_activities sa INNER JOIN sessions s
  ON sa.session_id=s.id
  WHERE s.user_id=users.id
),
...
FROM users

Other last ideas from projects I've worked on:

  • last emailed
  • last IP
  • last browser

User Model - Account Activated On

Record the date that an account was activated on. Could also record when the account is deactivated. How about when reactivated?!? Vicious circle.

Refactor - `AuthenticationsController` to become `CookieAuthenticationsController`

Make room for authenticating in one of two ways:

  1. Cookie-based authentication will store your access token in a cookie and a CSRF token will be required for every PATCH/PUT/DELETE (CookieAuthenticationsController)
  2. Token authentication will return you the access token which you are responsible for saving safely and then passing with every request to protected resources (TokenAuthenticationsController)

Immediate Flush Of Access Token

We already store the RUID inside the database's Session table. When a request to invalidate occurs, we ask JWTSessions::Session to locate the refresh token by RUID and invalidate it. We could at the same time effectively expire/destroy the associated access token as the refresh token maintains a reference to the access token.

If that doesn't work, we could store both the RUID (refresh) & UID (access) in our Sessions table.

Check out https://github.com/tuwukee/jwt_sessions#flush-sessions in the jwt_sessions gem.

Invite User To Set Password

Invitation should expire.
Expired invitations should permit visiting user to click a link to send additional invitation to self.
New invitation_status enum on User model with the following choices: Uninvited, Invited, and Accepted. This is a system status, it will never be updated through the API

Dress Up Some BASIC User Roles

Administrator - no brainer. Can do pretty much everything CRUD-wise
Member or User or Authenticated User or Guest - a basic authenticated user that is restricted in some manner

Dan doesn't love the role named User because it seems redundant. Brad doesn't like Guest as he associates anonymous access with the phrase. Brad also dislikes Member.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.