Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anandpilania/f3-token-middleware
Token authentication middleware for FatFreeFramework
https://github.com/anandpilania/f3-token-middleware
f3 f3-auth f3-middleware fatfree-framework secure-api token-authetication
Last synced: about 1 month ago
JSON representation
Token authentication middleware for FatFreeFramework
- Host: GitHub
- URL: https://github.com/anandpilania/f3-token-middleware
- Owner: AnandPilania
- License: other
- Created: 2019-08-12T16:29:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-08-14T11:48:25.000Z (over 5 years ago)
- Last Synced: 2024-04-16T08:03:06.046Z (8 months ago)
- Topics: f3, f3-auth, f3-middleware, fatfree-framework, secure-api, token-authetication
- Language: PHP
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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](https://github.com/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();`