Backend controllers and scaffolding for Laravel authentication.

Overview

Logo Laravel Fortify

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Fortify is a frontend agnostic authentication backend for Laravel. Fortify powers the registration, authentication, and two-factor authentication features of Laravel Jetstream.

Official Documentation

Documentation for Fortify can be found on the Laravel website.

Contributing

Thank you for considering contributing to Fortify! You can read the contribution guide here.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel Fortify is open-sourced software licensed under the MIT license.

Comments
  • Current 2FA solution can lock users out of their accounts

    Current 2FA solution can lock users out of their accounts

    • Version: v1.7.4
    • Laravel Version: v8.22.1
    • PHP Version: v7.4.13

    Description:

    The current two factor authentication solution sets 2fa to enabled without requiring a confirmation (via TOTP) that the authenticator app is actually set up.

    Steps To Reproduce:

    The current solution works like this:

    1. POST /user/two-factor-authentication, the user's two_factor_secret is stored. (2fa is now enabled!)
    2. GET /user/two-factor-qr-code, show QR code and ask user to scan the code with their app.
    3. GET /user/two-factor-recovery-codes, show recovery codes and ask the user to save them.
    4. User abandons the process before setting up their authenticator app or saving the recovery codes and is now locked out of their account.

    They could abandon the process because they first need to choose one of the many TOTP generators in the app store, and get side tracked, or their session times out, or they click the back button, or close their tab, or their computer crashes, ... Definitely 2fa must not be enabled before it is confirmed by a generated OTP.

    How To Fix It:

    1. GET /user/two-factor-qr-code generates a QR code from a new two factor secret that is stored in the session.
    2. GET /user/two-factor-recovery-codes, show the recovery codes to the user, ask them to save them.
    3. The user is asked to set up their authenticator app with this QR code and enter a resulting TOTP code. This confirms that they have set up their authenticator (else they cannot generate a valid code), and can also (by written explanation) be used as confirmation that recovery codes were stored in a safe place.
    4. POST /user/two-factor-authentication, receives a new parameter: code. The code is validated using the two factor secret stored in the session.
    5. If the code is valid, the two factor secret from the session is written into the user table (= enabling 2fa, now for real). If not, then the response indicates that the user did not enter a valid code and must re-try.
    enhancement 
    opened by LeoniePhiline 39
  • Redirection customization

    Redirection customization

    It would be nice to offer customization options for redirection such as Fortify::redirectAfterLoginUsing($callback) or Fortify::redirectAfterRegisterUsing($callback). This would bring back laravel/ui redirectTo capabilities. What do you think ? Do you prefer to encourage people to use custom Response classes and to put them under app/Http/Responses/Fortify ?

    Concerning the registration use case, maybe it's pretty common to redirect users to a tour/guide page, so what do you think about a dedicated configuration key to set the path ?

    enhancement 
    opened by webchopin 17
  • Webauthn support

    Webauthn support

    Would you be interested in a PR that adds webauthn (Security Keys and TouchID) support to Fortify and Jetstream? Would be awesome to have something like this out of the box.

    enhancement 
    opened by m1guelpf 16
  • [1.x] Improve Email Verification For SPA's using Laravel as an API

    [1.x] Improve Email Verification For SPA's using Laravel as an API

    Currently you are unable to use the VerifyEmailController with Fortify if you want to have an SPA which doesn't use Laravel's view templates. The reason for this is Laravel set's the route middleware to be signed and doesn't allow for using signed:relative. Also the VerifyEmailController currently only redirects to the home url set in the config template.

    This PR enables a config variable for setting signed:relative but defaults to signed and returns json within the VerifyEmailController if the request wantsJson.

    opened by garethredfern 15
  • [v1.0] Extensibility of Actions using Authentication User Providers

    [v1.0] Extensibility of Actions using Authentication User Providers

    I know this is extremely early since this just got released -- but I'm wondering if there's any plans on adding the ability to override the included actions, or for the actions to utilize other authentication providers besides eloquent?

    The current RedirectIfTwoFactorAuthenticatable action uses a getModel() method that is not currently inside the Stateful guard contract:

    https://github.com/laravel/fortify/blob/f29ed3f63d6da006fb540e2894e4aa387ccabde2/src/Actions/RedirectIfTwoFactorAuthenticatable.php#L51

    This action (RedirectIfTwoFactorAuthenticatable) is also responsible for validating the users credentials -- but isn't the authentication UserProvider responsible for this?

    https://github.com/laravel/framework/blob/c87794fc354941729d1f0c4607693c0b8d2cfda2/src/Illuminate/Contracts/Auth/UserProvider.php#L48

    The other concern is that the AttemptToAuthenticate action only allows customization of the username passed into the $guard->attempt() method, while Laravel UI allows you to customize the whole array of credentials passed in:

    AttemptToAuthenticate Action in Fortify: https://github.com/laravel/fortify/blob/4be99538e23fc4a04a4cbf305ab055f2e52537b6/src/Actions/AttemptToAuthenticate.php#L46-L53

    AuthenticatesUsers Trait in Laravel UI: https://github.com/laravel/ui/blob/6ed3b97576fc99049ba576de4cfab5cef4771ab3/auth-backend/AuthenticatesUsers.php#L93-L96

    Please don't take these questions in any sort of negative manor -- I'm immensely grateful for the insane amount of free work that was put into this! ❤️

    If there is interest in this possibility, I can work on a PR to add this extensibility and you can look at it to see if it's something you like / don't like. If it's denied, no hard feelings 👍

    Related: #16, https://github.com/DirectoryTree/LdapRecord-Laravel/issues/196

    opened by stevebauman 14
  • Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable.

    Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable.

    • Fortify Version: 0.0.1
    • Laravel Version: 8.x-dev 02522b0
    • PHP Version: 7.3.21
    • Database Version: 8.0.19

    Description:

    Illuminate\Contracts\Container\BindingResolutionException Target [Laravel\Fortify\Contracts\CreatesNewUsers] is not instantiable.

    Steps To Reproduce:

    Windows environment

    laravel new jetstream --jet --dev select livewire and teams php artisan migrate php artisan serve

    Register a new user and click "Register"

    opened by jozeflambrecht 11
  • fix optional feature: Two-Factor confirmation

    fix optional feature: Two-Factor confirmation

    after installation completed, and once you run the migrate command, enabling the Two-Factor confirmation feature will break the Two-Factor "Disable" button at least.

    Column not found: 1054 Unknown column 'two_factor_confirmed_at' in 'field list'

    opened by magdicom 10
  • Fortify::authenticateUsing called twice

    Fortify::authenticateUsing called twice

    • Fortify Version: 1.8
    • Laravel Version: 8.65
    • PHP Version: 8.0
    • Database Driver & Version:

    Description:

    The Fortify::authenticateUsing method is triggered twice for each request.

    Steps To Reproduce:

    In FortifyServiceProvider create an index: protected $i=1;

    In boot method add tis function:

        Fortify::authenticateUsing(function (Request $request) {
            $this->i++;
    
            if( $this->i > 2){
                dd('hmm', $this->i);
            }
            $user = User::where('email', $request->email)->first();
            if ($user && Hash::check($request->password, $user->password)) {
                return $user;
            }
        });
    
        Fortify::loginView(function () {
            return view('user::auth.login');
        });
    

    You will get: "hmm" 3

    needs more info 
    opened by oulfr 9
  • Use fortify authentication in multiple places of the same website

    Use fortify authentication in multiple places of the same website

    Using laravel/UI we can create authentication scaffold on multiple places or for multiple users like admin, normal users by copy-pasting the same scaffold generated by the --auth flag.

    How can we achieve the same with fortify?

    How can we use forify to authorize admin and normal users?

    opened by AjithLalps 9
  • Password reset exposes if an account exists

    Password reset exposes if an account exists

    Description:

    When performing a password reset, users enter an email address and the request gets posted to /forgot-password. If someone enters an email that doesn't exist, Fortify returns an error. If the email does exist, it returns a status message that the email has been sent.

    This exposes whether or not an account exists on the system which provides an attacker with information. They can now target that user/email address directly with phishing or social engineering attempts.

    Best practice would be to skip returning any errors and to always notify users that "An email has been sent to [email protected] with password reset instructions."

    opened by bkilshaw 9
  • Use method DI instead of constructor DI to allow packages like Laravel tenancy works with Fortify out of the box

    Use method DI instead of constructor DI to allow packages like Laravel tenancy works with Fortify out of the box

    As you can read at #163

    According to:

    https://tenancyforlaravel.com/docs/v3/early-identification

    Using constructor DI avoids tenancy route middleware to works. The reason is Constructor DI is executed before middleware.

    AFAIK the proposed changes will solve the issue and will make building web apps with Laravel Tenancy package and Fortify/Jetstream easier but feel free to close this PR for any reason...

    opened by acacha 8
