Skip to content

Commit cf04b0d

Browse files
committed
Initial Commit
0 parents  commit cf04b0d

File tree

172 files changed

+23738
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+23738
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: App Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
php: [ 8.1 ]
16+
laravel: [ 9 ]
17+
stability: [ 'prefer-lowest', 'prefer-stable' ]
18+
adapter: [ 'bladebones' ]
19+
variants: [
20+
'',
21+
'--without-rate-limiting',
22+
'--kind username-based',
23+
'--kind username-based --without-rate-limiting'
24+
]
25+
26+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} ${{ matrix.variants }} (w/ ${{ matrix.stability }})
27+
steps:
28+
- name: Determine latest release version
29+
run: |
30+
LATEST_RELEASE=`curl --silent -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest"`
31+
LATEST_TAG_NAME=`echo $LATEST_RELEASE | jq -r '.tag_name // "v0.1.0"'`
32+
echo "LATEST_RELEASE_VERSION=${LATEST_TAG_NAME}" >> $GITHUB_ENV
33+
34+
- name: Checkout code
35+
uses: actions/checkout@v3
36+
with:
37+
path: ./package
38+
39+
- name: Switch to predictable branch name (for Composer dev-branch versioning)
40+
run: git checkout -b gh-actions-predictable-composer-branch
41+
working-directory: ./package
42+
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php }}
47+
extensions: dom, curl, libxml, mbstring, zip
48+
ini-values: error_reporting=E_ALL
49+
tools: composer:v2
50+
coverage: none
51+
52+
- name: Create Laravel Project
53+
uses: nick-fields/retry@v2
54+
with:
55+
timeout_minutes: 5
56+
max_attempts: 5
57+
command: composer create-project laravel/laravel app "${{ matrix.laravel }}.x" --remove-vcs --prefer-dist --no-interaction
58+
59+
- name: Set Laravel Environment
60+
run: |
61+
sed -i "s/APP_DEBUG=.*/APP_DEBUG=true/" .env
62+
sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=secret/" .env
63+
working-directory: ./app
64+
65+
- name: Install Package
66+
run: |
67+
composer config repositories.package path ../package
68+
composer require "claudiodekker/laravel-auth:dev-gh-actions-predictable-composer-branch as ${{ env.LATEST_RELEASE_VERSION }}" claudiodekker/laravel-auth-${{ matrix.adapter }} --${{ matrix.stability }}
69+
working-directory: ./app
70+
71+
- name: Generate Auth Scaffolding
72+
run: php artisan auth:generate --yes ${{ matrix.variants }}
73+
working-directory: ./app
74+
75+
- name: Migrate Database
76+
run: php artisan migrate
77+
working-directory: ./app
78+
79+
- name: Execute tests
80+
run: vendor/bin/phpunit
81+
working-directory: ./app
82+
83+
services:
84+
mysql:
85+
image: 'mysql:5.7'
86+
ports:
87+
- 3306:3306
88+
env:
89+
MYSQL_DATABASE: laravel
90+
MYSQL_ROOT_PASSWORD: secret
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: dependabot-auto-merge
2+
3+
on: pull_request_target
4+
5+
permissions:
6+
pull-requests: write
7+
contents: write
8+
9+
jobs:
10+
dependabot:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.actor == 'dependabot[bot]' }}
13+
steps:
14+
- name: Dependabot metadata
15+
id: metadata
16+
uses: dependabot/fetch-metadata@v1.3.5
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
19+
20+
- name: Auto-merge Dependabot PRs for semver-minor updates
21+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
22+
run: gh pr merge --auto --merge "$PR_URL"
23+
env:
24+
PR_URL: ${{github.event.pull_request.html_url}}
25+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26+
27+
- name: Auto-merge Dependabot PRs for semver-patch updates
28+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
29+
run: gh pr merge --auto --merge "$PR_URL"
30+
env:
31+
PR_URL: ${{github.event.pull_request.html_url}}
32+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check & fix styling
2+
3+
on: push
4+
5+
jobs:
6+
laravel-pint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v3
12+
13+
- name: Setup PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: '8.1'
17+
tools: pint
18+
19+
- name: Run Laravel Pint
20+
run: pint --preset laravel
21+
22+
- name: Commit changes
23+
uses: stefanzweifel/git-auto-commit-action@v4
24+
with:
25+
commit_message: Fix styling
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Package Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
tests:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
php: [ 8.1 ]
16+
laravel: [ 9 ]
17+
stability: [ 'prefer-lowest', 'prefer-stable' ]
18+
19+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} (w/ ${{ matrix.stability }})
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v3
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
extensions: dom, curl, libxml, mbstring, zip
29+
ini-values: error_reporting=E_ALL
30+
tools: composer:v2
31+
coverage: none
32+
33+
- name: Set Minimum PHP 8.1 Versions
34+
uses: nick-fields/retry@v2
35+
with:
36+
timeout_minutes: 5
37+
max_attempts: 5
38+
command: |
39+
composer require phpunit/phpunit:^9.5.8 --dev --${{ matrix.stability }} --no-update --no-interaction
40+
composer require vlucas/phpdotenv:^5.3.1 --${{ matrix.stability }} --no-update --no-interaction
41+
if: matrix.php >= 8.1 && matrix.stability == 'prefer-lowest'
42+
43+
- name: Install dependencies
44+
uses: nick-fields/retry@v2
45+
with:
46+
timeout_minutes: 5
47+
max_attempts: 5
48+
command: composer update --${{ matrix.stability }} --no-interaction
49+
50+
- name: Execute tests
51+
run: vendor/bin/phpunit

