Download the PHP package sinbadxiii/phalcon-auth-jwt without Composer

On this page you can find all versions of the php package sinbadxiii/phalcon-auth-jwt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phalcon-auth-jwt

Phalcon JWT Auth

Example micro app sinbadxiii/phalcon-auth-jwt-example

Additional JWT guard for the Phalcon authentication library sinbadxiii/phalcon-auth

Banner

Packagist Downloads Latest Version

Demo

Banner

Requirements

Phalcon: ^5

PHP: ^7.4 || ^8.1

Installation

Install via composer

Run the following command to pull in the latest version::

composer require "sinbadxiii/phalcon-auth-jwt"

Add service provider

Configuration

Copy file from config/jwt.php in your folder config and merge your config

Generate secret key

Update the secret value in config jwt.php or JWT_SECRET value in your .env file.

Generate a 32 character secret phrase like here https://passwordsgenerator.net/

Update your User model

Firstly you need to implement the Sinbadxiii\PhalconAuthJWT\JWTSubject contract on your User model, which requires that you implement the 2 methods getJWTIdentifier() and getJWTCustomClaims().

The example below:

Create auth access, for example "jwt"

Set as a guard JWT

Here we are telling the api guard to use the jwt driver, and we are setting the api guard as the default.

We can now use Phalcon Auth with JWT guard.

Add some basic handlers

Example Auth Login Controller

Attach Middleware

Example code for middleware:

and attach:

You should now be able to POST to the login endpoint (e.g. http://0.0.0.0:8000/auth/login) with some valid credentials and see a response like:

There are a number of ways to send the token via http:

Authorization header:

Authorization Bearer eyJ0eXAiOiJKV1QiLC...

Query string param:

http://0.0.0.0:8000/me?token=eyJ0eXAiOiJKV1QiLC...

Exceptions

Methods

Multiple Guards

attempt()

Attempt to authenticate a user via some credentials.

This will return either a jwt or null

login()

Log a user in and return a jwt for them.

user()

Get the currently authenticated user.

If the user is not then authenticated, then null will be returned.

logout()

Log the user out - which will invalidate the current token and unset the authenticated user.

refresh()

Refresh a token, which invalidates the current one

invalidate()

Invalidate the token (add it to the blacklist)

tokenById()

Get a token based on a given user's id.

payload()

Get the raw JWT payload

validate()

Validate a user's credentials

More advanced usage

Adding custom claims

Set the token explicitly

Check token

Checking the token for correctness

Will return true if everything is ok or Exceptions:

License

The MIT License (MIT). Please see License File for more information.


All versions of phalcon-auth-jwt with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.1
nesbot/carbon Version ^2.0
sinbadxiii/phalcon-auth Version ^v2.0.0
lcobucci/jwt Version ^4.0
ext-phalcon Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sinbadxiii/phalcon-auth-jwt contains the following files

Loading the files please wait ....