Releases(v1.14.1)
Owner
The Laravel Framework
The Laravel Framework
Create secure controllers with routing system in Laravel.

Power Gates A simple Laravel application for testing Gates and Policy. Using laravel middlewares, routes and gates to create an Authenticated website.

AmirH.Najafizadeh 4 Jul 31, 2022
Laravel starter kit with Livewire & Bootstrap 5 auth scaffolding.

Laravel Livewire Auth Laravel starter kit with Livewire & Bootstrap 5 auth scaffolding. Requirements NPM Installation Create a new Laravel app: larave

null 8 Sep 11, 2021
Laravel JWT-Authentication API starter kit for rapid backend prototyping.

Laravel JWT API A Laravel JWT API starter kit. Features Laravel 8 Login, register, email verification and password reset Authentication with JWT Socia

Oybek Odilov 3 Nov 6, 2022
It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session and API Authentication

About Auth Starter It's a Laravel 8 authentication markdown that will help you to understand and grasp all the underlying functionality for Session an

Sami Alateya 10 Aug 3, 2022
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

Rinvex Authy Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest AP

Rinvex 34 Feb 14, 2022
phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

phpCAS is an authentication library that allows PHP applications to easily authenticate users via a Central Authentication Service (CAS) server.

Apereo Foundation 780 Dec 24, 2022
Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system.

