Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
8404b3d
docs: small improvements
kenjis Oct 9, 2023
36a41fd
Merge pull request #890 from kenjis/docs-RELEASE.md
kenjis Oct 9, 2023
dbdafb1
[Rector] Apply StringifyStrNeedlesRector
samsonasik Oct 9, 2023
e0c53d7
Run Rector
samsonasik Oct 10, 2023
282c517
chore: it fails on master branch
kenjis Oct 10, 2023
1393c18
Fix php 7.4 substr can return false
samsonasik Oct 10, 2023
6fb9594
Fix php 7.4 substr can return false
samsonasik Oct 10, 2023
c7fbd21
Merge pull request #891 from samsonasik/str-needles
samsonasik Oct 10, 2023
f9bf1cf
Merge pull request #892 from kenjis/fix-no-merge-commits.yml
datamweb Oct 10, 2023
71e0ddc
fix: replace `/>` with `>` for input tags
kenjis Oct 10, 2023
5b4f165
docs: improve instructions
kenjis Oct 11, 2023
9dd8e44
Merge pull request #895 from kenjis/docs-improve-customization/login_…
kenjis Oct 11, 2023
ba07cfd
docs: add "Customizing Views"
kenjis Oct 11, 2023
d22a6ae
docs: fix directory separators
kenjis Oct 11, 2023
cae1d34
docs: fix text decoration for file paths
kenjis Oct 11, 2023
874e024
docs: add link to "Integrating Custom View Libraries"
kenjis Oct 11, 2023
0e7109d
Merge pull request #897 from kenjis/fix-customization/login_identifier
kenjis Oct 11, 2023
224a3bb
Merge pull request #894 from kenjis/fix-view-html5
kenjis Oct 11, 2023
fd2dff9
Merge pull request #896 from kenjis/docs-customization/views
kenjis Oct 11, 2023
b7d591a
chore: remove autoload of auth_helper.php by Composer
kenjis Oct 10, 2023
7c6a017
test: add 'auth' and 'setting' helper loading
kenjis Oct 10, 2023
81d2d75
feat: setup command configure helper autoloading
kenjis Oct 10, 2023
068be1f
docs: update docs
kenjis Oct 10, 2023
a8f2a8a
docs: add UPGRADING.md
kenjis Oct 10, 2023
ef50333
refactor: remove duplicated code
kenjis Oct 11, 2023
d2ea9d3
refactor: remove unneeded check
kenjis Oct 12, 2023
dbd6f5c
refator: remove code that loads setting helper
kenjis Oct 12, 2023
e167b69
fix: phpstan errors for new ver of phpstan-codeigniter
datamweb Oct 12, 2023
4219d62
Merge pull request #898 from datamweb/fix-new-CI-phpstan
datamweb Oct 12, 2023
577eb15
chore: update .gitignore
datamweb Oct 13, 2023
3eb3fac
add `array` for `$passwordValidators`
datamweb Oct 13, 2023
e5bfec1
Improved sample code for PHP file
datamweb Oct 13, 2023
ed7b7e5
add `<?php` and isolation route code
datamweb Oct 13, 2023
a185a33
add type for `$authenticators ` and `$defaultAuthenticator`
datamweb Oct 13, 2023
258dfb5
comment output resulte
datamweb Oct 13, 2023
fef4ff3
add `<?php` for PHP file
datamweb Oct 13, 2023
6c7ffb2
Merge pull request #902 from codeigniter4/datamweb-patch-2
datamweb Oct 13, 2023
189017e
Merge pull request #903 from codeigniter4/datamweb-fix-docs
datamweb Oct 13, 2023
1efc8f4
test: update DBDebug values
kenjis Oct 12, 2023
5676a07
test: replace empty() with isset()
kenjis Oct 12, 2023
8102411
Merge pull request #901 from kenjis/update-tests-Config-Registrar
kenjis Oct 13, 2023
7774592
Merge pull request #893 from kenjis/remove-autoload-auth_helper
kenjis Oct 15, 2023
ff2ea5c
docs: add note for removing email from registration
kenjis Oct 15, 2023
d6aad43
docs: add note on validation rules for registration
kenjis Oct 16, 2023
a0dffd1
docs: add "Adding Attributes to Users"
kenjis Oct 16, 2023
97cf0c0
docs: add/update doc comments
kenjis Oct 16, 2023
543a36a
refactor: rename variable name
kenjis Oct 16, 2023
97bda91
refactor!: defer instantiation of Authentication
kenjis Oct 16, 2023
5e6faf3
refactor!: add $config property
kenjis Oct 16, 2023
c12177a
refactor: remove unneeded property check
kenjis Oct 16, 2023
7d4bd5c
refactor: replace empty()
kenjis Oct 16, 2023
997023b
docs: use Config\Auth::$tables
kenjis Oct 17, 2023
4c4658c
docs: add missing ","
kenjis Oct 17, 2023
9fbdaf4
Merge pull request #906 from kenjis/docs-improve-customization/login_…
kenjis Oct 17, 2023
0b32ab9
Merge pull request #907 from kenjis/docs-adding_attributes_to_users
kenjis Oct 17, 2023
27f9983
fix date localized-plugin and refactor action
datamweb Oct 17, 2023
b42574d
Merge pull request #911 from datamweb/fix-mkdocs-date-localized-plugin
datamweb Oct 17, 2023
b1d32a6
feat: add `after_permission_denied` and `after_group_denied`
datamweb Aug 16, 2023
10660b6
feat: add filter name to filter class
datamweb Aug 16, 2023
bf6c733
feat: update AbstractAuthFilter
datamweb Aug 16, 2023
056e8be
tests: fix phpunit test
datamweb Aug 16, 2023
1eb0dce
fix: rector/phpstan error
datamweb Aug 16, 2023
e7f5c3e
refctor: rename methods and keys
datamweb Aug 17, 2023
a327eae
refactor: add `redirectToDeniedUrl()` for able inherit from `Abstract…
datamweb Aug 17, 2023
c37823e
add translation ID
kikuKeii Oct 17, 2023
0ba8263
docs: add how to properly upgrade for `$permission_denied`&`$group_de…
datamweb Oct 17, 2023
afa3095
add Auth.token in excludedLocaleKeyTranslations
kikuKeii Oct 17, 2023
0cd5f3f
Merge pull request #913 from kikuKeii/feature/translation-ID
datamweb Oct 17, 2023
a8287bb
fix: replace url_is()
kenjis Oct 18, 2023
6d5683a
docs: apply suggestions from code review
datamweb Oct 18, 2023
cc07d8e
update defaulte value `$hashCost` to 12
datamweb Oct 18, 2023
05826bc
tests: set hashCost=13 for fix test
datamweb Oct 18, 2023
1546bec
docs: use h3 for title
datamweb Oct 18, 2023
56ab89e
Merge pull request #790 from datamweb/feat-add-denied-for-filter
datamweb Oct 18, 2023
a879923
Merge pull request #916 from datamweb/update-hash-cost
datamweb Oct 18, 2023
46a6da7
Merge pull request #915 from kenjis/fix-remove-url_is
kenjis Oct 18, 2023
193b10d
docs: remove unneeded / from routes
datamweb Oct 19, 2023
c096fed
Merge pull request #917 from datamweb/docs-remove-unneeded
datamweb Oct 19, 2023
231bdf8
docs: fix email rule for mobileLogin
datamweb Oct 19, 2023
50fb634
Merge pull request #919 from codeigniter4/datamweb-patch-docs-1
datamweb Oct 19, 2023
f969893
docs: add logout to session except list
datamweb Oct 19, 2023
eef12ae
fix logout route for `{locale}`
datamweb Oct 20, 2023
485592b
happy phpstan for `forget()`
datamweb Oct 21, 2023
1ab829c
Merge pull request #923 from datamweb/happy-phpstan-for-forget
datamweb Oct 21, 2023
2d7cd7c
Merge pull request #921 from datamweb/docs-add-logout-to-except
datamweb Oct 21, 2023
47cf8c1
Merge pull request #908 from kenjis/perf-Auth
kenjis Oct 21, 2023
4a38857
phpstan: fix phpstan error
datamweb Oct 22, 2023
92b5755
Merge pull request #924 from datamweb/fix-phpstan-error
datamweb Oct 22, 2023
edbe659
style: add copyright to all files with linter
datamweb Oct 22, 2023
5d1dff3
chore(deps-dev): update rector/rector requirement from 0.18.5 to 0.18.6
dependabot[bot] Oct 25, 2023
500a3d0
Merge pull request #929 from codeigniter4/dependabot/composer/rector/…
datamweb Oct 25, 2023
851152f
tests: refactor test by rector 0.18.6
datamweb Oct 25, 2023
f93a3bb
docs: improve expression
kenjis Oct 25, 2023
582a6ae
docs: add note for filter $aliases
kenjis Oct 25, 2023
e17a766
Merge pull request #927 from datamweb/rector_upg
datamweb Oct 26, 2023
5b50267
Merge pull request #931 from kenjis/docs-filter-alias
datamweb Oct 26, 2023
50eaa11
Update Auth.php
ivanBell199 Oct 30, 2023
5852f30
Create ru/Auth.php
ivanBell199 Oct 30, 2023
d3b8bb8
Create RussianTranslationTest.php
ivanBell199 Oct 30, 2023
2ac8ce7
Update AbstractTranslationTestCase.php
ivanBell199 Oct 30, 2023
0cd4d2a
Merge pull request #935 from ivanBell199/ivanBell199-patch-1
datamweb Oct 30, 2023
6a57e3b
Merge pull request #936 from ivanBell199/ivanBell199-patch-2
datamweb Oct 30, 2023
a0fa3b8
docs: fix forum link
datamweb Oct 31, 2023
8e41922
Fix typo
datamweb Oct 31, 2023
f1c2150
Merge pull request #938 from codeigniter4/datamweb-patch-1
kenjis Nov 1, 2023
3fb1ae7
docs: fix change-available-groups links
datamweb Nov 10, 2023
668305c
docs: fix protecting-pages link
datamweb Nov 10, 2023
25b95fc
Merge pull request #945 from codeigniter4/datamweb-docs-fix-links
datamweb Nov 10, 2023
4f07bb0
Merge pull request #946 from codeigniter4/datamweb-patch-1
datamweb Nov 10, 2023
94d51cd
update rector requirement from 0.18.6 to 0.18.7
datamweb Nov 13, 2023
c35a973
chore: run rector 0.18.7
datamweb Nov 13, 2023
cd8b6a3
Merge pull request #948 from datamweb/rector-0187
samsonasik Nov 14, 2023
b90bdd3
chore(deps-dev): update rector/rector requirement from 0.18.7 to 0.18.8
dependabot[bot] Nov 14, 2023
368274b
Merge pull request #949 from codeigniter4/dependabot/composer/rector/…
samsonasik Nov 14, 2023
8935248
chore(deps-dev): update rector/rector requirement from 0.18.8 to 0.18.10
dependabot[bot] Nov 17, 2023
c4f08ed
Merge pull request #952 from codeigniter4/dependabot/composer/rector/…
samsonasik Nov 17, 2023
0dd2392
Update Auth.php
vasylzavalko Nov 19, 2023
704ebbd
Merge pull request #953 from vasylzavalko/patch-1
datamweb Nov 19, 2023
a76acb4
lang: [tr] fix param in `errorPasswordPwned`
datamweb Nov 19, 2023
b2908f9
lang: [uk] fix param in `errorPasswordPwned`
datamweb Nov 19, 2023
fb4142b
Merge pull request #954 from datamweb/lang-fix-param
datamweb Nov 19, 2023
fce00ac
Merge pull request #925 from datamweb/add-copyright-all-file
datamweb Nov 20, 2023
ae8ecaf
style: fix code styling by cs-fix
datamweb Nov 20, 2023
7d41423
Merge pull request #957 from datamweb/fix-style
kenjis Nov 20, 2023
6c7c18e
Initial update to encrypt secretKey
tswagger Oct 30, 2023
6d61e6d
Adjustment to test scripts to account for encryption.
tswagger Oct 30, 2023
4dc28ac
Added migration and updates to documentation
tswagger Oct 31, 2023
9ec7b68
Adjustments to documentation language
tswagger Nov 1, 2023
d02ccf4
Added HmacEncrypter class
tswagger Nov 1, 2023
27fee69
Fixed the upgrading documentation
tswagger Nov 1, 2023
5ddf5fc
Migrate moved to spark command
tswagger Nov 3, 2023
85b8db6
Added check to ensure stored keys do not exceed db column width
tswagger Nov 3, 2023
0acff4b
Rework of encryption methods
tswagger Nov 6, 2023
a68eb63
Added ability to rotate hmac encryption
tswagger Nov 12, 2023
20bc9f9
Updated documentation to reflect encryption key updates.
tswagger Nov 12, 2023
280c4e3
Rework of HMAC Encryption config properties.
tswagger Nov 13, 2023
76fc1fe
Update docs/references/authentication/hmac.md
tswagger Nov 14, 2023
303082b
Update docs/references/authentication/hmac.md
tswagger Nov 14, 2023
493ebc6
Removed old code
tswagger Nov 14, 2023
e5d81e4
Rework of encrypter so it can decrypt all
tswagger Nov 14, 2023
c20031d
Minor update to text output
tswagger Nov 14, 2023
a3e4219
Documentation text clarification
tswagger Nov 14, 2023
3d1077c
Update tests/Commands/HmacTest.php
tswagger Nov 15, 2023
0c8ef4c
Update tests/Commands/HmacTest.php
tswagger Nov 15, 2023
8dca06d
Update tests/Commands/HmacTest.php
tswagger Nov 15, 2023
f2552cd
Replaced $ in regex
tswagger Nov 15, 2023
bcad732
Removed double-spaces between sentences.
tswagger Nov 17, 2023
aa0d7f5
Trim of test output for Windows machines
tswagger Nov 17, 2023
5acf382
docs: fix markdown
kenjis Nov 20, 2023
795a214
docs: fix text decoration
kenjis Nov 20, 2023
2570a7c
Update of hmac encryption config values
tswagger Nov 21, 2023
ee6785c
Clean up of switch statement.
tswagger Nov 21, 2023
a11bc0d
Update src/Config/AuthToken.php
tswagger Nov 21, 2023
eb73c31
Update src/Config/AuthToken.php
tswagger Nov 21, 2023
dcd9aa9
Cleanup of AuthToken Var statements
tswagger Nov 21, 2023
c34aebc
Adjustment to test output
tswagger Nov 21, 2023
363183d
cs-fix updates
tswagger Nov 22, 2023
f77c6ae
Merge pull request from GHSA-v427-c49j-8w6x
kenjis Nov 22, 2023
0405d31
fix: Access Token Authenticator raw tokens are logged
kenjis Oct 19, 2023
b0b10b6
fix: HMAC Token Authenticator raw tokens are logged
kenjis Oct 19, 2023
3e48895
fix: JWT Authenticator raw tokens are logged
kenjis Oct 19, 2023
2424f13
test: remove unneeded assertions
kenjis Oct 19, 2023
02f5020
docs: add description for logging
kenjis Oct 20, 2023
26558aa
docs: move "Access Token Lifetime" into "Configuration"
kenjis Oct 21, 2023
eddc976
docs: add doc comment
kenjis Oct 22, 2023
651902d
docs: add note for app/Config/AuthToken.php
kenjis Oct 22, 2023
393ec3b
docs: add links to reference pages
kenjis Oct 22, 2023
725baaa
docs: remove duplicated description
kenjis Oct 22, 2023
7e84c3f
Merge pull request from GHSA-j72f-h752-mx4w
kenjis Nov 22, 2023
0fdd64f
Prep for release-1.0.0-beta.8 release
kenjis Nov 22, 2023
f8bec97
Merge pull request #958 from kenjis/release-1.0.0-beta.8
kenjis Nov 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,18 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- run: pip3 install mkdocs-material
- run: pip3 install mkdocs-git-revision-date-localized-plugin
- run: pip3 install mkdocs-redirects
- run: mkdocs gh-deploy --force
- name: Install Dependencies
run: |
pip3 install mkdocs-material
pip3 install mkdocs-git-revision-date-localized-plugin
pip3 install mkdocs-redirects
- name: Publish Shiled Documentation
run: mkdocs gh-deploy --force
2 changes: 2 additions & 0 deletions .github/workflows/no-merge-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Detect Merge Commits

