planetadeleste/oc-jwtauth-plugin

JSON Web Token Authentication plugin for OctoberCMS with Lovata.Buddies

Installs: 37

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 28

Type:october-plugin

1.3.5 2021-05-07 11:42 UTC

This package is auto-updated.

Last update: 2024-10-07 18:56:28 UTC


README

Known Vulnerabilities

Introduction

This plugin is a fork of rluders/oc-jwtauth-plugin, adapted to be used with Lovata.Buddies plugin instead of RainLab.Users

This plugin provides a JSON Web Tokens authentication mechanism for OctoberCMS integrated with Lovata.Buddies. It's essential for your web application built with Angular, Vue.js, React or other modern Javascript frameworks.

Requirements

Theme

Tutorials

Installation

Yes, you can install it from the repository (but I'll not provide a documentation for that - in this case I'll assume that you know what you are doing). I strongly recommend that you install it from product page inside the OctoberCMS Marketplace.

Configuration

You must set a secret token for your application. Do do it, on October's Backend access: Settings > Users > JWTAuth

Usage

Here's the list of available endpoints for this plugin.

If you are using Postman, you can click here to import the collection with all the calls that you need to test it.

Login

POST /api/auth/login

Route name

api.auth.login

Parameters

The field login value can be the account email or username. You can select it on RainLab.User configuration what field should be used for login.

Responses

SUCCESS

Code: 200

{
  token: (string),
  user: (object)
}

ERROR

Code: 401

{
  error: (invalid_credentials|could_not_create_token|user_inactive|user_is_banned)
}

Register

POST /api/auth/register

Route name

api.auth.register

Parameters

The field username can be required. It depends of your RainLab.User configuration.

Responses

SUCCESS

Code: 201

[]

ERROR

Code: 401

{
  error: (object|registration_disabled)
}

Supported events

  • rainlab.user.beforeRegister
  • rainlab.user.register

Account Activation

POST /api/auth/account-activation

Route name

api.auth.account-activation

Parameters

Responses

SUCCESS

Code: 200

[]

ERROR

Code: 422

{
  error: (invalid_activation_code|invalid_user|user_not_found)
}

Forgot Password

POST /api/auth/forgot-password

Route name

api.auth.forgot-password

Parameters

Responses

SUCCESS

Code: 200

[]

ERROR

Code: 404

{
  error: (user_not_found)
}

Reset Password

POST /api/auth/reset-password

Route name

api.auth.reset-password

Parameters

Responses

SUCCESS

Code: 200

[]

ERROR

Code: 422

{
  error: (invalid_reset_password_code|invalid_user|invalid_reset_password_code)
}

Refresh Token

POST /api/auth/refresh-token

Route name

auth.api.refresh-token

Parameters

Responses

SUCCESS

Code: 200

{
  token: (string)
}

ERROR

Code: 403

{
  error: (could_not_refresh_token|given_token_was_blacklisted)
}

Get User

GET /api/auth/me

Middleware

jwt.auth

Route name

api.auth.me

Parameters

Responses

SUCCESS

Code: 200

{
  user: (object)
}

ERROR

Code: 404

{
  error: (user_not_found)
}

Known issues

Beside the fact that I'm always trying to solve the possible issues, bad things could happen. Here, an list of possible issues and how to fix it.

Note to Apache users

In order to use the authorization Bearer Token you must add the following code to your .httaccess

RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

License

GPLv3