Skip to content

Commit 4e86ca3

Browse files
authored
Merge pull request #95 from ADmad/cake-4.x
Cake 4.x
2 parents 1b600be + fa72c5e commit 4e86ca3

File tree

16 files changed

+168
-184
lines changed

16 files changed

+168
-184
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ insert_final_newline = true
1111
trim_trailing_whitespace = true
1212

1313
[*.yml]
14-
indent_style = space
1514
indent_size = 2
15+
16+
[*.neon]
17+
indent_style = tab

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@
55
phpunit.xml export-ignore
66
.travis.yml export-ignore
77
tests export-ignore
8+
.phpstan.neon export-ignore
9+
.psalm.xml export-ignore
10+
.github export-ignore

.github/workflows/ci.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
testsuite:
7+
runs-on: ubuntu-18.04
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
php-version: ['7.4', '8.0']
12+
composer-opts: ['']
13+
include:
14+
- php-version: '7.2'
15+
composer-opts: '--prefer-lowest'
16+
17+
steps:
18+
- uses: actions/checkout@v1
19+
with:
20+
fetch-depth: 1
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php-version }}
26+
extension-csv: mbstring, intl
27+
coverage: pcov
28+
29+
- name: Composer install
30+
run: |
31+
composer update ${{ matrix.composer-opts }}
32+
33+
- name: Run PHPUnit
34+
run: |
35+
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
36+
vendor/bin/phpunit --coverage-clover=coverage.xml
37+
else
38+
vendor/bin/phpunit
39+
fi
40+
41+
- name: Code Coverage Report
42+
if: matrix.php-version == '7.4'
43+
uses: codecov/codecov-action@v1
44+
45+
cs-stan:
46+
name: Coding Standard & Static Analysis
47+
runs-on: ubuntu-18.04
48+
49+
steps:
50+
- uses: actions/checkout@v1
51+
with:
52+
fetch-depth: 1
53+
54+
- name: Setup PHP
55+
uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: '7.4'
58+
extension-csv: mbstring, intl
59+
coverage: none
60+
tools: cs2pr, psalm, phpstan
61+
62+
- name: Composer Install
63+
run: composer require cakephp/cakephp-codesniffer:^4.1
64+
65+
- name: Run phpcs
66+
run: vendor/bin/phpcs --report=checkstyle -q --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/ | cs2pr
67+
68+
- name: Run psalm
69+
if: success() || failure()
70+
run: psalm --output-format=github
71+
72+
- name: Run phpstan
73+
if: success() || failure()
74+
run: phpstan analyse

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/composer.lock
22
/phpunit.xml
33
/vendor
4+
.phpunit.result.cache

.stickler.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2018 ADmad
3+
Copyright (c) 2015-Present ADmad
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CakePHP JWT Authenticate plugin
22

3-
[![Build Status](https://img.shields.io/travis/ADmad/cakephp-jwt-auth/master.svg?style=flat-square)](https://travis-ci.org/ADmad/cakephp-jwt-auth)
4-
[![Coverage](https://img.shields.io/codecov/c/github/ADmad/cakephp-jwt-auth.svg?style=flat-square)](https://codecov.io/github/ADmad/cakephp-jwt-auth)
3+
[![Build Status](https://img.shields.io/github/workflow/status/ADmad/cakephp-jwt-auth/CI/master?style=flat-square)](https://github.com/ADmad/cakephp-jwt-auth/actions?query=workflow%3ACI+branch%3Amaster)
4+
[![Coverage Status](https://img.shields.io/codecov/c/github/ADmad/cakephp-jwt-auth.svg?style=flat-square)](https://codecov.io/github/ADmad/cakephp-jwt-auth)
55
[![Total Downloads](https://img.shields.io/packagist/dt/ADmad/cakephp-jwt-auth.svg?style=flat-square)](https://packagist.org/packages/ADmad/cakephp-jwt-auth)
66
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE.txt)
77

@@ -17,14 +17,7 @@ composer require admad/cakephp-jwt-auth
1717

1818
## Usage
1919

20-
In your app's `config/bootstrap.php` add:
21-
22-
```php
23-
// In config/bootstrap.php
24-
Plugin::load('ADmad/JwtAuth');
25-
```
26-
27-
or using cake's console:
20+
Load the plugin using Cake's console:
2821

2922
```sh
3023
./bin/cake plugin load ADmad/JwtAuth
@@ -36,7 +29,7 @@ Setup `AuthComponent`:
3629

3730
```php
3831
// In your controller, for e.g. src/Api/AppController.php
39-
public function initialize()
32+
public function initialize(): void
4033
{
4134
parent::initialize();
4235

@@ -97,9 +90,9 @@ The authentication class checks for the token in two locations:
9790
RewriteCond %{HTTP:Authorization} ^(.*)
9891
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
9992
```
100-
93+
10194
or
102-
95+
10396
```
10497
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
10598
```
@@ -109,9 +102,11 @@ The authentication class checks for the token in two locations:
109102
You can use `\Firebase\JWT\JWT::encode()` of the [firebase/php-jwt](https://github.com/firebase/php-jwt)
110103
lib, which this plugin depends on, to generate tokens.
111104

112-
**The payload should have the "sub" (subject) claim whose value is used to query the
105+
**The payload must have the "sub" (subject) claim whose value is used to query the
113106
Users model and find record matching the "id" field.**
114107

108+
Ideally you should also specify the token expiry time using `exp` claim.
109+
115110
You can set the `queryDatasource` option to `false` to directly return the token's
116111
payload as user info without querying datasource for matching user record.
117112

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
"issues":"https://github.com/ADmad/cakephp-jwt-auth/issues"
2323
},
2424
"require": {
25-
"cakephp/cakephp": "^3.5",
25+
"cakephp/cakephp": "^4.0",
2626
"firebase/php-jwt": "^5.0"
2727
},
2828
"require-dev": {
29-
"cakephp/chronos": "^1.1",
30-
"phpunit/phpunit": "^5.7.14|^6.0"
29+
"phpunit/phpunit": "~8.5.0"
3130
},
3231
"autoload": {
3332
"psr-4": {

0 commit comments

Comments
 (0)