on:
pull_request:
branches:
- develop

permissions:
contents: read
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ phpunit
vendor/
composer.lock

#-------------------------
# MkDocs
#-------------------------
site/

#-------------------------
# IDE / Development Files
#-------------------------
Expand Down
15 changes: 14 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

declare(strict_types=1);

/**
* This file is part of CodeIgniter Shield.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

use CodeIgniter\CodingStandard\CodeIgniter4;
use Nexus\CsConfig\Factory;
use PhpCsFixer\Finder;
Expand All @@ -28,4 +37,8 @@
'cacheFile' => 'build/.php-cs-fixer.cache',
];

return Factory::create(new CodeIgniter4(), $overrides, $options)->forProjects();
return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary(
'CodeIgniter Shield',
'CodeIgniter Foundation',
'admin@codeigniter.com'
);
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ and authorization purposes in web applications.
* Flexible Groups-based access control (think Roles, but more flexible)
* Users can be granted additional Permissions

See the [An Official Auth Library](https://codeigniter.com/news/shield) for more Info.
See the [An Official Auth Library](https://forum.codeigniter.com/showthread.php?tid=82003) for more Info.

## Getting Started

Expand Down
67 changes: 67 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
# Upgrade Guide

## Version 1.0.0-beta.7 to 1.0.0-beta.8

### Mandatory Config Changes

#### Helper Autoloading

Helper autoloading has been changed to be done by CodeIgniter's autoloader
instead of Composer.

So you need to update the settings. Run `php spark shield:setup` again, and the
following steps will be done.

1. Add `auth` and `setting` to the `$helpers` array in **app/Config/Autoload.php**:

```php
public $helpers = ['auth', 'setting'];
```

2. Remove the following code in the `initController()` method in
`**app/Controllers/BaseController.php**:

```php
$this->helpers = array_merge($this->helpers, ['setting']);
```

#### Config\Auth

The following items have been added. Copy the properties in **src/Config/Auth.php**.

- `permission_denied` and `group_denied` are added to `Config\Auth::$redirects`.
- `permissionDeniedRedirect()` and `groupDeniedRedirect()` are added.

### Fix Custom Filter If extends `AbstractAuthFilter`

If you have written a custom filter that extends `AbstractAuthFilter`, now you need to add and implement the `redirectToDeniedUrl()` method to your custom filter.
The following example is related to the above explanation for **group** filter.

```php
/**
* If the user does not belong to the group, redirect to the configured URL with an error message.
*/
protected function redirectToDeniedUrl(): RedirectResponse
{
return redirect()->to(config('Auth')->groupDeniedRedirect())
->with('error', lang('Auth.notEnoughPrivilege'));
}
```

### Fix to HMAC Secret Key Encryption

#### Config\AuthToken

If you are using the HMAC authentication you need to update the encryption settings in **app/Config/AuthToken.php**.
You will need to update and set the encryption key in `$hmacEncryptionKeys`. This should be set using **.env** and/or
system environment variables. Instructions on how to do that can be found in the
[Setting Your Encryption Key](https://codeigniter.com/user_guide/libraries/encryption.html#setting-your-encryption-key)
section of the CodeIgniter 4 documentation and in [HMAC SHA256 Token Authenticator](./docs/references/authentication/hmac.md#hmac-secret-key-encryption).

You also may wish to adjust the default Driver `$hmacEncryptionDefaultDriver` and the default Digest
`$hmacEncryptionDefaultDigest`, these currently default to `'OpenSSL'` and `'SHA512'` respectively.

#### Encrypt Existing Keys

After updating the key in `$hmacEncryptionKeys` value, you will need to run `php spark shield:hmac encrypt` in order
to encrypt any existing HMAC tokens. This only needs to be run if you have existing unencrypted HMAC secretKeys in
stored in the database.

## Version 1.0.0-beta.6 to 1.0.0-beta.7

### The minimum CodeIgniter version
Expand Down
30 changes: 16 additions & 14 deletions admin/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,41 +36,43 @@ the changelog.

## Preparation

* Clone **codeigniter4/shield** and resolve any necessary PRs
* [ ] Clone **codeigniter4/shield** and resolve any necessary PRs
```console
git clone git@github.com:codeigniter4/shield.git
```
* Merge any Security Advisory PRs in private forks
* [ ] Merge any Security Advisory PRs in private forks

## Process

> **Note** Most changes that need noting in the User Guide and docs should have
> been included with their PR, so this process assumes you will not be
> generating much new content.

* Create a new branch `release-1.x.x`
* Update **src/Auth.php** with the new version number:
* [ ] Create a new branch `release-1.x.x`
* [ ] Update **src/Auth.php** with the new version number:
`const SHIELD_VERSION = '1.x.x';`
* Commit the changes with "Prep for 1.x.x release" and push to origin
* Create a new PR from `release-1.x.x` to `develop`:
* [ ] Commit the changes with "Prep for 1.x.x release" and push to origin
* [ ] Create a new PR from `release-1.x.x` to `develop`:
* Title: "Prep for 1.x.x release"
* Description: "Updates version references for `1.x.x`." (plus checklist)
* Let all tests run, then review and merge the PR
* Create a new PR from `develop` to `master`:
* [ ] Let all tests run, then review and merge the PR
* [ ] Create a new PR from `develop` to `master`:
* Title: "1.x.x Ready code"
* Description: blank
* Merge the PR
* Create a new Release:
* [ ] Merge the PR
* [ ] Create a new Release:
* Version: "v1.x.x"
* Target: master
* Title: "v1.x.x"
* Click the "Generate release notes" button
* Remove "### Others (Only for checking. Remove this category)" section
* Add important notes if necessary
* Add link to Upgrade Guide if necessary
* Check "Create a discussion for this release"
* Click the "Publish release" button
* Watch for the "docs" action and verify that the user guide updated:
* [ ] Watch for the "docs" action and verify that the user guide updated:
* [docs](https://github.com/codeigniter4/shield/actions/workflows/docs.yml)
* Fast-forward `develop` branch to catch the merge commit from `master`
* [ ] Fast-forward `develop` branch to catch the merge commit from `master`
(note: pushing to `develop` is restricted to administrators):
```console
git fetch origin
Expand All @@ -82,9 +84,9 @@ the changelog.
**At this point, `master` must be merged into `develop`.** Otherwise, the
GitHub-generated release note from `develop` for the next release will not be
generated correctly.
* Publish any Security Advisories that were resolved from private forks
* [ ] Publish any Security Advisories that were resolved from private forks
(note: publishing is restricted to administrators)
* Announce the release on the forums and Slack channel
* [ ] Announce the release on the forums and Slack channel
(note: this forum is restricted to administrators):
* Make a new topic in the "News & Discussion" forums:
https://forum.codeigniter.com/forum-2.html
Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"mockery/mockery": "^1.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"rector/rector": "0.18.5"
"rector/rector": "0.18.10"
},
"provide": {
"codeigniter4/authentication-implementation": "1.0"
Expand All @@ -52,9 +52,6 @@
"psr-4": {
"CodeIgniter\\Shield\\": "src"
},
"files": [
"src/Helpers/auth_helper.php"
],
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
Expand Down
31 changes: 30 additions & 1 deletion docs/addons/jwt.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ To use JWT Authentication, you need additional setup and configuration.
2. Copy the **AuthJWT.php** from **vendor/codeigniter4/shield/src/Config/** into your project's config folder and update the namespace to `Config`. You will also need to have these classes extend the original classes. See the example below.

```php
// new file - app/Config/AuthJWT.php
<?php

// app/Config/AuthJWT.php

declare(strict_types=1);

namespace Config;
Expand Down Expand Up @@ -127,6 +128,19 @@ php -r 'echo base64_encode(random_bytes(32));'

The secret key is used for signing and validating tokens.

### Login Attempt Logging

By default, only failed login attempts are recorded in the `auth_token_logins` table.

```php
public int $recordLoginAttempt = Auth::RECORD_LOGIN_ATTEMPT_FAILURE;
```

If you don't want any logs, set it to `Auth::RECORD_LOGIN_ATTEMPT_NONE`.

If you want to log all login attempts, set it to `Auth::RECORD_LOGIN_ATTEMPT_ALL`.
It means you log all requests.

## Issuing JWTs

To use JWT Authentication, you need a controller that issues JWTs.
Expand All @@ -140,7 +154,10 @@ $routes->post('auth/jwt', '\App\Controllers\Auth\LoginController::jwtLogin');
```

```php
<?php

// app/Controllers/Auth/LoginController.php

declare(strict_types=1);

namespace App\Controllers\Auth;
Expand Down Expand Up @@ -260,6 +277,7 @@ file itself:
$routes->group('api', ['filter' => 'jwt'], static function ($routes) {
// ...
});

$routes->get('users', 'UserController::list', ['filter' => 'jwt']);
```

Expand Down Expand Up @@ -346,3 +364,14 @@ It uses the `secret` and `alg` in the `Config\AuthJWT::$keys['default']`.
It sets the `Config\AuthJWT::$defaultClaims` to the token, and sets
`"iat"` (Issued At) and `"exp"` (Expiration Time) claims automatically even if
you don't pass them.

## Logging

Login attempts are recorded in the `auth_token_logins` table, according to the
configuration above.

When a failed login attempt is logged, the raw token value sent is saved in
the `identifier` column.

When a successful login attempt is logged, the SHA256 hash value of the token
sent is saved in the `identifier` column.
Loading