Plugin Directory

Changeset 1247722


Ignore:
Timestamp:
09/17/2015 02:59:18 PM (11 years ago)
Author:
glena
Message:

Release new version

Location:
wp-jwt-auth/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-jwt-auth/trunk/JWT_AUTH.php

    r1168653 r1247722  
    33 * Plugin Name: Wordpress JWT Authentication
    44 * Description: Implements JWT Authentication for APIs
    5  * Version: 1.1.0
     5 * Version: 1.1.1
    66 * Author: Auth0
    77 * Author URI: https://auth0.com
     
    2222        add_filter("plugin_action_links_$plugin", array(__CLASS__, 'wp_add_plugin_settings_link'));
    2323
    24         add_action( 'init', array( __CLASS__, 'add_headers' ), 99 );       
     24        add_action( 'init', array( __CLASS__, 'add_headers' ), 99 );
    2525
    2626        JWT_AUTH_UsersRepo::init();
     
    3131
    3232    public static function add_headers() {
    33         header('Access-Control-Allow-Origin:'. get_http_origin()); 
    34         header('Access-Control-Allow-Credentials: true'); 
     33        header('Access-Control-Allow-Origin:'. get_http_origin());
     34        header('Access-Control-Allow-Credentials: true');
    3535
    3636        if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
    3737            if ( isset( $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] ) ) {
    38                 header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); 
     38                header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
    3939            }
    4040            if ( isset( $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] ) ) {
    41                 header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']); 
     41                header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
    4242            }
    4343            die('options');
  • wp-jwt-auth/trunk/README.md

    r1168653 r1247722  
    11#Wordpress JWT Authentication
    22
    3 This plugin targets to add JWT authentication to Wordpress API's provided by plugins.
     3Authenticate your APIs with JWT easily.
    44
    55##Configuration
     
    1010- **JWT Attribute**: should match the User Property to determine the user.
    1111
     12##How it works
     13
     14This plugin will check the headers of the requests and if there is an `Authorization` header will try to log in a user that matches. So it is as easy to check for the current user to authenticate users in your own API.
     15
     16Also, it provides support for the following plugins:
     17- http://wp-api.org/
     18- http://docs.woothemes.com/document/woocommerce-rest-api/
     19
     20And any other that extends `Wp Rest Api` like http://tweichart.github.io/JSON-API-for-BuddyPress/ for BuddyPress.
     21
     22
    1223##Overriding the User Repository logic
    13 The user repository is the responsible of retriving the user based on the JWT. By default, it looks in the user database to match the *User Property* and the *JWT Attribute*. 
     24The user repository is the responsible of retriving the user based on the JWT. By default, it looks in the user database to match the *User Property* and the *JWT Attribute*.
    1425
    15 If you need to override the way the user matching is made (ie: you need to look to another table in the database) you can create your own User Repostory and match the user as you need. 
     26If you need to override the way the user matching is made (ie: you need to look to another table in the database) you can create your own User Repostory and match the user as you need.
    1627
    1728To accomplish this, you need to add a filter:
    1829
    1930```
    20     add_filter( 'wp_jwt_auth_get_user', array( __CLASS__, 'getUser' ),10);
     31    add_filter( 'wp_jwt_auth_get_user', array( __CLASS__, 'get_user' ),10);
    2132```
    2233
  • wp-jwt-auth/trunk/lib/JWT_AUTH_UserProcessor.php

    r1168653 r1247722  
    4444        $overrideUserRepo = JWT_AUTH_Options::get('override_user_repo');
    4545
    46         return apply_filters( 'wp_jwt_auth_get_user', $jwt, $encodedJWT );
     46        $response = apply_filters( 'wp_jwt_auth_get_user', $jwt, $encodedJWT );
     47
     48        return $response;
    4749    }
    4850
     
    5860        global $wp_json_basic_auth_error;
    5961
    60         $wp_json_basic_auth_error = null;
     62          $wp_json_basic_auth_error = null;
    6163
    6264        $authorization = self::getAuthorizationHeader();
  • wp-jwt-auth/trunk/readme.txt

    r1156142 r1247722  
    66License URI: https://github.com/auth0/wp-jwt-auth/blob/master/LICENSE.md
    77Stable tag: trunk
    8 Contributors: glena
     8Contributors: glena, auth0
    99
    10 This plugin targets to add JWT authentication to Wordpress API's provided by plugins.
     10Authenticate your APIs with JWT easily.
    1111
    1212== Description ==
    1313
    14 This plugin targets to add JWT authentication to Wordpress API's provided by plugins.
     14This plugin targets to add a easy way to authenticate your APIs using JWT.
     15
     16Also, it provides a basic way to match the users and allow you to extend base on your needs easily with a filter.
     17
     18How it works
     19
     20This plugin will check the headers of the requests and if there is an `Authorization` header will try to log in a user that matches. So it is as easy to check for the current user to authenticate users in your own API.
     21
     22Also, it provides support for the following plugins:
     23- http://wp-api.org/
     24- http://docs.woothemes.com/document/woocommerce-rest-api/
     25
     26And any other that extends `Wp Rest Api` like http://tweichart.github.io/JSON-API-for-BuddyPress/ for BuddyPress.
    1527
    1628== Installation ==
     
    19312. Activate the plugin through the 'Plugins' menu in WordPress.
    20323. Access to the plugin settings and configure the keys and how should it match the users.
     33
     34- Aud: represents the client id which the JWT was sent.
     35- Secret: used to verify the JWT signature
     36- Base64 Secret Encoded: it must be active if the secret is base64 encoded and needs to be decoded before checkig the signature.
     37- User Property: is the property which much match with the JWT attribute to determine the user.
     38- JWT Attribute: should match the User Property to determine the user.
     39
     40or extend it implementing a filter:
     41
     42add_filter( 'wp_jwt_auth_get_user', 'get_user',10);
     43
     44function get_user($jwt) {
     45  ...
     46}
     47
     48To see an example, check the UsersRepo (https://github.com/auth0/wp-jwt-auth/blob/master/lib/JWT_AUTH_UsersRepo.php).
Note: See TracChangeset for help on using the changeset viewer.