Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
916f315
Add test for checking localization parameters are not translated
paulbalandan Nov 20, 2023
3c2ea0a
chore(deps-dev): update rector/rector requirement
dependabot[bot] Nov 27, 2023
2a6a419
Merge pull request #965 from codeigniter4/dependabot/composer/rector/…
samsonasik Nov 27, 2023
cecec67
Merge pull request #955 from paulbalandan/localization-parameters
kenjis Dec 2, 2023
7b69071
test: update assertion
kenjis Dec 3, 2023
8de5f73
Merge pull request #969 from kenjis/fix-JWTManagerTest
datamweb Dec 3, 2023
2b4078b
refactor: remove unneeded deleted_at in $allowedFields
kenjis Nov 25, 2023
e34bfe8
chore: remove ignoreErrors
kenjis Nov 25, 2023
9f715f9
docs: add @var to tell PHPStan correct type
kenjis Dec 2, 2023
9b5c2bf
Merge pull request #963 from kenjis/remove-deleted_at
kenjis Dec 4, 2023
e4fc382
chore(deps-dev): update rector/rector requirement
dependabot[bot] Dec 4, 2023
4a47c4a
Merge pull request #970 from codeigniter4/dependabot/composer/rector/…
samsonasik Dec 4, 2023
1420dfc
chore(deps): bump actions/setup-python from 4 to 5
dependabot[bot] Dec 6, 2023
e4eb000
Merge pull request #972 from codeigniter4/dependabot/github_actions/a…
kenjis Dec 7, 2023
a191391
lang: [bg] Adjust translations for bg/Auth.php
kpeu3u Dec 7, 2023
d1d1f96
Merge pull request #973 from kpeu3u/adjust-bg-language
datamweb Dec 8, 2023
fef02d1
supportOldDangerousPassword support removed
omerimzali Sep 30, 2023
f54d7bf
supportOldDangerousPassword support removed && style fixes according …
omerimzali Sep 30, 2023
c528352
PHPStan changed to 8 and composer fix
omerimzali Sep 30, 2023
2d4c315
docs: add UPGRADING.md
kenjis Dec 8, 2023
5020b54
docs: add explanations
kenjis Dec 8, 2023
550414b
docs: move "Configuring to Use Your UserModel" up
kenjis Dec 9, 2023
6518ffa
Merge pull request #977 from kenjis/docs-adding_attributes_to_users
datamweb Dec 9, 2023
47f02e1
Merge pull request #976 from kenjis/remove-supportOldDangerousPassword
kenjis Dec 14, 2023
a88cc97
update docs color scheme
michalsn Dec 17, 2023
d3e43d8
add CNAME
michalsn Dec 17, 2023
233dba3
Merge pull request #981 from michalsn/docs-color-scheme
michalsn Dec 17, 2023
a0ec47f
docs: Remove emojis from index to be consistent with other docs in ou…
lonnieezell Dec 19, 2023
5bc4df3
Allow specifying namespace when generating routes. (#985)
lonnieezell Dec 21, 2023
bfd3e2c
chore(deps-dev): update rector/rector requirement
dependabot[bot] Dec 21, 2023
444061c
Merge pull request #986 from codeigniter4/dependabot/composer/rector/…
samsonasik Dec 22, 2023
636b46f
docs: add site_url
michalsn Dec 22, 2023
c884927
docs: remove navigation.instant.prefetch feature
michalsn Dec 22, 2023
d4400cd
docs: fix hljs init
michalsn Dec 22, 2023
daba1e3
Merge pull request #987 from michalsn/doc-navigation
datamweb Dec 22, 2023
92ad2af
docs: composer cs-fix
kenjis Dec 26, 2023
e8252d6
docs: add commands to prepare
kenjis Dec 26, 2023
a851593
Merge pull request #989 from kenjis/update-RELEASE.md
kenjis Dec 26, 2023
ccf15cc
Merge pull request #988 from kenjis/update-phpdoc-var
kenjis Dec 26, 2023
75068c1
Prep for 1.0.0 release
kenjis Dec 26, 2023
5218ff4
Merge pull request #990 from kenjis/release-1.0.0
kenjis Dec 27, 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
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install Dependencies
Expand Down
8 changes: 8 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Upgrade Guide

## Version 1.0.0-beta.8 to 1.0.0

## Removed Deprecated Items

The [$supportOldDangerousPassword](#if-you-want-to-allow-login-with-existing-passwords)
feature for backward compatiblity has been removed. The old passwords saved in
Shield v1.0.0-beta.3 or earlier are no longer supported.

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

### Mandatory Config Changes
Expand Down
2 changes: 2 additions & 0 deletions admin/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ the changelog.

* [ ] Clone **codeigniter4/shield** and resolve any necessary PRs
```console
rm -rf shield.bk
mv shield shield.bk
git clone git@github.com:codeigniter4/shield.git
```
* [ ] Merge any Security Advisory PRs in private forks
Expand Down
2 changes: 1 addition & 1 deletion 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.10"
"rector/rector": "0.18.13"
},
"provide": {
"codeigniter4/authentication-implementation": "1.0"
Expand Down
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shield.codeigniter.com
18 changes: 18 additions & 0 deletions docs/assets/css/codeigniter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[data-md-color-scheme="codeigniter"] {
--md-primary-fg-color: #dd4814;
--md-primary-fg-color--light: #ECB7B7;
--md-primary-fg-color--dark: #90030C;

--md-default-bg-color: #fcfcfc;

--md-typeset-a-color: #e74c3c;
--md-accent-fg-color: #97310e;

--md-accent-fg-color--transparent: #ECB7B7;

--md-code-bg-color: #ffffff;

.md-typeset code {
border: 1px solid #e1e4e5;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
[data-md-color-scheme="slate"] {
--md-primary-fg-color: #6a290d;
--md-primary-fg-color: #b13a10;
--md-primary-fg-color--light: #8d7474;
--md-primary-fg-color--dark: #6d554d;

--md-default-bg-color: #1e2129;

--md-typeset-a-color: #ed6436;
--md-accent-fg-color: #f18a67;

--md-accent-fg-color--transparent: #625151;

--md-code-bg-color: #282b2d;

.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
Expand Down Expand Up @@ -43,31 +52,30 @@
color: #ddba52
}

.md-typeset .note > .admonition-title,
.md-typeset .note > summary {
background-color: #0000001a;
.md-typeset code {
border: 1px solid #3f4547;
}

.md-typeset .admonition.note,
.md-typeset details.note {
border-color: #675647;
border-color: #2c5293;
}

.md-typeset .note > .admonition-title:before,
.md-typeset .note > summary:before {
background-color: #65686d;
background-color: #2c5293;
-webkit-mask-image: var(--md-admonition-icon--note);
mask-image: var(--md-admonition-icon--note);
}

.md-typeset .admonition.warning,
.md-typeset details.warning {
border-color: #776144;
border-color: #97631e;
}

.md-typeset .warning > .admonition-title:before,
.md-typeset .warning > summary:before {
background-color: #d9913bc2;
background-color: #97631e;
-webkit-mask-image: var(--md-admonition-icon--warning);
mask-image: var(--md-admonition-icon--warning);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/js/hljs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
document.addEventListener('DOMContentLoaded', (event) => {
window.document$.subscribe(() => {
hljs.highlightAll();
});
2 changes: 2 additions & 0 deletions docs/customization/adding_attributes_to_users.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ php spark db:table users

See [Customizing User Provider](./user_provider.md).

Don't forget to add the added attributes to the `$allowedFields` property.

## Update Validation Rules

You need to update the [validation rules](./validation_rules.md) for registration.
Expand Down
10 changes: 10 additions & 0 deletions docs/customization/route_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ $routes->get('register', '\App\Controllers\Auth\RegisterController::registerView

After customization, check your routes with the [spark routes](https://codeigniter.com/user_guide/incoming/routing.html#spark-routes) command.

## Change Namespace

If you are overriding all of the auth controllers, you can specify the namespace as an option to the `routes()` helper:

```php
service('auth')->routes($routes, ['namespace' => '\App\Controllers\Auth']);
```

This will generate the routes with the specified namespace instead of the default Shield namespace. This can be combined with any other options, like `except`.

## Use Locale Routes

You can use the `{locale}` placeholder in your routes
Expand Down
38 changes: 37 additions & 1 deletion docs/customization/user_provider.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Customizing User Provider

## Creating Your Own UserModel

If you want to customize user attributes, you need to create your own
[User Provider](../getting_started/concepts.md#user-providers) class.
The only requirement is that your new class MUST extend the provided `CodeIgniter\Shield\Models\UserModel`.
Expand All @@ -13,8 +15,42 @@ php spark shield:model UserModel

The class name is optional. If none is provided, the generated class name would be `UserModel`.

After creating the class, set the `$userProvider` property in **app/Config/Auth.php** as follows:
## Configuring to Use Your UserModel

After creating the class, set your model classname to the `$userProvider` property
in **app/Config/Auth.php**:

```php
public string $userProvider = \App\Models\UserModel::class;
```

## Customizing Your UserModel

Customize your model as you like.

If you add attributes, don't forget to add the attributes to the `$allowedFields`
property.

```php
<?php

declare(strict_types=1);

namespace App\Models;

use CodeIgniter\Shield\Models\UserModel as ShieldUserModel;

class UserModel extends ShieldUserModel
{
protected function initialize(): void
{
parent::initialize();

$this->allowedFields = [
...$this->allowedFields,
'first_name', // Added
'last_name', // Added
];
}
}
```
44 changes: 22 additions & 22 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# Shield Documentation

## What is Shield? 🤔
## What is Shield?

Shield is the official authentication and authorization framework for CodeIgniter 4. While
it does provide a base set of tools that are commonly used in websites, it is
designed to be flexible and easily customizable.

### Primary Goals 🥅
### Primary Goals

The primary goals for Shield are:

1. It must be very flexible and allow developers to extend/override almost any part of it.
2. It must have security at its core. It is an auth lib after all.
3. To cover many auth needs right out of the box, but be simple to add additional functionality to.

### Important Features 🌠
### Important Features

* **Session-based Authentication** (traditional **ID/Password** with **Remember-me**)
* **Stateless Authentication** using **Access Token**, **HMAC SHA256 Token**, or **JWT**
* Optional **Email verification** on account registration
* Optional **Email-based Two-Factor Authentication** after login
* **Magic Link Login** when a user forgets their password
* Flexible **Group-based Access Control** (think Roles, but more flexible), and users can be granted additional **Permissions**
* A simple **Auth Helper** that provides access to the most common auth actions
* Save initial settings in your code, so it can be in version control, but can also be updated in the database, thanks to our [Settings](https://github.com/codeigniter4/settings) library
* Highly configurable
* **User Entity** and **User Provider** (`UserModel`) ready for you to use or extend
* Built to extend and modify
* Easily extendable controllers
* All required views that can be used as is or swapped out for your own
- **Session-based Authentication** (traditional **ID/Password** with **Remember-me**)
- **Stateless Authentication** using **Access Token**, **HMAC SHA256 Token**, or **JWT**
- Optional **Email verification** on account registration
- Optional **Email-based Two-Factor Authentication** after login
- **Magic Link Login** when a user forgets their password
- Flexible **Group-based Access Control** (think Roles, but more flexible), and users can be granted additional **Permissions**
- A simple **Auth Helper** that provides access to the most common auth actions
- Save initial settings in your code, so it can be in version control, but can also be updated in the database, thanks to our [Settings](https://github.com/codeigniter4/settings) library
- Highly configurable
- **User Entity** and **User Provider** (`UserModel`) ready for you to use or extend
- Built to extend and modify
- Easily extendable controllers
- All required views that can be used as is or swapped out for your own

### License 📑
### License

Shield is licensed under the MIT License - see the [LICENSE](https://github.com/codeigniter4/shield/blob/develop/LICENSE) file for details.

### Acknowledgements 🙌🏼
### Acknowledgements

Every open-source project depends on it's contributors to be a success. The following users have
contributed in one manner or another in making Shield:
Expand All @@ -48,7 +48,7 @@ Made with [contrib.rocks](https://contrib.rocks).
The following articles/sites have been fundamental in shaping the security and best practices used
within this library, in no particular order:

- [Google Cloud: 13 best practices for user account, authentication, and password management, 2021 edition](https://cloud.google.com/blog/products/identity-security/account-authentication-and-password-management-best-practices)
- [NIST Digital Identity Guidelines](https://pages.nist.gov/800-63-3/sp800-63b.html)
- [Implementing Secure User Authentication in PHP Applications with Long-Term Persistence (Login with "Remember Me" Cookies) ](https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence)
- [Password Storage - OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html)
- [Google Cloud: 13 best practices for user account, authentication, and password management, 2021 edition](https://cloud.google.com/blog/products/identity-security/account-authentication-and-password-management-best-practices)
- [NIST Digital Identity Guidelines](https://pages.nist.gov/800-63-3/sp800-63b.html)
- [Implementing Secure User Authentication in PHP Applications with Long-Term Persistence (Login with "Remember Me" Cookies) ](https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence)
- [Password Storage - OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html)
18 changes: 9 additions & 9 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ theme:
palette:
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: deep orange
accent: orange
scheme: codeigniter
primary: custom
accent: custom
toggle:
icon: material/brightness-7
name: Switch to dark mode
# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: deep orange
accent: orange
primary: custom
accent: custom
toggle:
icon: material/brightness-4
name: Switch to light mode
features:
- navigation.instant
- navigation.instant.prefetch
- content.code.copy
- navigation.footer
- content.action.edit
Expand All @@ -55,7 +54,7 @@ extra:
link: https://join.slack.com/t/codeigniterchat/shared_invite/zt-244xrrslc-l_I69AJSi5y2a2RVN~xIdQ
name: Slack


site_url: https://shield.codeigniter.com/
repo_url: https://github.com/codeigniter4/shield
edit_uri: edit/develop/docs/
copyright: Copyright &copy; 2023 CodeIgniter Foundation.
Expand All @@ -68,8 +67,9 @@ markdown_extensions:
- pymdownx.details

extra_css:
- https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.8.0/build/styles/default.min.css
- assets/css/dark_mode.css
- https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.8.0/build/styles/github.min.css
- assets/css/codeigniter.css
- assets/css/codeigniter_dark_mode.css

extra_javascript:
- https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.8.0/build/highlight.min.js
Expand Down
22 changes: 1 addition & 21 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,31 +311,11 @@
'count' => 1,
'path' => __DIR__ . '/src/Models/UserIdentityModel.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot unset offset \'email\' on array\\{username\\: string, status\\: string, status_message\\: string, active\\: bool, last_active\\: string, deleted_at\\: string\\}\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/UserModel.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot unset offset \'password_hash\' on array\\{username\\: string, status\\: string, status_message\\: string, active\\: bool, last_active\\: string, deleted_at\\: string\\}\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/UserModel.php',
];
$ignoreErrors[] = [
'message' => '#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#',
'count' => 2,
'path' => __DIR__ . '/src/Models/UserModel.php',
];
$ignoreErrors[] = [
'message' => '#^Offset \'email\' does not exist on array\\{username\\: string, status\\: string, status_message\\: string, active\\: bool, last_active\\: string, deleted_at\\: string\\}\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/UserModel.php',
];
$ignoreErrors[] = [
'message' => '#^Offset \'password_hash\' does not exist on array\\{username\\: string, status\\: string, status_message\\: string, active\\: bool, last_active\\: string, deleted_at\\: string\\}\\.$#',
'count' => 1,
'path' => __DIR__ . '/src/Models/UserModel.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$data \\(array\\|CodeIgniter\\\\Shield\\\\Entities\\\\User\\) of method CodeIgniter\\\\Shield\\\\Models\\\\UserModel\\:\\:insert\\(\\) should be contravariant with parameter \\$data \\(array\\|object\\|null\\) of method CodeIgniter\\\\Model\\:\\:insert\\(\\)$#',
'count' => 1,
Expand Down Expand Up @@ -368,7 +348,7 @@
];
$ignoreErrors[] = [
'message' => '#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) with \'CodeIgniter\\\\\\\\Shield\\\\\\\\Result\' and CodeIgniter\\\\Shield\\\\Result will always evaluate to true\\.$#',
'count' => 9,
'count' => 8,
'path' => __DIR__ . '/tests/Authentication/Authenticators/SessionAuthenticatorTest.php',
];
$ignoreErrors[] = [
Expand Down
6 changes: 4 additions & 2 deletions src/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Auth
/**
* The current version of CodeIgniter Shield
*/
public const SHIELD_VERSION = '1.0.0-beta.8';
public const SHIELD_VERSION = '1.0.0';

protected AuthConfig $config;
protected ?Authentication $authenticate = null;
Expand Down Expand Up @@ -138,7 +138,9 @@ public function routes(RouteCollection &$routes, array $config = []): void
{
$authRoutes = config('AuthRoutes')->routes;

$routes->group('/', ['namespace' => 'CodeIgniter\Shield\Controllers'], static function (RouteCollection $routes) use ($authRoutes, $config): void {
$namespace = $config['namespace'] ?? 'CodeIgniter\Shield\Controllers';

$routes->group('/', ['namespace' => $namespace], static function (RouteCollection $routes) use ($authRoutes, $config): void {
foreach ($authRoutes as $name => $row) {
if (! isset($config['except']) || ! in_array($name, $config['except'], true)) {
foreach ($row as $params) {
Expand Down
Loading