diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 7382bb8eb..000000000 --- a/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -; This file is for unifying the coding style for different editors and IDEs. -; More information at http://editorconfig.org - -root = true - -[*] -charset = utf-8 -indent_size = 4 -indent_style = space -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.{yml,yaml}] -indent_size = 2 diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index fb192d9bc..000000000 --- a/.gitattributes +++ /dev/null @@ -1,25 +0,0 @@ -/.github export-ignore -/admin export-ignore -/bin export-ignore -/tests export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.php-cs-fixer.dist.php export-ignore -/composer-unused.php export-ignore -/structarmed.php export-ignore -/infection.json.dist export-ignore -/mkdocs.yml export-ignore -/phpstan-baseline.php export-ignore -/phpstan.neon.dist export-ignore -/phpunit.xml.dist export-ignore -/pyrameter.php export-ignore -/psalm_autoload.php export-ignore -/psalm-baseline.xml export-ignore -/psalm.xml export-ignore -/rector.php export-ignore -/roave-bc-check.yml export-ignore - -# Configure diff output for .php and .phar files. -*.php diff=php -*.phar -diff diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 56bac1cb6..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,125 +0,0 @@ -name: Bug report -description: Create a report to help us improve CodeIgniter Shield -title: "Bug: " -labels: ['bug'] - -body: - - type: markdown - attributes: - value: | - Thanks for taking the time to fill out this bug report! - - Before you begin, **please ensure that there are no existing issues, - whether still open or closed, related to your report**. - If there is, your report will be closed promptly. - - For example, if you get the error "*Can't find a route for 'post: login'*", - you can search the GitHub repository with the keyword "[Can't find a route for](https://github.com/codeigniter4/shield/issues?q=Can%27t+find+a+route+for)". - - --- - - - type: input - id: php-version - attributes: - label: PHP Version - description: | - e.g. 8.1.8 - validations: - required: true - - - type: input - id: codeigniter-version - attributes: - label: CodeIgniter4 Version - description: | - e.g. 4.2.2 - validations: - required: true - - - type: input - id: shield-version - attributes: - label: Shield Version - description: | - e.g. 1.0.0-beta.2 - If you are not using the [latest version](https://github.com/codeigniter4/shield/releases), please - check to see if the problem occurs with the latest version. - validations: - required: true - - - type: dropdown - id: operating-systems - attributes: - label: Which operating systems have you tested for this bug? - description: You may select more than one. - multiple: true - options: - - macOS - - Windows - - Linux - validations: - required: true - - - type: dropdown - id: server - attributes: - label: Which server did you use? - options: - - apache - - cli - - cli-server (PHP built-in webserver) - - cgi-fcgi - - fpm-fcgi - - phpdbg - validations: - required: true - - - type: input - id: database - attributes: - label: Database - description: e.g. MySQL 5.6, MariaDB 10.2, PostgreSQL 9.6 - validations: - required: true - - - type: textarea - id: shield-customization - attributes: - label: Did you customize Shield? - description: | - If "Yes," please tell us which classes you customized and how. - If "No," please indicate "No." - validations: - required: true - - - type: textarea - id: description - attributes: - label: What happened? - placeholder: Tell us what you see! - validations: - required: true - - - type: textarea - attributes: - label: Steps to Reproduce - description: Steps to reproduce the behavior. - validations: - required: true - - - type: textarea - attributes: - label: Expected Output - description: What do you expect to happen instead of this filed bug? - validations: - required: true - - - type: textarea - attributes: - label: Anything else? - description: | - Links? References? Anything that will give us more context about the issue you are encountering! - - Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. - validations: - required: false diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 317bff7fa..000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,9 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: GitHub Discussions - url: https://github.com/codeigniter4/shield/discussions - about: Please ask your support questions in the Discussions. Thanks! - - - name: CodeIgniter Slack channel - url: https://codeigniterchat.slack.com - about: Engage with other members of the community in our Slack channel. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index dacb0cd7a..000000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: Feature request -about: How to submit a feature request -title: '' -labels: '' -assignees: '' - ---- - -Please submit feature requests to [Discussions](https://github.com/codeigniter4/shield/discussions/categories/ideas). -We use GitHub Issues to track bugs and planned work. diff --git a/.github/ISSUE_TEMPLATE/planned-work.md b/.github/ISSUE_TEMPLATE/planned-work.md deleted file mode 100644 index 4faa45ed8..000000000 --- a/.github/ISSUE_TEMPLATE/planned-work.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -name: Planned work -about: Approved work planning -title: 'Dev: ' -labels: dev -assignees: '' - ---- - -Repo maintainers will create "issues" for planned work, so it can be tracked. diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index fd20b19f7..000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: -- package-ecosystem: composer - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 - -- package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: daily diff --git a/.github/prlint.json b/.github/prlint.json deleted file mode 100644 index 996d98f2f..000000000 --- a/.github/prlint.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "title": [ - { - "pattern": "^(\\[\\d+\\.\\d+\\]\\s{1})?(feat|fix|chore|docs|perf|refactor|style|test|lang)(\\([\\-.@:`a-zA-Z0-9]+\\))?!?:\\s{1}\\S.+\\S|Prep for \\d\\.\\d\\.\\d release$", - "message": "PR title must include the type (feat, fix, chore, docs, perf, refactor, style, test, lang) of the commit per Conventional Commits specification. See https://www.conventionalcommits.org/en/v1.0.0/ for the discussion." - } - ] -} diff --git a/.github/release.yml b/.github/release.yml deleted file mode 100644 index b2eb4ae46..000000000 --- a/.github/release.yml +++ /dev/null @@ -1,26 +0,0 @@ -changelog: - exclude: - authors: - - dependabot - categories: - - title: Breaking Changes - labels: - - 'breaking change' - - title: Fixed Bugs - labels: - - bug - - title: New Features - labels: - - 'new feature' - - title: Enhancements - labels: - - enhancement - - title: Translations - labels: - - lang - - title: Refactoring - labels: - - refactor - - title: Others (Only for checking. Remove this category) - labels: - - "*" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 441278441..000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: docs -on: - push: - branches: - - develop - - tags: - - 'v*' - - paths: - - 'docs/**' - - 'mkdocs.yml' - - '.github/workflows/docs.yml' - -permissions: - contents: write - -concurrency: - group: docs-deploy - cancel-in-progress: false - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - - - name: Setup Python - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 - with: - python-version: '3.x' - - - name: Install Dependencies - run: | - pip3 install mkdocs-material mike - pip3 install mkdocs-git-revision-date-localized-plugin - pip3 install mkdocs-redirects - - - name: Fetch gh-pages - run: git fetch origin gh-pages --depth=1 || true - - - name: Configure git - run: | - git config user.name github-actions[bot] - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - - - name: Deploy docs with mike - shell: bash - run: | - set -e - - deploy_version () { - local VERSION="$1" - local UPDATE_LATEST="${2:-false}" - - VERSION="${VERSION#v}" - - MINOR=$(echo "$VERSION" | sed -E 's/^([0-9]+\.[0-9]+).*/\1/') - - echo "Deploying docs version: $MINOR" - - if [ "$UPDATE_LATEST" = "true" ]; then - mike deploy --push --update-aliases "$MINOR" latest - return - fi - - mike deploy --push "$MINOR" - } - - # - # Develop branch - # - if [ "${{ github.ref_type }}" = "branch" ] && [ "${{ github.ref_name }}" = "develop" ]; then - echo "Deploying dev docs" - - mike deploy --push dev - - exit 0 - fi - - # - # Release tags - # - if [ "${{ github.ref_type }}" = "tag" ]; then - VERSION="${{ github.ref_name }}" - - if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Skipping non-stable release tag: $VERSION" - exit 0 - fi - - deploy_version "$VERSION" true - - echo "Setting default docs version: latest" - - mike set-default --push latest - - exit 0 - fi - - echo "Unsupported ref" - exit 1 diff --git a/.github/workflows/no-merge-commits.yml b/.github/workflows/no-merge-commits.yml deleted file mode 100644 index 67cc66f47..000000000 --- a/.github/workflows/no-merge-commits.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Detect Merge Commits - -on: - pull_request: - branches: - - develop - -permissions: - contents: read - pull-requests: read - -jobs: - test: - name: Check for merge commits - runs-on: ubuntu-22.04 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Run test - uses: NexusPHP/no-merge-commits@109a3342781ddcf26b2fa739f29e8ee9f68b7d8e # v2.4.1 - with: - token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/phpcpd.yml b/.github/workflows/phpcpd.yml deleted file mode 100644 index b95d842df..000000000 --- a/.github/workflows/phpcpd.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: PHPCPD - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcpd.yml' - push: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcpd.yml' - -jobs: - phpcpd: - uses: codeigniter4/.github/.github/workflows/phpcpd.yml@CI47 - with: - dirs: "src/ tests/" - options: "--exclude src/Database/Migrations/2020-12-28-223112_create_auth_tables.php --exclude src/Authentication/Authenticators/HmacSha256.php --exclude tests/Authentication/Authenticators/AccessTokenAuthenticatorTest.php" diff --git a/.github/workflows/phpcsfixer.yml b/.github/workflows/phpcsfixer.yml deleted file mode 100644 index 98ad44cd6..000000000 --- a/.github/workflows/phpcsfixer.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: PHPCSFixer - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcsfixer.yml' - push: - branches: - - develop - paths: - - '**.php' - - '.github/workflows/phpcsfixer.yml' - -jobs: - phpcsfixer: - uses: codeigniter4/.github/.github/workflows/phpcsfixer.yml@CI47 diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index fd8c9a15d..000000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: PHPStan - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpstan*' - - '.github/workflows/phpstan.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpstan*' - - '.github/workflows/phpstan.yml' - -jobs: - phpstan: - uses: codeigniter4/.github/.github/workflows/phpstan.yml@CI47 diff --git a/.github/workflows/phpunit-lang.yml b/.github/workflows/phpunit-lang.yml deleted file mode 100644 index a0e2521d6..000000000 --- a/.github/workflows/phpunit-lang.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: Language Unit Tests - -on: - pull_request: - branches: - - develop - paths: - - 'src/Language/**.php' - - '!src/Language/en/**.php' - - 'phpunit*' - - '.github/workflows/phpunit-lang.yml' - - 'tests/Language/AbstractTranslationTestCase.php' - push: - branches: - - develop - paths: - - 'src/Language/**.php' - - '!src/Language/en/**.php' - - 'phpunit*' - - '.github/workflows/phpunit-lang.yml' - - 'tests/Language/AbstractTranslationTestCase.php' - -jobs: - main: - name: Language Unit Tests - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 - with: - php-version: '8.2' - tools: composer, phive, phpunit - extensions: intl, json, mbstring, gd, xdebug, xml, sqlite3 - coverage: xdebug - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV - - - name: Cache composer dependencies - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 - with: - path: ${{ env.COMPOSER_CACHE_FILES_DIR }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Test with PHPUnit - run: vendor/bin/phpunit --no-coverage --testsuite lang - env: - TERM: xterm-256color - TACHYCARDIA_MONITOR_GA: enabled - PYRAMETER_DISABLED: 1 diff --git a/.github/workflows/phpunit-lowest.yml b/.github/workflows/phpunit-lowest.yml deleted file mode 100644 index f9af38c22..000000000 --- a/.github/workflows/phpunit-lowest.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: PHPUnit Lowest - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpunit*' - - '.github/workflows/phpunit-lowest.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpunit*' - - '.github/workflows/phpunit-lowest.yml' - -jobs: - phpunit: - uses: codeigniter4/.github/.github/workflows/phpunit-lowest.yml@CI47 diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml deleted file mode 100644 index a521e1bf3..000000000 --- a/.github/workflows/phpunit.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: PHPUnit - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpunit*' - - '.github/workflows/phpunit.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'phpunit*' - - '.github/workflows/phpunit.yml' - -jobs: - phpunit: - strategy: - matrix: - php-version: ['8.2', '8.3', '8.4', '8.5'] - db-platform: ['MySQLi', 'SQLite3'] - mysql-version: ['8.0'] - dependencies: ['highest'] - include: - # MySQL 5.7 - - php-version: '8.2' - db-platform: MySQLi - mysql-version: '5.7' - # Postgre - - php-version: '8.2' - db-platform: Postgre - mysql-version: '8.0' - # SQLSRV - - php-version: '8.2' - db-platform: SQLSRV - mysql-version: '8.0' - # OCI8 - - php-version: '8.2' - db-platform: OCI8 - mysql-version: '8.0' - - uses: codeigniter4/.github/.github/workflows/phpunit.yml@CI47 - with: - php-version: ${{ matrix.php-version }} - db-platform: ${{ matrix.db-platform }} - mysql-version: ${{ matrix.mysql-version }} - dependencies: ${{ matrix.dependencies }} - coveralls-php: '8.2' diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml deleted file mode 100644 index 8c9d14eef..000000000 --- a/.github/workflows/psalm.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Psalm - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'psalm*' - - '.github/workflows/psalm.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'psalm*' - - '.github/workflows/psalm.yml' - -jobs: - psalm: - uses: codeigniter4/.github/.github/workflows/psalm.yml@CI47 diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml deleted file mode 100644 index a1d407360..000000000 --- a/.github/workflows/rector.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Rector - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'rector.php' - - '.github/workflows/rector.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'rector.php' - - '.github/workflows/rector.yml' - -jobs: - rector: - uses: codeigniter4/.github/.github/workflows/rector.yml@CI47 diff --git a/.github/workflows/smart-commenting.yml b/.github/workflows/smart-commenting.yml deleted file mode 100644 index 3361c9f72..000000000 --- a/.github/workflows/smart-commenting.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Smart Commenting -on: - pull_request: - types: - - labeled -jobs: - - add-comment-for-GPG-Signing: - if: github.event.label.name == 'GPG-Signing needed' - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Add comment for GPG-sign - uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - You must GPG-sign your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open-source project. See Developer's Certificate of Origin. - See [signing][1]. - - **Note that all your commits must be signed.** If you have an unsigned commit, you can sign the previous commits by referring to [gpg-signing-old-commits][2]. - - [1]: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#signing - [2]: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#gpg-signing-old-commits - - add-comment-for-tests: - if: github.event.label.name == 'tests needed' - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Add comment for PHPUnit test - uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - **Unit Testing:** - Unit testing is expected for all CodeIgniter components. We use PHPUnit, and run unit tests using GitHub Actions for each PR submitted or changed. - - **So please write a unit test or update the existing tests.** - - See [unit testing][1] for more info. - - [1]: https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#unit-testing - - add-comment-for-conflict: - if: github.event.label.name == 'stale' - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Add comment for resolving a merge conflict - uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - We detected conflicts in your PR against the base branch :speak_no_evil: - You may want to sync :arrows_counterclockwise: your branch with upstream! - See [resolving a merge conflict using the Git][1] for more info. - - [1]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line diff --git a/.github/workflows/structarmed.yml b/.github/workflows/structarmed.yml deleted file mode 100644 index c2acfb1dc..000000000 --- a/.github/workflows/structarmed.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: StructArmed - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'structarmed.php' - - '.github/workflows/structarmed.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - 'structarmed.php' - - '.github/workflows/structarmed.yml' - workflow_call: - inputs: - php-version: - required: false - type: string - default: '8.2' - -permissions: - contents: read - -jobs: - build: - name: Dependency Tracing - runs-on: ubuntu-latest - if: (! contains(github.event.head_commit.message, '[ci skip]')) - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - - name: Set up PHP - uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 - with: - php-version: ${{ inputs['php-version'] }} - tools: composer - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV - - - name: Cache composer dependencies - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 - with: - path: ${{ env.COMPOSER_CACHE_FILES_DIR }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Structarmed Cache - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 - with: - path: /tmp/structarmed - key: ${{ runner.os }}-structarmed-${{ github.run_id }} - restore-keys: ${{ runner.os }}-structarmed- - - - run: mkdir -p /tmp/structarmed - - - name: Run static analysis - run: vendor/bin/structarmed analyze diff --git a/.github/workflows/unused.yml b/.github/workflows/unused.yml deleted file mode 100644 index 60911677a..000000000 --- a/.github/workflows/unused.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Unused - -on: - pull_request: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - '.github/workflows/unused.yml' - push: - branches: - - develop - paths: - - '**.php' - - 'composer.*' - - '.github/workflows/unused.yml' - -jobs: - unused: - uses: codeigniter4/.github/.github/workflows/unused.yml@CI47 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 00ffd45bd..000000000 --- a/.gitignore +++ /dev/null @@ -1,113 +0,0 @@ -#------------------------- -# Operating Specific Junk Files -#------------------------- - -# OS X -.DS_Store -.AppleDouble -.LSOverride - -# OS X Thumbnails -._* - -# Windows image file caches -Thumbs.db -ehthumbs.db -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Windows shortcuts -*.lnk - -# Linux -*~ - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -#------------------------- -# Environment Files -#------------------------- -# These should never be under version control, -# as it poses a security risk. -.env -.vagrant -Vagrantfile - -#------------------------- -# Temporary Files -#------------------------- -php_errors.log - -#------------------------- -# Test Files -#------------------------- -tests/coverage* - -# Don't save phpunit under version control. -phpunit - -#------------------------- -# Composer -#------------------------- -vendor/ -composer.lock - -#------------------------- -# MkDocs -#------------------------- -site/ - -#------------------------- -# IDE / Development Files -#------------------------- - -# Modules Testing -_modules/* - -# phpenv local config -.php-version - -# Jetbrains editors (PHPStorm, etc) -.idea/ -*.iml - -# Netbeans -nbproject/ -build/ -nbbuild/ -dist/ -nbdist/ -nbactions.xml -nb-configuration.xml -.nb-gradle/ - -# Sublime Text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache -*.sublime-workspace -*.sublime-project -.phpintel -/api/ - -# Visual Studio Code -.vscode/ - -/results/ -/phpunit*.xml -/.phpunit.*.cache - -/.php-cs-fixer.php -/docs/assets/__pycache__/ diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 000000000..e69de29bb diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php deleted file mode 100644 index ebcd908ad..000000000 --- a/.php-cs-fixer.dist.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * 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; - -$finder = Finder::create() - ->files() - ->in([ - __DIR__ . '/src/', - __DIR__ . '/tests/', - ]) - ->exclude('build') - ->append([ - __FILE__, - __DIR__ . '/rector.php', - __DIR__ . '/psalm_autoload.php', - ]); - -$overrides = [ - 'declare_strict_types' => true, - 'void_return' => true, -]; - -$options = [ - 'finder' => $finder, - 'cacheFile' => 'build/.php-cs-fixer.cache', -]; - -return Factory::create(new CodeIgniter4(), $overrides, $options)->forLibrary( - 'CodeIgniter Shield', - 'CodeIgniter Foundation', - 'admin@codeigniter.com', -); diff --git a/1.3/404.html b/1.3/404.html new file mode 100644 index 000000000..098046508 --- /dev/null +++ b/1.3/404.html @@ -0,0 +1,1496 @@ + + + +
+ + + + + + + + + + + + + + + + +Note
+Shield now supports only JWS (Signed JWT). JWE (Encrypted JWT) is not supported.
+JWT or JSON Web Token is a compact and self-contained way of securely transmitting +information between parties as a JSON object. It is commonly used for authentication +and authorization purposes in web applications.
+For example, when a user logs in to a web application, the server generates a JWT +token and sends it to the client. The client then includes this token in the header +of subsequent requests to the server. The server verifies the authenticity of the +token and grants access to protected resources accordingly.
+If you are not familiar with JWT, we recommend that you check out +Introduction to JSON Web Tokens before continuing.
+To use JWT Authentication, you need additional setup and configuration.
+Install "firebase/php-jwt" via Composer.
+composer require firebase/php-jwt:^6.4
+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
+
+// app/Config/AuthJWT.php
+
+declare(strict_types=1);
+
+namespace Config;
+
+use CodeIgniter\Shield\Config\AuthJWT as ShieldAuthJWT;
+
+/**
+ * JWT Authenticator Configuration
+ */
+class AuthJWT extends ShieldAuthJWT
+{
+ // ...
+}
+If your app/Config/Auth.php is not up-to-date, you also need to update it. Check vendor/codeigniter4/shield/src/Config/Auth.php and apply the differences.
+You need to add the following constants: +
public const RECORD_LOGIN_ATTEMPT_NONE = 0; // Do not record at all
+public const RECORD_LOGIN_ATTEMPT_FAILURE = 1; // Record only failures
+public const RECORD_LOGIN_ATTEMPT_ALL = 2; // Record all login attempts
+You need to add JWT Authenticator: +
use CodeIgniter\Shield\Authentication\Authenticators\JWT;
+
+// ...
+
+public array $authenticators = [
+ 'tokens' => AccessTokens::class,
+ 'session' => Session::class,
+ 'jwt' => JWT::class,
+];
+If you want to use JWT Authenticator in Authentication Chain, add jwt:
+
public array $authenticationChain = [
+ 'session',
+ 'tokens',
+ 'jwt'
+];
+Configure app/Config/AuthJWT.php for your needs.
+Note
+A payload contains the actual data being transmitted, such as user ID, role, +or expiration time. Items in a payload is called claims.
+Set the default payload items to the property $defaultClaims.
E.g.: +
public array $defaultClaims = [
+ 'iss' => 'https://codeigniter.com/',
+];
+The default claims will be included in all tokens issued by Shield.
+Set your secret key in the $keys property, or set it in your .env file.
E.g.: +
authjwt.keys.default.0.secret = 8XBFsF6HThIa7OV/bSynahEch+WbKrGcuiJVYPiwqPE=
+It needs at least 256 bits random string. The length of the secret depends on the
+algorithm we use. The default one is HS256, so to ensure that the hash value is
+secure and not easily guessable, the secret key should be at least as long as the
+hash function's output - 256 bits (32 bytes). You can get a secure random string
+with the following command:
php -r 'echo base64_encode(random_bytes(32));'
+Note
+The secret key is used for signing and validating tokens.
+By default, only failed login attempts are recorded in the auth_token_logins table.
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.
To use JWT Authentication, you need a controller that issues JWTs.
+Here is a sample controller. When a client posts valid credentials (email/password), +it returns a new JWT.
+// app/Config/Routes.php
+$routes->post('auth/jwt', '\App\Controllers\Auth\LoginController::jwtLogin');
+<?php
+
+// app/Controllers/Auth/LoginController.php
+
+declare(strict_types=1);
+
+namespace App\Controllers\Auth;
+
+use App\Controllers\BaseController;
+use CodeIgniter\API\ResponseTrait;
+use CodeIgniter\HTTP\ResponseInterface;
+use CodeIgniter\Shield\Authentication\Authenticators\Session;
+use CodeIgniter\Shield\Authentication\JWTManager;
+use CodeIgniter\Shield\Validation\ValidationRules;
+
+class LoginController extends BaseController
+{
+ use ResponseTrait;
+
+ /**
+ * Authenticate Existing User and Issue JWT.
+ */
+ public function jwtLogin(): ResponseInterface
+ {
+ // Get the validation rules
+ $rules = $this->getValidationRules();
+
+ // Validate credentials
+ if (! $this->validateData($this->request->getJSON(true), $rules, [], config('Auth')->DBGroup)) {
+ return $this->fail(
+ ['errors' => $this->validator->getErrors()],
+ $this->codes['unauthorized']
+ );
+ }
+
+ // Get the credentials for login
+ $credentials = $this->request->getJsonVar(setting('Auth.validFields'));
+ $credentials = array_filter($credentials);
+ $credentials['password'] = $this->request->getJsonVar('password');
+
+ /** @var Session $authenticator */
+ $authenticator = auth('session')->getAuthenticator();
+
+ // Check the credentials
+ $result = $authenticator->check($credentials);
+
+ // Credentials mismatch.
+ if (! $result->isOK()) {
+ // @TODO Record a failed login attempt
+
+ return $this->failUnauthorized($result->reason());
+ }
+
+ // Credentials match.
+ // @TODO Record a successful login attempt
+
+ $user = $result->extraInfo();
+
+ /** @var JWTManager $manager */
+ $manager = service('jwtmanager');
+
+ // Generate JWT and return to client
+ $jwt = $manager->generateToken($user);
+
+ return $this->respond([
+ 'access_token' => $jwt,
+ ]);
+ }
+
+ /**
+ * Returns the rules that should be used for validation.
+ *
+ * @return array<string, array<string, array<string>|string>>
+ * @phpstan-return array<string, array<string, string|list<string>>>
+ */
+ protected function getValidationRules(): array
+ {
+ $rules = new ValidationRules();
+
+ return $rules->getLoginRules();
+ }
+}
+You could send a request with the existing user's credentials by curl like this:
+curl --location 'http://localhost:8080/auth/jwt' \
+--header 'Content-Type: application/json' \
+--data-raw '{"email" : "admin@example.jp" , "password" : "passw0rd!"}'
+When making all future requests to the API, the client should send the JWT in
+the Authorization header as a Bearer token.
You could send a request with the Authorization header by curl like this:
curl --location --request GET 'http://localhost:8080/api/users' \
+--header 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJTaGllbGQgVGVzdCBBcHAiLCJzdWIiOiIxIiwiaWF0IjoxNjgxODA1OTMwLCJleHAiOjE2ODE4MDk1MzB9.DGpOmRPOBe45whVtEOSt53qJTw_CpH0V8oMoI_gm2XI'
+The first way to specify which routes are protected is to use the jwt controller
+filter.
For example, to ensure it protects all routes under the /api route group, you
+would use the $filters setting on app/Config/Filters.php.
public $filters = [
+ 'jwt' => ['before' => ['api', 'api/*']],
+];
+You can also specify the filter should run on one or more routes within the routes +file itself:
+$routes->group('api', ['filter' => 'jwt'], static function ($routes) {
+ // ...
+});
+
+$routes->get('users', 'UserController::list', ['filter' => 'jwt']);
+When the filter runs, it checks the Authorization header for a Bearer value
+that has the JWT. It then validates the token. If the token is valid, it can
+determine the correct user, which will then be available through an auth()->user()
+call.
JWTs are created through the JWTManager::generateToken() method.
+This takes a User object to give to the token as the first argument.
+It can also take optional additional claims array, time to live in seconds,
+a key group (an array key) in the Config\AuthJWT::$keys, and additional header
+array:
public function generateToken(
+ User $user,
+ array $claims = [],
+ ?int $ttl = null,
+ $keyset = 'default',
+ ?array $headers = null
+): string
+The following code generates a JWT to the user.
+use CodeIgniter\Shield\Authentication\JWTManager;
+
+/** @var JWTManager $manager */
+$manager = service('jwtmanager');
+
+$user = auth()->user();
+$claims = [
+ 'email' => $user->email,
+];
+$jwt = $manager->generateToken($user, $claims);
+It sets the Config\AuthJWT::$defaultClaims to the token, and adds
+the 'email' claim and the user ID in the "sub" (subject) claim.
+It also sets "iat" (Issued At) and "exp" (Expiration Time) claims automatically
+if you don't specify.
You can generate arbitrary JWT with the JWTManager::issue() method.
It takes a JWT claims array, and can take time to live in seconds, a key group
+(an array key) in the Config\AuthJWT::$keys, and additional header array:
public function issue(
+ array $claims,
+ ?int $ttl = null,
+ $keyset = 'default',
+ ?array $headers = null
+): string
+The following code generates a JWT.
+use CodeIgniter\Shield\Authentication\JWTManager;
+
+/** @var JWTManager $manager */
+$manager = service('jwtmanager');
+
+$payload = [
+ 'user_id' => '1',
+ 'email' => 'admin@example.jp',
+];
+$jwt = $manager->issue($payload, DAY);
+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.
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.
{"use strict";/*!
+ * escape-html
+ * Copyright(c) 2012-2013 TJ Holowaychuk
+ * Copyright(c) 2015 Andreas Lubbe
+ * Copyright(c) 2015 Tiancheng "Timothy" Gu
+ * MIT Licensed
+ */var Wa=/["'&<>]/;Vn.exports=Ua;function Ua(e){var t=""+e,r=Wa.exec(t);if(!r)return t;var o,n="",i=0,s=0;for(i=r.index;i