Skip to content

Commit

Permalink
[2.x] New version
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Mar 5, 2024
1 parent 02e0ce5 commit e03e3cb
Show file tree
Hide file tree
Showing 33 changed files with 107 additions and 494 deletions.
136 changes: 18 additions & 118 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,108 +8,62 @@ jobs:
byte_level:
name: 0️⃣ Byte-level





runs-on: ubuntu-latest





steps:
- name: Checkout code
uses: actions/checkout@v3




uses: actions/checkout@v4

- name: Check file permissions
run: |
test "$(find . -type f -not -path './.git/*' -executable)" == ""
- name: Find non-printable ASCII characters
run: |
! LC_ALL=C.UTF-8 find ./src -type f -name "*.php" -print0 | xargs -0 -- grep -PHn "[^ -~]"
syntax_errors:
name: 1️⃣ Syntax errors





runs-on: ubuntu-latest





steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: latest
tools: parallel-lint





- name: Checkout code
uses: actions/checkout@v3




uses: actions/checkout@v4

- name: Validate Composer configuration
run: composer validate --strict





- name: Check source code for syntax errors
run: composer exec -- parallel-lint src/

unit_tests:
name: 2️⃣ Unit and Feature tests



needs:
- byte_level
- syntax_errors





runs-on: ubuntu-latest

strategy:
matrix:
php-version: ['8.0', '8.1', '8.2']
laravel-constraint: ['9.*', '10.*', '11.*']
dependencies: [lowest, highest]
php-version:
- 8.1
- 8.2
- 8.3
laravel-constraint:
- 10.*
- 11.*
dependencies: [ lowest, highest ]
exclude:
- php-version: '8.0'
laravel-constraint: 10.*
- laravel-constraint: 11.*
php-version: '8.0'
- laravel-constraint: 11.*
php-version: '8.1'




php-version: 8.1

steps:
- name: Set up PHP
Expand All @@ -119,56 +73,29 @@ jobs:
extensions: mbstring, intl
coverage: xdebug





- name: Checkout code
uses: actions/checkout@v3




uses: actions/checkout@v4

- name: Install dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --with=laravel/framework:${{ matrix.laravel-constraint }}





- name: Execute unit tests
run: composer run-script test





- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4

static_analysis:
name: 3️⃣ Static Analysis



needs:
- byte_level
- syntax_errors





runs-on: ubuntu-latest





steps:
- name: Set up PHP
uses: shivammathur/setup-php@v2
Expand All @@ -177,53 +104,26 @@ jobs:
php-version: latest
coverage: none





- name: Checkout code
uses: actions/checkout@v3




uses: actions/checkout@v4

- name: Install dependencies
uses: ramsey/composer-install@v2




uses: ramsey/composer-install@v3

- name: Execute static analysis
run: composer exec -- phpstan analyze -l 5 src/

exported_files:
name: 4️⃣ Exported files



needs:
- byte_level
- syntax_errors





runs-on: ubuntu-latest





steps:
- name: Checkout code
uses: actions/checkout@v3




uses: actions/checkout@v4