Laravel Auth is a Complete Build of Laravel 8 with Email Registration Verification, Social Authentication, User Roles and Permissions, User Profiles, and Admin restricted user management system. Built on Bootstrap 4.

Jeremy Kenedy 2.8k Dec 31, 2022
Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use

Introduction Laravel Passport is an OAuth2 server and API authentication package that is simple and enjoyable to use. Official Documentation Documenta

The Laravel Framework 3.1k Dec 31, 2022
Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.

Introduction Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs. Official Documentation Documentation for Sanctum

The Laravel Framework 2.4k Dec 30, 2022
Social OAuth Authentication for Laravel 5. drivers: facebook, github, google, linkedin, weibo, qq, wechat and douban

Social OAuth Authentication for Laravel 5. drivers: facebook, github, google, linkedin, weibo, qq, wechat and douban

安正超 330 Nov 14, 2022
SPA authentication demo with Laravel Sanctum and Nuxt.js (Buefy components)

laravel-sanctum-nuxt-spa SPA authentication demo with Laravel Sanctum and Nuxt.js (Buefy components) Project structure Backend: Cookie-based authentic

codezri 3 Aug 20, 2022
:octocat: Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, you can easily use it without Laravel.

Socialite Socialite is an OAuth2 Authentication tool. It is inspired by laravel/socialite, You can easily use it in any PHP project. 中文文档 This tool no

安正超 1.2k Dec 22, 2022
A Simple method to create laravel authentication for an existing laravel project.

Laravel Simple Auth A Simple method to create laravel authentication for an existing laravel project. Indroduction Why I created this kind of package?

Dasun Tharanga 10 Dec 14, 2021
Provides a unified interface to local and remote authentication systems.

Aura.Auth Provides authentication functionality and session tracking using various adapters; currently supported adapters are: Apache htpasswd files S

Aura for PHP 125 Sep 28, 2022
This is registration and authentication forms written in PHP, JQuery

Registration-form This is registration and authentication forms written in PHP, JQuery Each file is: header.php - html-file for links "Главная", "Реги

Galina 2 Nov 2, 2021
Authentication and authorization library for Codeigniter 4

Authentication and Authorization Library for CodeIgniter 4. This library provides an easy and simple way to create login, logout, and user registratio

Rizky Kurniawan 12 Oct 10, 2022
PHP class to generate and verify Google Authenticator 2-factor authentication

Google Authenticator PHP class Copyright (c) 2012-2016, http://www.phpgangsta.de Author: Michael Kliewe, @PHPGangsta and contributors Licensed under t

Michael Kliewe 2.1k Jan 2, 2023
PSR-7 and PSR-15 JWT Authentication Middleware

PSR-7 and PSR-15 JWT Authentication Middleware This middleware implements JSON Web Token Authentication. It was originally developed for Slim but can

Mika Tuupola 782 Dec 18, 2022
Log user authentication details and send new device notifications.

Laravel Authentication Log is a package which tracks your user's authentication information such as login/logout time, IP, Browser, Location, etc. as well as sends out notifications via mail, slack, or sms for new devices and failed logins.

John S Nwanosike 2 Mar 13, 2022