1
1
# Myth: Auth
2
2
3
- [ ![ ] ( https://github.com/lonnieezell/myth-auth/workflows/PHPUnit/badge.svg )] ( https://github.com/lonnieezell/myth-auth/actions?query=workflow%3A%22PHPUnit%22 )
4
- [ ![ ] ( https://github.com/lonnieezell/myth-auth/workflows/PHPStan/badge.svg )] ( https://github.com/lonnieezell/myth-auth/actions?query=workflow%3A%22PHPStan%22 )
3
+ [ ![ ] ( https://github.com/lonnieezell/myth-auth/workflows/PHPUnit/badge.svg )] ( https://github.com/lonnieezell/myth-auth/actions/workflows/phpunit.yml )
4
+ [ ![ ] ( https://github.com/lonnieezell/myth-auth/workflows/PHPStan/badge.svg )] ( https://github.com/lonnieezell/myth-auth/actions/workflows/phpstan.yml )
5
+ [ ![ ] ( https://github.com/lonnieezell/myth-auth/workflows/Deptrac/badge.svg )] ( https://github.com/lonnieezell/myth-auth/actions/workflows/deptrac.yml )
5
6
[ ![ Coverage Status] ( https://coveralls.io/repos/github/lonnieezell/myth-auth/badge.svg?branch=develop )] ( https://coveralls.io/github/lonnieezell/myth-auth?branch=develop )
6
7
7
8
Flexible, Powerful, Secure auth package for CodeIgniter 4.
8
9
9
- * This repo is maintained by volunteers. If you post an issue and haven't heard from us within 7 days, feel free to ping the issue so that we see it again.*
10
+ ## Project Notice
11
+
12
+ As of [ June 2022] ( https://forum.codeigniter.com/showthread.php?tid=82003 ) CodeIgniter now has an official
13
+ Authentication library, [ CodeIgniter Shield] ( https://www.codeigniter.com/user_guide/libraries/official_packages.html#shield ) .
14
+ If you are looking for an authentication solution for a new project then that is the recommended solution.
15
+
16
+ This project is now maintained by volunteers. If you interact with the project repository there may be delays
17
+ in receiving response. Please direct support questions to [ GitHub Discussions] ( https://github.com/lonnieezell/myth-auth/discussions )
18
+ or to CodeIgniter's [ Forums] ( https://forum.codeigniter.com/forumdisplay.php?fid=34 ) or [ Slack Channel] ( https://codeigniterchat.slack.com/ ) .
10
19
11
20
## Requirements
12
21
13
- - PHP 7.3 +, 8.0+
14
- - CodeIgniter 4.0.4 +
22
+ - PHP 7.4 +, 8.0+
23
+ - CodeIgniter 4.1 +
15
24
16
25
## Features
17
26
@@ -29,32 +38,30 @@ the following primary features:
29
38
30
39
Installation is best done via Composer. Assuming Composer is installed globally, you may use
31
40
the following command:
32
-
41
+ ``` shell
33
42
> composer require myth/auth
43
+ ```
34
44
35
- This will add the latest stable release of ** Myth\Auth** as a module to your project. Note that
36
- you may need to adjust your project's
37
- [ minimum stability ] ( http://webtips.krajee.com/setting-composer-minimum-stability-application/ )
38
- in order to use ** Myth\Auth** while it is in beta.
45
+ This will add the latest stable release of ** Myth: Auth ** as a module to your project.
39
46
40
47
### Manual Installation
41
48
42
49
Should you choose not to use Composer to install, you can clone or download this repo and
43
- then enable it by editing ** app/Config/Autoload.php** and adding the ** Myth\Auth**
44
- namespace to the ** $psr4** array. For example, if you copied it into ** app/ThirdParty** :
50
+ then enable it by editing ** app/Config/Autoload.php** and adding the ` Myth\Auth `
51
+ namespace to the ` $psr4 ` array. For example, if you copied it into ** app/ThirdParty/ ** :
45
52
``` php
46
53
$psr4 = [
47
54
'Config' => APPPATH . 'Config',
48
55
APP_NAMESPACE => APPPATH,
49
56
'App' => APPPATH,
50
- 'Myth\Auth' => APPPATH .'ThirdParty/myth-auth/src',
57
+ 'Myth\Auth' => APPPATH . 'ThirdParty/myth-auth/src',
51
58
];
52
59
```
53
60
54
61
### Upgrading
55
62
56
- Be sure to check the [ Changes Docs] ( https://github.com/lonnieezell/myth-auth/blob/develop/docs/_changes.md ) for
57
- necessary steps to take after upgrading versions.
63
+ Be sure to check the [ Changes Docs] ( https://github.com/lonnieezell/myth-auth/blob/develop/docs/_changes.md )
64
+ for necessary steps to take after upgrading versions.
58
65
59
66
## Configuration
60
67
@@ -68,8 +75,9 @@ In your application, perform the following setup:
68
75
` \Myth\Auth\Authentication\Passwords\ValidationRules::class `
69
76
70
77
3 . Ensure your database is setup correctly, then run the Auth migrations:
71
-
78
+ ``` shell
72
79
> php spark migrate -all
80
+ ```
73
81
74
82
NOTE: This library uses your application's cache settings to reduce database lookups. If you want
75
83
to make use of this, simply make sure that your are using a cache engine other than ` dummy ` and
@@ -88,26 +96,27 @@ by setting the `$allowRemembering` variable to be `true` in Config/Auth.php.
88
96
89
97
Routes are defined in Auth's ** Config/Routes.php** file. This file is automatically located by CodeIgniter
90
98
when it is processing the routes. If you would like to customize the routes, you should copy the file
91
- to the ** app/Config** directory and make your changes there.
99
+ to the ** app/Config** directory, update the namespace, and make your route changes there. You
100
+ may also use the ` $reservedRoutes ` property of ` Config\Auth ` to redirect internal route names.
92
101
93
102
### Views
94
103
95
- Basic views are provided that are based on [ Bootstrap 4] ( http ://getbootstrap.com/) for all features.
104
+ Basic views are provided that are based on [ Bootstrap 4] ( https ://getbootstrap.com/) for all features.
96
105
97
- You can easily override the views used by editing Config/Auth.php, and changing the appropriate values
98
- within the ` $views ` variable:
106
+ You can easily override the views used by editing ** Config/Auth.php** , and changing the appropriate
107
+ values within the ` $views ` variable:
99
108
100
109
public $views = [
101
- 'login' => 'Myth\Auth\Views\login',
102
- 'register' => 'Myth\Auth\Views\register',
103
- 'forgot' => 'Myth\Auth\Views\forgot',
104
- 'reset' => 'Myth\Auth\Views\reset',
110
+ 'login' => 'Myth\Auth\Views\login',
111
+ 'register' => 'Myth\Auth\Views\register',
112
+ 'forgot' => 'Myth\Auth\Views\forgot',
113
+ 'reset' => 'Myth\Auth\Views\reset',
105
114
'emailForgot' => 'Myth\Auth\Views\emails\forgot',
106
115
];
107
116
108
117
NOTE: If you're not familiar with how views can be namespaced in CodeIgniter, please refer to
109
- [ the user guide ] ( https://codeigniter4.github.io/CodeIgniter4 /general/modules.html ) for CI4's
110
- Code Module support.
118
+ [ the CodeIgniter User Guide ] ( https://codeigniter.com/user_guide /general/modules.html ) for section
119
+ on Code Module support.
111
120
112
121
## Services
113
122
@@ -117,48 +126,54 @@ The following Services are provided by the package:
117
126
118
127
Provides access to any of the authentication packages that Myth: Auth knows about. By default
119
128
it will return the "Local Authentication" library, which is the basic password-based system.
120
-
129
+ ``` php
121
130
$authenticate = service('authentication');
131
+ ```
122
132
123
133
You can specify the library to use as the first argument:
124
-
134
+ ``` php
125
135
$authenticate = service('authentication', 'jwt');
126
-
136
+ ```
137
+
127
138
** authorization**
128
139
129
140
Provides access to any of the authorization libraries that Myth: Auth knows about. By default
130
141
it will return the "Flat" authorization library, which is a Flat RBAC (role-based access control)
131
142
as defined by NIST. It provides user-specific permissions as well as group (role) based permissions.
132
-
143
+ ``` php
133
144
$authorize = service('authorization');
145
+ ```
134
146
135
147
** passwords**
136
148
137
149
Provides direct access to the Password validation system. This is an expandable system that currently
138
150
supports many of [ NIST's latest Digital Identity guidelines] ( https://pages.nist.gov/800-63-3/ ) . The
139
151
validator comes with a dictionary of over 620,000 common/leaked passwords that can be checked against.
140
152
A handful of variations on the user's email/username are automatically checked against.
141
-
153
+ ``` php
142
154
$authenticate = service('passwords');
143
-
155
+ ```
156
+
144
157
Most of the time you should not need to access this library directly, though, as a new Validation rule
145
158
is provided that can be used with the Validation library, ` strong_password ` . In order to enable this,
146
159
you must first edit ** app/Config/Validation.php** and add the new ruleset to the available rule sets:
147
-
160
+ ``` php
148
161
public $ruleSets = [
149
162
\CodeIgniter\Validation\Rules::class,
150
163
\CodeIgniter\Validation\FormatRules::class,
151
164
\CodeIgniter\Validation\FileRules::class,
152
165
\CodeIgniter\Validation\CreditCardRules::class,
153
166
\Myth\Auth\Authentication\Passwords\ValidationRules::class,
154
167
];
155
-
156
- Now you can use ` strong_password ` in any set of rules for validation:
168
+ ```
157
169
170
+ Now you can use ` strong_password ` in any set of rules for validation:
171
+ ``` php
158
172
$validation->setRules([
159
173
'username' => 'required',
160
174
'password' => 'required|strong_password'
161
175
]);
176
+ ```
162
177
163
178
## Helper Functions
164
179
@@ -200,7 +215,6 @@ auth filters all pre-load the helper so it is available on any filtered routes.
200
215
* Parameters: Permission ID or name.
201
216
* Returns: ` true ` or ` false `
202
217
203
-
204
218
## Users
205
219
206
220
Myth: Auth uses [ CodeIgniter Entities] ( https://codeigniter4.github.io/CodeIgniter4/models/entities.html )
@@ -215,7 +229,6 @@ or modify it as needed.
215
229
The UserModel can automatically assign a role during user creation. Pass the group name to the
216
230
` withGroup() ` method prior to calling ` insert() ` or ` save() ` to create a new user and the user
217
231
will be automatically added to that group.
218
-
219
232
``` php
220
233
$user = $userModel
221
234
->withGroup('guests')
0 commit comments