Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
erp5
erp5
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Merge Requests 107
    • Merge Requests 107
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Jobs
  • Commits
  • nexedi
  • erp5erp5
  • Merge Requests
  • !138

Open
Opened Jul 06, 2016 by Cédric Le Ninivin@cedric.leninivin2 of 5 tasks completed2/5 tasks
  • Report abuse
Report abuse

WIP: ERP5Security: Add JSON Web Token for authentication

A new Pluggable Authentication Plugin for PAS using JSON Web Token (JWT) has been implmented ERP5. It provides two services:

  • ILoginPasswordHostExtractionPlugin to extract JWT
  • IAuthenticationPlugin to set JWT upon user validation

It uses one cookie to authenticate:

  • erp5_jwt when doing Same Site request
  • erp5_cors_jwt when doing Request from other Domains

Here is an example of erp5_jwt cookie HEADER

{
  "alg": "HS256",
  "typ": "JWT"
}

erp5_jwt payload:

{
  "iat": 1475828460,
  "sub": "person_module/1",
  "ptid": 268471363270312580
}

erp5_cors_jwt payload:

{
  "iat": 1475828460,
  "sub": "person_module/1",
  "ptid": 268471363270312580,
  "cors": ["https://domain1.com", "https://domain2.com"]
}

iat is the time of issue time, sub the relative url of the "user" and ptid the tid of the password. erp5_cors_jwt cookie adds cors containing the list of origin authorised to be Origin or Referer of a request.

The token is signed by a unique secret which can be updated (invalidating all current cookies) on the Plugin.

How to use:

  1. Add pyjwt to your software release
  2. Rebase this branch on top of yours
  3. Restart your zopes 😃
  4. Activate the Plugin. This step is not necessary if you created your ERP5 Site with this branch thanks to 696d5969.
  5. Access plugin management interface acl_users and add "ERP5 JSON Web Token Plugin".
  6. Activate the plugin as an
    • Extraction Plugins
    • Authentication Plugins
  7. Disable erp5_users plugin
  8. XXX This is temporary: Disable __ac cookie by commenting the lines setting the cookie in setAuthCookie
  9. jwt will take over on all new logins.

HowTo:

  • Invalidate Token of user: Use "Invalidate Token" Action on a user
  • Set Expiration Time for Token: Use "Set Expiration Time" tab on JWT plugin in acl_users

TODO:

  • Describe what problem is addressed by this MR
  • Give a high level description of the new authentication flow
  • Provide expiration date for the token. This expiration date should be configurable in the Plugin view
  • Add action on user to invalidate token
  • Update erp5_auto_logout and CookieCrumbler to not set __ac cookie when other plugins are in charge of authentication

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch https://lab.nexedi.com/cedric.leninivin/erp5.git jwt
git checkout -b cedric.leninivin/erp5-jwt FETCH_HEAD

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/master
git merge --no-ff cedric.leninivin/erp5-jwt

Step 4. Push the result of the merge to GitLab

git push origin master

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 45
  • Commits 14
  • Changes 17
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: nexedi/erp5!138
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备14008524号