Giter Site home page Giter Site logo

f3-token-middleware's Introduction

f3-token-middleware

Just pass your token secure routes [/ OR '/secure/*'] & handler to f3-token-middleware & relax... it will check requests pattern + token & execute your handler if token not found.

NOTE: This package built/ported from ikkez/f3-middleware.

CHECK example.file for sample

Install

  `composer require anandpilania/f3-token-middleware`

## Usage

  • 1: Configure f3:

    `$f3->mset(array(
    
        'TOKEN' => array(
      	  'TYPE' => 'HEADER', // HEADER|QUERY
      	  
            'KEY' => 'Authorization', // TOKEN KEY
            
            'STARTS_WITH' => 'X-Auth-Token', // TOKEN KEY STARTS WITH (supports only HEADER type) -> "Authorization: X-Auth-Token xxxxxxxx"
            
            'TABLE' => 'Models\Token', // FQCN
            
            'TABLE_KEY' => 'token' // KEY, which you used to store the token value in table
            
        )
        
    ));`
    
  • 2: Initialize in your main bootstrap file:

    `$tokenMiddleware = new TokenMiddleware();`
    
  • 3: Protect routes/pattern:

    `$tokenMiddleware->protect(array('GET|POST|PUT|DELETE /home/*', 'POST /profile'), function($f3, $params, $alias) {
    
        // YOUR FUNCTION, IF 'TOKEN' NOT SUPPLIED
        
    });`
    
  • 4: RUN:

    `$tokenMiddleware->run();`
    

f3-token-middleware's People

Contributors

anandpilania avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

dappcenter

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.