├── .github
├── FUNDING.yml
└── workflows
│ └── release.yml
├── .gitignore
├── .releaserc
├── CHANGELOG.md
├── LICENSE.md
├── README.md
├── UPGRADE.md
├── composer.json
├── config
└── filament-authentication.php
├── database
└── migrations
│ ├── create_filament_authentication_tables.php.stub
│ ├── create_filament_password_renew_table.php.stub
│ └── tracks_filament_password_hashes.php.stub
├── docs
└── .gitkeep
├── larastan
└── Facades.stub
├── phpcs.xml
├── phpstan-baseline.neon
├── phpstan.neon.dist
├── phpunit.xml
├── pint.json
├── resources
├── lang
│ ├── en
│ │ └── filament-authentication.php
│ ├── ja
│ │ └── filament-authentication.php
│ ├── pt_BR
│ │ └── filament-authentication.php
│ └── vi
│ │ └── filament-authentication.php
└── views
│ ├── components
│ └── banner.blade.php
│ ├── impersonating-banner.blade.php
│ └── pages
│ └── auth
│ └── renew-password.blade.php
├── routes
└── web.php
├── src
├── .DS_Store
├── Actions
│ └── ImpersonateLink.php
├── Commands
│ ├── InstallCommand.php
│ └── UpdateUserPasswordToUpdatedCommand.php
├── Events
│ ├── UserCreated.php
│ └── UserUpdated.php
├── FilamentAuthentication.php
├── FilamentAuthenticationProvider.php
├── Http
│ └── Middleware
│ │ ├── ImpersonatingMiddleware.php
│ │ └── RenewPasswordMiddleware.php
├── Models
│ ├── AuthenticationLog.php
│ └── PasswordRenewLog.php
├── Pages
│ └── Auth
│ │ └── RenewPassword.php
├── Resources
│ ├── AuthenticationLogResource.php
│ ├── AuthenticationLogResource
│ │ └── Pages
│ │ │ └── ListAuthenticationLogs.php
│ ├── PermissionResource.php
│ ├── PermissionResource
│ │ ├── Pages
│ │ │ ├── CreatePermission.php
│ │ │ ├── EditPermission.php
│ │ │ ├── ListPermissions.php
│ │ │ └── ViewPermission.php
│ │ └── RelationManager
│ │ │ └── RoleRelationManager.php
│ ├── RoleResource.php
│ ├── RoleResource
│ │ ├── Pages
│ │ │ ├── CreateRole.php
│ │ │ ├── EditRole.php
│ │ │ ├── ListRoles.php
│ │ │ └── ViewRole.php
│ │ └── RelationManager
│ │ │ ├── PermissionRelationManager.php
│ │ │ └── UserRelationManager.php
│ ├── UserResource.php
│ └── UserResource
│ │ ├── Pages
│ │ ├── CreateUser.php
│ │ ├── EditUser.php
│ │ ├── ListUsers.php
│ │ └── ViewUser.php
│ │ └── RelationManager
│ │ ├── AuthenticationLogsRelationManager.php
│ │ └── RoleRelationManager.php
├── Rules
│ └── PreventPasswordReuseRule.php
├── Subscribers
│ └── AuthenticationLoggingSubscriber.php
├── Traits
│ ├── CanRenewPassword.php
│ ├── LogsAuthentication.php
│ ├── PagePolicyTrait.php
│ └── SettingsPagePolicyTrait.php
└── Widgets
│ └── LatestUsersWidget.php
└── tests
└── DefaultTest.php
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: phpsa
2 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Semantic Release
2 |
3 | on: [workflow_dispatch]
4 |
5 | jobs:
6 | release:
7 | name: release
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout
11 | uses: actions/checkout@v3
12 |
13 | - name: Semantic Release
14 | uses: cycjimmy/semantic-release-action@v3
15 | id: semantic
16 | with:
17 | branches: |
18 | [
19 | '+([0-9])?(.{+([0-9]),x}).x',
20 | 'master',
21 | 'main',
22 | 'next',
23 | 'next-major',
24 | {
25 | name: 'beta',
26 | prerelease: true
27 | },
28 | {
29 | name: 'alpha',
30 | prerelease: true
31 | }
32 | ]
33 | extra_plugins: |
34 | @semantic-release/commit-analyzer
35 | @semantic-release/git
36 | @semantic-release/changelog
37 | @semantic-release/exec
38 | env:
39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 | SEMANTIC_RELEASE_PACKAGE: Filament Authentication
41 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | composer.lock
3 |
--------------------------------------------------------------------------------
/.releaserc:
--------------------------------------------------------------------------------
1 | plugins:
2 | - "@semantic-release/commit-analyzer"
3 | - "@semantic-release/release-notes-generator"
4 | - - "@semantic-release/exec"
5 | - verifyReleaseCmd: "echo ${nextRelease.version} > VERSION.txt"
6 | - - "@semantic-release/changelog"
7 | - changelogFile: CHANGELOG.md
8 | - - "@semantic-release/github"
9 | - - "@semantic-release/git"
10 | - assets:
11 | - CHANGELOG.md
12 | message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
13 | branches:
14 | - "master"
15 | - "main"
16 | - "next"
17 | - "next-major"
18 | - "+([0-9])?(.{+([0-9]),x}).x"
19 | - name: "beta"
20 | prerelease: true
21 | - name: "alpha"
22 | prerelease: true
23 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [2.4.2](https://github.com/phpsa/filament-authentication/compare/v2.4.1...v2.4.2) (2023-05-15)
2 |
3 |
4 | ### Bug Fixes
5 |
6 | * missing ; on widget ([4c4d91d](https://github.com/phpsa/filament-authentication/commit/4c4d91d1cff87d00009c3665175022128906e93b))
7 |
8 | ## [2.4.1](https://github.com/phpsa/filament-authentication/compare/v2.4.0...v2.4.1) (2023-05-15)
9 |
10 |
11 | ### Bug Fixes
12 |
13 | * Add password type to input password ([#32](https://github.com/phpsa/filament-authentication/issues/32)) ([a5bd787](https://github.com/phpsa/filament-authentication/commit/a5bd78753d650a9772935fd6c3fbb429cd4e769e))
14 | * **widgets:** update LatestUsers query to use the configured resource ([#34](https://github.com/phpsa/filament-authentication/issues/34)) ([a09a2a8](https://github.com/phpsa/filament-authentication/commit/a09a2a80427effbe3e447e2073413c3eb8f6adcd))
15 |
16 | # [2.4.0](https://github.com/phpsa/filament-authentication/compare/v2.3.0...v2.4.0) (2023-02-06)
17 |
18 |
19 | ### Features
20 |
21 | * Portuguese translations ([#30](https://github.com/phpsa/filament-authentication/issues/30)) ([93f838e](https://github.com/phpsa/filament-authentication/commit/93f838e7c8dcd24d0e0f77f9c8b997addace98ea))
22 |
23 | # [2.3.0](https://github.com/phpsa/filament-authentication/compare/v2.2.1...v2.3.0) (2022-11-23)
24 |
25 |
26 | ### Features
27 |
28 | * Attach user to role ([62d7c19](https://github.com/phpsa/filament-authentication/commit/62d7c19c394a06ad5341c327952e3468a6eb7798))
29 |
30 | ## [2.2.1](https://github.com/phpsa/filament-authentication/compare/v2.2.0...v2.2.1) (2022-09-11)
31 |
32 |
33 | ### Bug Fixes
34 |
35 | * Clear permissions cache on attach/detach ([#22](https://github.com/phpsa/filament-authentication/issues/22)) ([50952ca](https://github.com/phpsa/filament-authentication/commit/50952ca04144e85f175f167211e29f48dc7df454))
36 | * Make Role and Permission Name and Guard Name required for form ([#23](https://github.com/phpsa/filament-authentication/issues/23)) ([0f948e9](https://github.com/phpsa/filament-authentication/commit/0f948e93cd7b939221a6b0fd1e76cdd021129207))
37 |
38 | # [2.2.0](https://github.com/phpsa/filament-authentication/compare/v2.1.2...v2.2.0) (2022-08-11)
39 |
40 |
41 | ### Features
42 |
43 | * Vietnamese translations ([#19](https://github.com/phpsa/filament-authentication/issues/19)) ([616bb75](https://github.com/phpsa/filament-authentication/commit/616bb754e6bf8ba99df6b04df941e2ee26294d5b))
44 |
45 | ## [2.2.0] (to be released)
46 |
47 | ### Features
48 |
49 | * [2.2.0] introduce ability to override User, Role and Permission Model (instead of just RoleResource and PermissionResource)
50 |
51 | ## [2.1.2](https://github.com/phpsa/filament-authentication/compare/v2.1.1...v2.1.2) (2022-06-16)
52 |
53 |
54 | ### Bug Fixes
55 |
56 | * tableActions removed ([91b1526](https://github.com/phpsa/filament-authentication/commit/91b152674ef6f7a0b1d658d5efc40bd08546cd61))
57 |
58 | ## [2.1.1](https://github.com/phpsa/filament-authentication/compare/v2.1.0...v2.1.1) (2022-06-06)
59 |
60 |
61 | ### Bug Fixes
62 |
63 | * added ability to set sort order of the LatestUsers widget ([7198cff](https://github.com/phpsa/filament-authentication/commit/7198cfffbc37e788f46cde363709cf2d91332bc1))
64 |
65 | # [2.1.0](https://github.com/phpsa/filament-authentication/compare/v2.0.0...v2.1.0) (2022-06-02)
66 |
67 |
68 | ### Bug Fixes
69 |
70 | * mount not static ([3b9e4cc](https://github.com/phpsa/filament-authentication/commit/3b9e4cc0fe9ca259135b5eee15ebfdccbe05d22e))
71 | * use Terniary Filter ([9d9a07a](https://github.com/phpsa/filament-authentication/commit/9d9a07ad9672739c96b3128bc80649614536e824))
72 | * use user name by default on edit ([b3d4a90](https://github.com/phpsa/filament-authentication/commit/b3d4a90356622901ff71bf3c95381fe9df07fc8b))
73 |
74 |
75 | ### Features
76 |
77 | * added event triggers for create and update ([59dd8ef](https://github.com/phpsa/filament-authentication/commit/59dd8ef6f62591b2e6a8f89e425e5f54e340df71))
78 |
79 | # [2.1.0-beta.2](https://github.com/phpsa/filament-authentication/compare/v2.1.0-beta.1...v2.1.0-beta.2) (2022-05-31)
80 |
81 |
82 | ### Bug Fixes
83 |
84 | * use Terniary Filter ([9d9a07a](https://github.com/phpsa/filament-authentication/commit/9d9a07ad9672739c96b3128bc80649614536e824))
85 | * use user name by default on edit ([b3d4a90](https://github.com/phpsa/filament-authentication/commit/b3d4a90356622901ff71bf3c95381fe9df07fc8b))
86 |
87 | # [2.1.0-beta.1](https://github.com/phpsa/filament-authentication/compare/v2.0.0...v2.1.0-beta.1) (2022-05-30)
88 |
89 |
90 | ### Bug Fixes
91 |
92 | * mount not static ([3b9e4cc](https://github.com/phpsa/filament-authentication/commit/3b9e4cc0fe9ca259135b5eee15ebfdccbe05d22e))
93 |
94 |
95 | ### Features
96 |
97 | * added event triggers for create and update ([59dd8ef](https://github.com/phpsa/filament-authentication/commit/59dd8ef6f62591b2e6a8f89e425e5f54e340df71))
98 |
99 | # [2.0.0](https://github.com/phpsa/filament-authentication/compare/v1.1.2...v2.0.0) (2022-05-27)
100 |
101 |
102 | ### Bug Fixes
103 |
104 | * use Filament::makeTableAction for table action ([864610a](https://github.com/phpsa/filament-authentication/commit/864610acaf9d05498d4c430c51deb50027bc1fc1))
105 |
106 |
107 | ### Features
108 |
109 | * Timezone display set to use Filament Core system ([f5d5507](https://github.com/phpsa/filament-authentication/commit/f5d550710ff63b018c660a6b5be3262de469318b))
110 |
111 |
112 | ### BREAKING CHANGES
113 |
114 | * Visual display of dates will need to be updated
115 |
116 | ## [1.1.2](https://github.com/phpsa/filament-authentication/compare/v1.1.1...v1.1.2) (2022-05-06)
117 |
118 |
119 | ### Bug Fixes
120 |
121 | * spelling issue in config file ([4160da9](https://github.com/phpsa/filament-authentication/commit/4160da954fa0163653560abd3824904a8a426d06))
122 |
123 | ## [1.1.1](https://github.com/phpsa/filament-authentication/compare/v1.1.0...v1.1.1) (2022-05-03)
124 |
125 |
126 | ### Bug Fixes
127 |
128 | * code quality updates ([ce9c8d1](https://github.com/phpsa/filament-authentication/commit/ce9c8d113ab1c3769d63b59b544813bb107c2f1c))
129 | * user Widget laravel 8 compatability ([f9dd25f](https://github.com/phpsa/filament-authentication/commit/f9dd25f5eff7d110367cf61c666752b49ba60c20))
130 |
131 | # [1.1.0](https://github.com/phpsa/filament-authentication/compare/v1.0.1...v1.1.0) (2022-04-23)
132 |
133 |
134 | ### Features
135 |
136 | * allow enable / disable / config of user widget ([74329cb](https://github.com/phpsa/filament-authentication/commit/74329cb4ff4db269796a9bb8750f8d39a9452dfa))
137 | * User Impersonation ([fb30d9e](https://github.com/phpsa/filament-authentication/commit/fb30d9e2b47d5a8f04a5ac12fa22782b51c0556e))
138 |
139 | ## [1.0.1](https://github.com/phpsa/filament-authentication/compare/v1.0.0...v1.0.1) (2022-04-22)
140 |
141 |
142 | ### Bug Fixes
143 |
144 | * set page resources to use config value for resource ([f239ca9](https://github.com/phpsa/filament-authentication/commit/f239ca9ab732895147e1cc606780870ce8bf58df))
145 |
146 | # 1.0.0 (2022-04-20)
147 |
148 |
149 | ### Bug Fixes
150 |
151 | * remove pagination on widget ([b8a5e99](https://github.com/phpsa/filament-authentication/commit/b8a5e9947d666715c8f82637d6b363bdbfacfca4))
152 |
153 |
154 | ### Features
155 |
156 | * Initial Commit ([a5b7299](https://github.com/phpsa/filament-authentication/commit/a5b72991624e1049369c3ff453c14449aa391885))
157 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright 2022 phspa
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://packagist.org/packages/phpsa/filament-authentication)
2 | [](https://github.com/phpsa/filament-authentication/actions/workflows/release.yml)
3 | [](https://packagist.org/packages/phpsa/filament-authentication)
4 |
5 | # Filament User Authentication
6 |
7 | User Resource For Filament Admin along with Roles & Permissions using Spatie
8 |
9 | ## Package Installation
10 |
11 |
12 | You can install the package via composer:
13 |
14 | ```bash
15 | composer require phpsa/filament-authentication
16 | ```
17 | and run the install command
18 |
19 | ```bash
20 | php artisan filament-authentication:install
21 | ```
22 | this will publish the config file and migrations
23 |
24 |
25 | optionally publish views / translations
26 | ```bash
27 | artisan vendor:publish --tag=filament-authentication-views
28 | artisan vendor:publish --tag=filament-authentication-translations
29 | ```
30 |
31 | ### Spatie Roles & Permissions
32 | If you have not yet configured this package it is automatically added by this installer, run the following steps:
33 |
34 | 1. You should publish the migration and the config/permission.php config file with:
35 |
36 | ```php
37 | php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
38 | php artisan migrate
39 | ```
40 |
41 | 2. Add the `Spatie\Permission\Traits\HasRoles` trait to your Users model
42 |
43 | 3. Add Roles & Permissions as required
44 |
45 | For more see: https://spatie.be/docs/laravel-permission/v6/introduction
46 |
47 |
48 | ## Setup & Config
49 |
50 | in your Filament panel file you need to add the following to the Plugins section
51 |
52 | add the resources
53 | ```php
54 | public function panel(Panel $panel): Panel
55 | {
56 | return $panel
57 | ...
58 | ->plugins([
59 | \Phpsa\FilamentAuthentication\FilamentAuthentication::make(),
60 | ])
61 | ...
62 | ```
63 |
64 | You can configure this via either the config file or the plugin.
65 |
66 |
67 | # Features
68 | ## 1. Widgets
69 | `LatestUsersWidget` can be added to your dashboard by adding it to your panel widgets area..
70 | ```
71 | LatestUsersWidget::class
72 | ```
73 |
74 | Note that it is also attached to the UserPolicy::viewAny policy value if the policy exists
75 |
76 |
77 | ## 2. Laravel Impersonate
78 | If you have not configured this package it is automatically added by this install, run the following steps:
79 |
80 | 1. Add the trait `Lab404\Impersonate\Models\Impersonate` to your User model.
81 | 2. edit the config file and set impersonate->enabled to true
82 |
83 | ### Defining impersonation authorization
84 |
85 | By default all users can **impersonate** an user.
86 | You need to add the method `canImpersonate()` to your user model:
87 |
88 | ```php
89 | /**
90 | * @return bool
91 | */
92 | public function canImpersonate()
93 | {
94 | // For example
95 | return $this->is_admin == 1;
96 | }
97 | ```
98 |
99 | By default all users can **be impersonated**.
100 | You need to add the method `canBeImpersonated()` to your user model to extend this behavior:
101 |
102 | ```php
103 | /**
104 | * @return bool
105 | */
106 | public function canBeImpersonated()
107 | {
108 | // For example
109 | return $this->can_be_impersonated == 1;
110 | }
111 | ```
112 |
113 | **Protect From Impersonation**
114 |
115 | You can use the middleware `impersonate.protect` to protect your routes against user impersonation.
116 | This middleware can be useful when you want to protect specific pages like users subscriptions, users credit cards, ...
117 |
118 | ```php
119 | Router::get('/my-credit-card', function() {
120 | echo "Can't be accessed by an impersonator";
121 | })->middleware('impersonate.protect');
122 | ```
123 |
124 | **Events**
125 | There are two events available that can be used to improve your workflow:
126 | - `TakeImpersonation` is fired when an impersonation is taken.
127 | - `LeaveImpersonation` is fired when an impersonation is leaved.
128 |
129 | Each events returns two properties `$event->impersonator` and `$event->impersonated` containing User model instance.
130 |
131 | ## 3. Password Renewal
132 |
133 | Introduced in V4.2.0 - this allows you to enforce a user to change their password every X days.
134 |
135 | Enable this & configure this as Follows:
136 | 1. add the `Phpsa\FilamentAuthentication\Traits\CanRenewPassword` trait to your user model
137 | 2. configure the options for pruning and renewal day period in the config file
138 | 3. if not published, publish migration `artisan vendor:publish --tag filament-authentication-migrations`
139 |
140 | this will force a user to update their password, note -- all existing users will initially be foreced to, this can be ignored by running the following command:
141 |
142 | From V5.0.0 - there is a new validation rule that can be added to validate that a password has not been used before.
143 | `Phpsa\FilamentAuthentication\Rules\PreventPasswordReuseRule` - this will use the value from config `filament-authentication.password_renew.prevent_password_reuse` 0 to disable, any number of previous to block out fro re-use.
144 |
145 | -- If using socialite / Filament-socialite etc, you will need to override the `public function needsRenewal(): bool` method in the trait,
146 | EG:
147 | ```php
148 | use CanRenewPassword {
149 | CanRenewPassword::needsRenewal as traitNeedsRenewal;
150 | }
151 |
152 | public function needsRenewal(): bool
153 | {
154 | if ($this->password === null && SocialiteUser::where('user_id', $this->id)->exists()) {
155 | return false;
156 | }
157 | return $this->traitNeedsRenewal();
158 | }
159 | ```
160 |
161 | ## Authentication Log
162 |
163 | Introduced in V4.2.0 - this allows you to log each user login attempt.
164 |
165 | Enable this & configure this as follows:
166 | 1. add the `Phpsa\FilamentAuthentication\Traits\LogsAuthentication` trait to your user model
167 | 2. configure the options for prune in the authentication_log section of the config
168 | 3. optionally enable the resource in navigation section of the config file.
169 | 4. if not published, publish migration `artisan vendor:publish --tag filament-authentication-migrations`
170 |
171 | this will now log login and logouts on the system.
172 |
173 | ## Security
174 | Roles & Permissions can be secured using Laravel Policies,
175 | create your policies and register then in the AuthServiceProvider
176 |
177 | ```php
178 | protected $policies = [
179 | Role::class => RolePolicy::class,
180 | Permission::class => PermissionPolicy::class,
181 | CustomPage::class => CustomPagePolicy::class,
182 | SettingsPage::class => SettingsPagePolicy::class
183 | // 'App\Models\Model' => 'App\Policies\ModelPolicy',
184 | ];
185 | ```
186 |
187 | We have a Custom Page Trait: `Phpsa\FilamentAuthentication\Traits\PagePolicyTrait` and a Spatie Settings Page Trait `Phpsa\FilamentAuthentication\Traits\SettingsPage\PolicyTrait` that you can add to your pages / settings pages.
188 | By defining a model and mapping it with a `viewAny($user)` method you can define per policies whether or not to show the page in navigation.
189 |
190 |
191 |
192 |
193 | ## Events
194 |
195 | `Phpsa\FilamentAuthentication\Events\UserCreated` is triggered when a user is created via the Resource
196 |
197 | `Phpsa\FilamentAuthentication\Events\UserUpdated` is triggered when a user is updated via the Resource
198 |
199 | ## Future Plans
200 | * MFA Authentication
201 | * Socialite Authentication
202 | * Biometrics Athentication
203 |
204 | ## Changelog
205 |
206 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
207 |
208 | ## Credits
209 |
210 | - [Phpsa](https://github.com/phpsa)
211 |
212 | ## License
213 |
214 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
215 |
--------------------------------------------------------------------------------
/UPGRADE.md:
--------------------------------------------------------------------------------
1 | # Upgrading V4 - V5
2 |
3 | Breaking Changes:
4 | - Impersonation - links now generated based on panels, so route name and path will be slightly different
5 | - Password Renew - added phash to the table to store previous passwords, this will be used to validate if a password has been used before.
6 |
7 |
8 |
9 | Upgrading V2 - V3
10 |
11 | - Widget / panels no longer auto-published
12 | - Profile screen removed in favour of Filaments default one
13 |
14 | Breaking Change V1 - V2
15 | *****
16 |
17 | -- no longer customises the DateTime values in the user tables, makes use of Filament core verson.
18 |
19 | in your AppServiceProvider add the following to the boot method:
20 | ```php
21 | DateTimePicker::configureUsing(fn (DateTimePicker $component) => $component->timezone(config('app.user_timezone')));
22 | TextColumn::configureUsing(fn (TextColumn $column) => $column->timezone(config('app.user_timezone')));
23 | ```
24 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "phpsa/filament-authentication",
3 | "description": "User & Role (via Spatie Roles/Permissions) Manager Resource For Filament Admin",
4 | "keywords": [
5 | "laravel",
6 | "user",
7 | "cli",
8 | "resource",
9 | "ui",
10 | "filament"
11 | ],
12 | "homepage": "https://cgs4k.nz",
13 | "license": "MIT",
14 | "autoload": {
15 | "psr-4": {
16 | "Phpsa\\FilamentAuthentication\\": "src/"
17 | }
18 | },
19 | "authors": [
20 | {
21 | "name": "Craig G Smith",
22 | "email": "vxdhost@gmail.com"
23 | }
24 | ],
25 | "minimum-stability": "dev",
26 | "require": {
27 | "php": "^8.1",
28 | "filament/filament": "^3.0",
29 | "illuminate/support": "^9.0|^10|^11|^12.0",
30 | "lab404/laravel-impersonate": "^1.7",
31 | "spatie/laravel-package-tools": "^1.13",
32 | "spatie/laravel-permission": "^5.5|^6.0"
33 | },
34 | "require-dev": {
35 | "laravel/pint": "^1.2",
36 | "larastan/larastan": "^3.0",
37 | "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0"
38 | },
39 | "config": {
40 | "sort-packages": true
41 | },
42 | "extra": {
43 | "laravel": {
44 | "providers": [
45 | "Phpsa\\FilamentAuthentication\\FilamentAuthenticationProvider"
46 | ]
47 | }
48 | },
49 | "prefer-stable": true,
50 | "scripts": {
51 | "test": "phpunit",
52 | "phpstan": "phpstan analyse"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/config/filament-authentication.php:
--------------------------------------------------------------------------------
1 | [
5 | 'User' => \App\Models\User::class,
6 | 'Role' => \Spatie\Permission\Models\Role::class,
7 | 'Permission' => \Spatie\Permission\Models\Permission::class,
8 | 'AuthenticationLog' => \Phpsa\FilamentAuthentication\Models\AuthenticationLog::class,
9 | 'PasswordRenewLog' => \Phpsa\FilamentAuthentication\Models\PasswordRenewLog::class,
10 | ],
11 | 'resources' => [
12 | 'UserResource' => \Phpsa\FilamentAuthentication\Resources\UserResource::class,
13 | 'RoleResource' => \Phpsa\FilamentAuthentication\Resources\RoleResource::class,
14 | 'PermissionResource' => \Phpsa\FilamentAuthentication\Resources\PermissionResource::class,
15 | 'AuthenticationLogResource' => \Phpsa\FilamentAuthentication\Resources\AuthenticationLogResource::class,
16 | ],
17 | 'navigation' => [
18 | 'user' => [
19 | 'register' => true,
20 | 'sort' => 1,
21 | 'icon' => 'heroicon-o-user'
22 | ],
23 | 'role' => [
24 | 'register' => true,
25 | 'sort' => 3,
26 | 'icon' => 'heroicon-o-user-group'
27 | ],
28 | 'permission' => [
29 | 'register' => true,
30 | 'sort' => 4,
31 | 'icon' => 'heroicon-o-lock-closed'
32 | ],
33 | 'authentication_log' => [
34 | 'register' => false,
35 | 'sort' => 2,
36 | 'icon' => 'heroicon-o-shield-check'
37 | ],
38 | ],
39 | 'preload_roles' => true,
40 | 'preload_permissions' => true,
41 | 'impersonate' => [
42 | 'enabled' => false,
43 | 'guard' => 'web',
44 | 'redirect' => '/'
45 | ],
46 | 'soft_deletes' => false,
47 | 'authentication_log' => [
48 | 'table_name' => 'authentication_log',
49 | //The database connection where the authentication_log table resides. Leave empty to use the default
50 | 'db_connection' => null,
51 | //The number of days to keep the authentication logs for. Set to 0 to keep forever
52 | // remeber to schedule
53 | //Schedule::command('model:prune')->daily();
54 | 'prune' => 365,
55 | ],
56 | 'password_renew' => [
57 | 'table_name' => 'password_renew_log',
58 | //The database connection where the password_logs table resides. Leave empty to use the default
59 | 'db_connection' => null,
60 | //The number of days to keep the password logs for. Set to 0 to keep forever
61 | // remeber to schedule
62 | //Schedule::command('model:prune')->daily();
63 | 'prune' => 365,
64 | //renew password days period, 0 to disable
65 | 'renew_password_days_period' => 90,
66 | //prevent password reuse for x times, 0 to disable
67 | 'prevent_password_reuse' => 0,
68 | ],
69 |
70 |
71 | ];
72 |
--------------------------------------------------------------------------------
/database/migrations/create_filament_authentication_tables.php.stub:
--------------------------------------------------------------------------------
1 | id();
13 | $table->morphs('authenticatable');
14 | $table->string('ip_address', 45)->nullable();
15 | $table->text('user_agent')->nullable();
16 | $table->timestamp('login_at')->nullable();
17 | $table->boolean('login_successful')->default(false);
18 | $table->timestamp('logout_at')->nullable();
19 | $table->boolean('cleared_by_user')->default(false);
20 | $table->json('location')->nullable();
21 | });
22 | }
23 |
24 | public function down(): void
25 | {
26 | Schema::dropIfExists(config('filament-authentication.authentication_log.table_name'));
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/database/migrations/create_filament_password_renew_table.php.stub:
--------------------------------------------------------------------------------
1 | id();
13 | $table->morphs('renewable');
14 | $table->timestamps();
15 | });
16 | }
17 |
18 | public function down(): void
19 | {
20 | Schema::dropIfExists(config('filament-authentication.password_renew.table_name'));
21 | }
22 | };
23 |
--------------------------------------------------------------------------------
/database/migrations/tracks_filament_password_hashes.php.stub:
--------------------------------------------------------------------------------
1 | string('phash', 255)->nullable()->after('renewable_id');
13 | });
14 | }
15 |
16 | };
17 |
--------------------------------------------------------------------------------
/docs/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/phpsa/filament-authentication/f1c48294344cdb8d36f028fd5cf54610ac34e095/docs/.gitkeep
--------------------------------------------------------------------------------
/larastan/Facades.stub:
--------------------------------------------------------------------------------
1 |
2 |