Giter VIP home page Giter VIP logo

cakephp2-jwt-auth's Introduction

CakePHP 2.x JWT Authentication (DEAD)

This project is no longer being actively developed.

This plugin is a CakePHP 2.x Authentication component and view helper for JWT.

Components

  • Auth/JwtTokeAuthenticate - A JSON Web Token implementation for CakePHP 2.6.x

Helpers

  • AuthHelper - Utility functions for helping with the authentication of users.

Requirements

  • PHP version: PHP 5.3+
  • CakePHP version: 2.6 Stable

Support

For support and feature request, please visit the JWT Authentication Plugin Support section.

License

Copyright 2011 - 2014, Florian Krämer Copyright 2015, Ronald Chaplin

Licensed under The MIT License
Redistributions of files must retain the above copyright notice.

Copyright

Copyright 2011 - 2014 Florian Krämer http://github.com/burzum

Copyright 2015 Ronald Chaplin http://github.com/t73biz

Version

1.0.6

Installation

composer require t73biz/cakephp2-jwt-auth 1.0.6

This will install into the Plugin directory (in the JwtAuth folder). To run the tests, simply navigate to your webroot/test.php and follow the links for the test cases for the Authentication Adapter.

Usage

Configuration

You can either declare this in your Controller's $components array, or on the fly in an action (if you need to load any configuration values, which you can't do when declaring in the $components array, for example).

public $components = array(
    'Auth' => array(
        'authenticate' => array(
            'JwtAuth.JwtToken' => array(
                'fields' => array(
                    'username' => 'username',
                    'password' => 'password',
                    'token' => 'public_key',
                ),
                'parameter' => '_token',
                'userModel' => 'User',
                'scope' => array('User.active' => 1),
                'pepper' => 'sneezing',
            ),
        ),
    ),
);

Or

$this->Auth->authenticate['JwtAuth.JwtToken'] = array(
    'fields' => array(
        'username' => 'username',
        'password' => 'password',
        'token' => 'public_key',
    ),
    'parameter' => '_token',
    'userModel' => 'User',
    'scope' => array('User.active' => 1),
    'pepper' => Configure::read('API.token.pepper'),
);

Where (excluding common authentication items):

  • fields is an array containing the details of which passed values (POSTed) contain the username, password and token
    • token is used to hold a unique key against the user once authenticated and is also stored in the JWT
  • parameter is the query string parameter that could hold the JWT
  • header is the HTTP header that could hold the JWT
  • pepper is the salt to use when encrypting your JWT (keep this super secret!)

Defaults

array(
    'fields' => array(
        'username' => 'username',
        'token' => 'token'
    ),
    'parameter' => '_token',
    'header' => 'X_JSON_WEB_TOKEN',
    'userModel' => 'User',
    'scope' => array(),
    'recursive' => 0,
    'contain' => null,
    'pepper' => '123'
);

Authentication

You can authenticate by passing a valid JWT as either:

  • The query string parameter defined as parameter in the config array (defaults to _token)
  • The contents of the header defined as header in the config array (defaults to X_JSON_WEB_TOKEN)

TODO

Implement an end to end example for inside clients and 3rd party client usage.

cakephp2-jwt-auth's People

Contributors

alevilar avatar codeeverything avatar t73biz avatar

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.