-
Notifications
You must be signed in to change notification settings - Fork 143
docs: reorganize (part 2) #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
e977f0e
docs: extract "Controller Filters"
kenjis 159295b
docs: remove "the"
kenjis b42159c
docs: add list of Authenticators
kenjis a937a80
docs: add section title
kenjis 5c636e5
docs: change first letters of keywords to capital letters
kenjis 91e094d
docs: change page titles
kenjis a3d84c8
docs: add "Using Authorization"
kenjis 2952e1f
docs: replace "Magic Login Links" with "Magic Link Login"
kenjis 0d3c652
docs: add page for Magic Link Login
kenjis 0ffd7c6
docs: add "Controller Filters"
kenjis 228ad48
docs: change filename
kenjis 6f260fe
docs: add descriptions
kenjis 7008664
docs: remove using_access_tokens_auth.md
kenjis 85fd665
docs: change section title
kenjis adf6024
docs: add links
kenjis cf1e5f1
docs: add "Getting Started > Configuration"
kenjis 80e46eb
docs: update link
kenjis 604b390
docs: fix section title
kenjis 32ab5ca
docs: remove duplicated "the"
kenjis 38fb0da
docs: move Configuration to References
kenjis ae56615
docs: add explanation to configuration.md
kenjis 969e47c
docs: add empty line
kenjis d7008e8
docs: move configuration.md to "Getting Started"
kenjis a6a6d12
docs: add Configuration in magic_link_login.md
kenjis 14a607c
docs: fix rebase mistake
kenjis dfe0448
docs: add empty lines and line breaks
kenjis 331a81e
docs: improve descriptions for Filters
kenjis ba72bdd
docs: add line break after **Note**
kenjis a33cf5a
docs: add HmacSha256 authenticator
kenjis 6584605
docs: move "Managing Users" to "Guides"
kenjis ae30aac
docs: add section "User Management" and change section order
kenjis 62685e8
docs: change sub section order
kenjis e523415
docs: move files to references/
kenjis 780c57b
docs: update links
kenjis 564352a
docs: fix link text
kenjis 588d17d
docs: add about app/Config/AuthToken.php
kenjis 2e48eca
docs: remove out-of-dated error description
kenjis 2316f76
docs: replace "remember me" with remember-me
kenjis ab65804
docs: replace Email/Password with ID/Password
kenjis 4f7d592
docs: add section title
kenjis cd757a2
docs: move note up
kenjis 10d5f4d
docs: add link to CI4 user guide
kenjis f40a5ee
docs: make page title shorter
kenjis 52d24fd
docs: add Acknowledgements
kenjis d8c89bc
docs: update and move description for Authenticators
kenjis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # Authenticators | ||
|
|
||
| ## Authenticator List | ||
|
|
||
| Shield provides the following Authenticators: | ||
|
|
||
| - **Session** authenticator provides traditional ID/Password authentication. | ||
| It uses username/email/password to authenticate against and stores the user | ||
| information in the session. See [Using Session Authenticator](../quick_start_guide/using_session_auth.md) for usage. | ||
| - **AccessTokens** authenticator provides stateless authentication using Personal | ||
| Access Tokens passed in the HTTP headers. | ||
| See [Protecting an API with Access Tokens](../guides/api_tokens.md) for usage. | ||
| - **HmacSha256** authenticator provides stateless authentication using HMAC Keys. | ||
| See [Protecting an API with HMAC Keys](../guides/api_hmac_keys.md) for usage. | ||
| - **JWT** authenticator provides stateless authentication using JSON Web Token. To use this, | ||
| you need additional setup. See [JWT Authentication](../addons/jwt.md). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Configuration | ||
|
|
||
| ## Config files | ||
|
|
||
| Shield has a lot of Config items. Change the default values as needed. | ||
|
|
||
| If you have completed the setup according to this documentation, you will have | ||
| the following configuration files: | ||
|
|
||
| - **app/Config/Auth.php** | ||
| - **app/Config/AuthGroups.php** - For Authorization | ||
| - **app/Config/AuthToken.php** - For AccessTokens and HmacSha256 Authentication | ||
| - **app/Config/AuthJWT.php** - For JWT Authentication | ||
|
|
||
| Note that you do not need to have configuration files for features you do not use. | ||
|
|
||
| This section describes the major Config items that are not described elsewhere. | ||
|
|
||
| ## AccessTokens Authenticator | ||
|
|
||
| ### Access Token Lifetime | ||
|
|
||
| By default, Access Tokens can be used for 1 year since the last use. This can be easily modified in the **app/Config/Auth.php** config file. | ||
|
|
||
| ```php | ||
| public int $unusedTokenLifetime = YEAR; | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| # Installation | ||
|
|
||
| These instructions assume that you have already [installed the CodeIgniter 4 app starter](https://codeigniter.com/user_guide/installation/installing_composer.html) as the basis for your new project, set up your **.env** file, and created a database that you can access via the Spark CLI script. | ||
|
|
||
| ## Requirements | ||
|
|
||
| - [Composer](https://getcomposer.org) | ||
| - Codeigniter **v4.2.7** or later | ||
| - A created database that you can access via the Spark CLI script | ||
| - InnoDB (not MyISAM) is required if MySQL is used. | ||
|
|
||
| ## Composer Installation | ||
|
|
||
| Installation is done through [Composer](https://getcomposer.org). The example assumes you have it installed globally. | ||
| If you have it installed as a phar, or otherwise you will need to adjust the way you call composer itself. | ||
|
|
||
| ```console | ||
| composer require codeigniter4/shield | ||
| ``` | ||
|
|
||
| ### Troubleshooting | ||
|
|
||
| #### IMPORTANT: composer error | ||
|
|
||
| If you get the following error: | ||
|
|
||
| ```console | ||
| Could not find a version of package codeigniter4/shield matching your minimum-stability (stable). | ||
| Require it with an explicit version constraint allowing its desired stability. | ||
| ``` | ||
|
|
||
| 1. Run the following commands to change your [minimum-stability](https://getcomposer.org/doc/articles/versions.md#minimum-stability) in your project `composer.json`: | ||
|
|
||
| ```console | ||
| composer config minimum-stability dev | ||
| composer config prefer-stable true | ||
| ``` | ||
|
|
||
| 2. Or specify an explicit version: | ||
|
|
||
| ```console | ||
| composer require codeigniter4/shield:dev-develop | ||
| ``` | ||
|
|
||
| The above specifies `develop` branch. | ||
| See <https://getcomposer.org/doc/articles/versions.md#branches> | ||
|
|
||
| ```console | ||
| composer require codeigniter4/shield:^1.0.0-beta | ||
| ``` | ||
|
|
||
| The above specifies `v1.0.0-beta` or later and before `v2.0.0`. | ||
| See <https://getcomposer.org/doc/articles/versions.md#caret-version-range-> | ||
|
|
||
| ## Initial Setup | ||
|
|
||
| ### Command Setup | ||
|
|
||
| 1. Run the following command. This command handles steps 1-5 of *Manual Setup* and runs the migrations. | ||
|
|
||
| ```console | ||
| php spark shield:setup | ||
| ``` | ||
|
|
||
| > **Note** | ||
| > If you want to customize table names, you must change the table names | ||
| > before running database migrations. | ||
| > See [Customizing Table Names](../customization/table_names.md). | ||
|
|
||
| 2. Configure **app/Config/Email.php** to allow Shield to send emails with the [Email Class](https://codeigniter.com/user_guide/libraries/email.html). | ||
|
|
||
| ```php | ||
| <?php | ||
|
|
||
| namespace Config; | ||
|
|
||
| use CodeIgniter\Config\BaseConfig; | ||
|
|
||
| class Email extends BaseConfig | ||
| { | ||
| /** | ||
| * @var string | ||
| */ | ||
| public $fromEmail = 'your_mail@example.com'; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| public $fromName = 'your name'; | ||
|
|
||
| // ... | ||
| } | ||
| ``` | ||
|
|
||
| ### Manual Setup | ||
|
|
||
| There are a few setup items to do before you can start using Shield in | ||
| your project. | ||
|
|
||
| 1. Copy the **Auth.php**, **AuthGroups.php**, and **AuthToken.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. These files contain all the settings, group, and permission information for your application and will need to be modified to meet the needs of your site. | ||
|
|
||
| ```php | ||
| // new file - app/Config/Auth.php | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Config; | ||
|
|
||
| // ... | ||
| use CodeIgniter\Shield\Config\Auth as ShieldAuth; | ||
|
|
||
| class Auth extends ShieldAuth | ||
| { | ||
| // ... | ||
| } | ||
| ``` | ||
|
|
||
| 2. **Helper Setup** The `setting` helper needs to be included in almost every page. The simplest way to do this is to add it to the `BaseController::initController()` method: | ||
|
|
||
| ```php | ||
| public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) | ||
| { | ||
| $this->helpers = array_merge($this->helpers, ['setting']); | ||
|
|
||
| // Do Not Edit This Line | ||
| parent::initController($request, $response, $logger); | ||
| } | ||
| ``` | ||
|
|
||
| This requires that all of your controllers extend the `BaseController`, but that's a good practice anyway. | ||
|
|
||
| 3. **Routes Setup** The default auth routes can be setup with a single call in **app/Config/Routes.php**: | ||
|
|
||
| ```php | ||
| service('auth')->routes($routes); | ||
| ``` | ||
|
|
||
| 4. **Security Setup** Set `Config\Security::$csrfProtection` to `'session'` (or set `security.csrfProtection = session` in your **.env** file) for security reasons, if you use Session Authenticator. | ||
|
|
||
| 5. **Migration** Run the migrations. | ||
|
|
||
| > **Note** | ||
| > If you want to customize table names, you must change the table names | ||
| > before running database migrations. | ||
| > See [Customizing Table Names](../customization/table_names.md). | ||
|
|
||
| ```console | ||
| php spark migrate --all | ||
| ``` | ||
|
|
||
| #### Note: migration error | ||
|
|
||
| When you run `spark migrate --all`, if you get `Class "SQLite3" not found` error: | ||
|
|
||
| 1. Remove sample migration files in **tests/_support/Database/Migrations/** | ||
| 2. Or install `sqlite3` php extension | ||
|
|
||
| 6. Configure **app/Config/Email.php** to allow Shield to send emails. | ||
|
|
||
| ```php | ||
| <?php | ||
|
|
||
| namespace Config; | ||
|
|
||
| use CodeIgniter\Config\BaseConfig; | ||
|
|
||
| class Email extends BaseConfig | ||
| { | ||
| /** | ||
| * @var string | ||
| */ | ||
| public $fromEmail = 'your_mail@example.com'; | ||
|
|
||
| /** | ||
| * @var string | ||
| */ | ||
| public $fromName = 'your name'; | ||
|
|
||
| // ... | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it(
<?php) added to all existing codes?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a whole file of it. So it seems better to have
<?php.I don't think
<?phpshould be added to all existing codes.