packages/core/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.idea
2+
/.vscode
3+
/vendor
4+
.php-cs-fixer.cache
5+
.php-cs-fixer.php
6+
.phpunit.result.cache

packages/core/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased](https://github.com/claudiodekker/laravel-auth/compare/v0.1.0...HEAD)
9+
10+
## [v0.1.0](https://github.com/claudiodekker/laravel-auth/releases/tag/v0.1.0) - 2022-11-30
11+
12+
### Added
13+
14+
- Initial release

packages/core/CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

packages/core/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Claudio Dekker
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/core/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Laravel Auth (Core)
2+
Rich authentication logic for your Laravel applications; not intended for direct use.
3+
4+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/claudiodekker/laravel-auth.svg?style=flat-square)](https://packagist.org/packages/claudiodekker/laravel-auth)
5+
[![GitHub App Tests Action Status](https://github.com/claudiodekker/laravel-auth/actions/workflows/app-tests.yml/badge.svg)](https://github.com/claudiodekker/laravel-auth/actions/workflows/app-tests.yml)
6+
[![Github Package Tests Action Status](https://github.com/claudiodekker/laravel-auth/actions/workflows/package-tests.yml/badge.svg)](https://github.com/claudiodekker/laravel-auth/actions/workflows/package-tests.yml)
7+
[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/claudiodekker/laravel-auth/Check%20&%20fix%20styling?label=code%20style)](https://github.com/claudiodekker/laravel-auth/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster)
8+
[![Code Quality Score](https://img.shields.io/scrutinizer/g/claudiodekker/laravel-auth.svg?style=flat-square)](https://scrutinizer-ci.com/g/claudiodekker/laravel-auth)
9+
[![Total Downloads](https://img.shields.io/packagist/dt/claudiodekker/laravel-auth.svg?style=flat-square)](https://packagist.org/packages/claudiodekker/laravel-auth)
10+
11+
These days, most (web)applications no longer have just a simple username-password login form; they require you to think about password strength, two-factor authentication,
12+
the ability to recover your account with all of this set up, and as of more recently even the ability to log in without any password at all, using Passkeys.
13+
It goes without saying, that it takes a lot of effort to implement authentication yourself, and especially so if you want to do it in a way that is secure and easy to maintain.
14+
15+
### What in the box?
16+
17+
This package holds all the core authentication logic that's [used by adapter packages](#adapters--usage),
18+
with the exception of the scaffolding that ends up getting installed into your application:
19+
20+
- Basic email-password or username-password based authentication.
21+
- Passkey-based ("passwordless") authentication.
22+
- Two factor authentication for password-based users (TOTP, Security Keys).
23+
- Email verification, either directly after registration or manually.
24+
- Sudo-mode, allowing the user to temporarily elevate their privileges and perform sensitive actions.
25+
- Account recovery (requires the generation of recovery codes).
26+
- A rich set of authentication events, such as `MultiFactorChallenged`, `AccountRecoveryFailed`, etc.
27+
28+
## Adapters & Usage
29+
30+
To use this authentication library, you'll want to install an adapter package instead, which all use this library as an internal dependency.
31+
Here are some of the available adapters:
32+
33+
- [Laravel Auth Bladebones](https://github.com/claudiodekker/laravel-auth-bladebones)
34+
- Laravel Auth Blade (coming soon, includes Tailwind themed views)
35+
- Laravel Auth Inertia (coming soon, includes Tailwind themed views)
36+
37+
### Creating your own adapter package
38+
39+
If you're looking to develop your own adapter, we recommend using the [Bladebones adapter (template)](https://github.com/claudiodekker/laravel-auth-bladebones)
40+
repository as a starting point, as it already contains all the necessary scaffolding in it's most barebones form (hence the name).
41+
42+
## Testing
43+
44+
``` bash
45+
composer test
46+
```
47+
48+
## Changelog
49+
50+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
51+
52+
## Contributing
53+
54+
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
55+
56+
## Security
57+
58+
If you discover any security related issues, please email claudio@ubient.net instead of using the issue tracker.
59+
60+
This way, we can safely discuss and resolve the issue (within a reasonable timeframe), without exposing users to the unnecessary additional risk.
61+
Once the issue is fixed and a new version is released, we'll make sure to credit you for your contribution (unless you wish to remain anonymous).
62+
63+
## License
64+
65+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

0 commit comments

Comments
 (0)