- name: Check exported files
run: |
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Codecov coverage](https://codecov.io/gh/Laragear/TwoFactor/branch/1.x/graph/badge.svg?token=BJMBVZNPM8)](https://codecov.io/gh/Laragear/TwoFactor)
[![Maintainability](https://api.codeclimate.com/v1/badges/64241e25adb0f55d7ba1/maintainability)](https://codeclimate.com/github/Laragear/TwoFactor/maintainability)
[![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=Laragear_TwoFactor&metric=alert_status)](https://sonarcloud.io/dashboard?id=Laragear_TwoFactor)
[![Laravel Octane Compatibility](https://img.shields.io/badge/Laravel%20Octane-Compatible-success?style=flat&logo=laravel)](https://laravel.com/docs/10.x/octane#introduction)
[![Laravel Octane Compatibility](https://img.shields.io/badge/Laravel%20Octane-Compatible-success?style=flat&logo=laravel)](https://laravel.com/docs/11.x/octane#introduction)

On-premises Two-Factor Authentication for all your users out of the box.

Expand Down Expand Up @@ -36,8 +36,7 @@ Your support allows me to keep this package free, up-to-date and maintainable. A

## Requirements

* PHP 8 or later
* Laravel 9, 10 or later
* Laravel 10 or later

## Installation

Expand Down Expand Up @@ -238,7 +237,7 @@ You can further customize how to handle the 2FA code authentication procedure wi

> * For [Laravel UI](https://github.com/laravel/ui), override the `attemptLogin()` method to replace the default guard attempt with `Auth2FA::attempt()` and `validateLogin` method to wrap in the `if ($request->isNotFilled('2fa_code'))` statement in your Login controller.
> * For [Laravel Breeze](https://laravel.com/docs/starter-kits#laravel-breeze), you may need to extend the `LoginRequest::authenticate()` call.
> * For [Laravel Fortify](https://laravel.com/docs/fortify) and [Jetstream](https://jetstream.laravel.com/), you may need to set a custom callback with the [`Fortify::authenticateUsing()`](https://laravel.com/docs/10.x/fortify#customizing-user-authentication) method.
> * For [Laravel Fortify](https://laravel.com/docs/fortify) and [Jetstream](https://jetstream.laravel.com/), you may need to set a custom callback with the [`Fortify::authenticateUsing()`](https://laravel.com/docs/11.x/fortify#customizing-user-authentication) method.
Alternatively, you may use `Auth::attemptWhen()` with TwoFactor helper methods, which returns a callback to check if the user needs a 2FA Code before proceeding using `TwoFactor::hasCode()`.

Expand Down Expand Up @@ -585,4 +584,4 @@ If you discover any security related issues, please email darkghosthunter@gmail.

This specific package version is licensed under the terms of the [MIT License](LICENSE.md), at time of publishing.

[Laravel](https://laravel.com) is a Trademark of [Taylor Otwell](https://github.com/TaylorOtwell/). Copyright © 2011-2023 Laravel LLC.
[Laravel](https://laravel.com) is a Trademark of [Taylor Otwell](https://github.com/TaylorOtwell/). Copyright © 2011-2024 Laravel LLC.
36 changes: 14 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "On-premises 2FA Authentication for out-of-the-box.",
"type": "library",
"license": "MIT",
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true,
"keywords": [
"laravel",
Expand All @@ -24,21 +24,21 @@
"issues": "https://github.com/Laragear/TwoFactor/issues"
},
"require": {
"php": "8.*",
"php": "^8.1",
"ext-json": "*",
"laragear/meta": "^2.1.0",
"laragear/meta": "3.*",
"bacon/bacon-qr-code": "2.*",
"paragonie/constant_time_encoding": "^2.5",
"illuminate/config": "9.*|10.*|^11.0",
"illuminate/validation": "9.*|10.*|^11.0",
"illuminate/database": "9.*|10.*|^11.0",
"illuminate/support": "9.*|10.*|^11.0",
"illuminate/http": "9.*|10.*|^11.0",
"illuminate/auth": "9.*|10.*|^11.0"
"paragonie/constant_time_encoding": "^2.6",
"illuminate/config": "10.*|11.*",
"illuminate/validation": "10.*|11.*",
"illuminate/database": "10.*|11.*",
"illuminate/support": "10.*|11.*",
"illuminate/http": "10.*|11.*",
"illuminate/auth": "10.*|11.*"
},
"require-dev": {
"laragear/meta-testing": "^1.3.1",
"orchestra/testbench": "^7.22|8.*|^9.0"
"laragear/meta-testing": "2.*",
"orchestra/testbench": "8.*|9.*"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -67,16 +67,8 @@
},
"funding": [
{
"type": "Patreon",
"url": "https://patreon.com/PackagesForLaravel"
},
{
"type": "Ko-Fi",
"url": "https://ko-fi.com/DarkGhostHunter"
},
{
"type": "Buy me a cofee",
"url": "https://www.buymeacoffee.com/darkghosthunter"
"type": "Github Sponsorship",
"url": "https://github.com/sponsors/DarkGhostHunter"
},
{
"type": "Paypal",
Expand Down
10 changes: 1 addition & 9 deletions database/factories/TwoFactorAuthenticationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ class TwoFactorAuthenticationFactory extends Factory
/**
* The name of the factory's corresponding model.
*
* @var string
* @var class-string<\Illuminate\Database\Eloquent\Model>|string
*/
protected $model = TwoFactorAuthentication::class;

/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
Expand All @@ -47,8 +45,6 @@ public function definition(): array

/**
* Returns a model with unused recovery codes.
*
* @return \Database\Factories\Laragear\TwoFactor\TwoFactorAuthenticationFactory
*/
public function withRecovery(): static
{
Expand All @@ -65,8 +61,6 @@ public function withRecovery(): static

/**
* Returns an authentication with a list of safe devices.
*
* @return \Database\Factories\Laragear\TwoFactor\TwoFactorAuthenticationFactory
*/
public function withSafeDevices(): static
{
Expand All @@ -92,8 +86,6 @@ public function withSafeDevices(): static

/**
* Returns an enabled authentication.
*
* @return \Database\Factories\Laragear\TwoFactor\TwoFactorAuthenticationFactory
*/
public function enabled(): static
{
Expand Down
10 changes: 6 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
Expand All @@ -19,4 +16,9 @@
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_CONNECTION" value="testing"/>
</php>
<source>
<include>
<directory>src/</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit e03e3cb

Please sign in to comment.