Giter Site home page Giter Site logo

myth-auth's Introduction

Myth:Auth

Coverage Status

Flexible, Powerful, Secure auth package for CodeIgniter 4.

Project Notice

As of June 2022 CodeIgniter now has an official Authentication library, CodeIgniter Shield. If you are looking for an authentication solution for a new project then that is the recommended solution.

This project is now maintained by volunteers. If you interact with the project repository there may be delays in receiving response. Please direct support questions to GitHub Discussions or to CodeIgniter's Forums or Slack Channel.

Requirements

  • PHP 7.4+, 8.0+
  • CodeIgniter 4.1+

Features

This is meant to be a one-stop shop for 99% of your web-based authentication needs with CI4. It includes the following primary features:

  • Password-based authentication with remember-me functionality for web apps
  • Flat RBAC per NIST standards, described here and here.
  • All views necessary for login, registration and forgotten password flows.
  • Publish files to the main application via a CLI command for easy customization
  • Debug Toolbar integration
  • Email-based account verification

Installation

Installation is best done via Composer. Assuming Composer is installed globally, you may use the following command:

    > composer require myth/auth

This will add the latest stable release of Myth:Auth as a module to your project.

Manual Installation

Should you choose not to use Composer to install, you can clone or download this repo and then enable it by editing app/Config/Autoload.php and adding the Myth\Auth namespace to the $psr4 array. For example, if you copied it into app/ThirdParty/:

    $psr4 = [
        'Config'      => APPPATH . 'Config',
        APP_NAMESPACE => APPPATH,
        'App'         => APPPATH,
        'Myth\Auth'   => APPPATH . 'ThirdParty/myth-auth/src',
    ];

Upgrading

Be sure to check the Changes Docs for necessary steps to take after upgrading versions.

Configuration

Once installed you need to configure the framework to use the Myth\Auth library. In your application, perform the following setup:

  1. Edit app/Config/Email.php and verify that a fromName and fromEmail are set as that is used when sending emails for password reset, etc.

  2. Edit app/Config/Validation.php and add the following value to the ruleSets array: \Myth\Auth\Authentication\Passwords\ValidationRules::class

  3. Ensure your database is setup correctly, then run the Auth migrations:

    > php spark migrate -all  

NOTE: This library uses your application's cache settings to reduce database lookups. If you want to make use of this, simply make sure that your are using a cache engine other than dummy and it is properly setup. The GroupModel and PermissionModel will handle caching and invalidation in the background for you.

Overview

When first installed, Myth:Auth is setup to provide all of the basic authentication services for you, including new user registration, login/logout, and forgotten password flows.

"Remember Me" functionality is turned off by default though it can be turned on by setting the $allowRemembering variable to be true in Config/Auth.php.

Routes

Routes are defined in Auth's Config/Routes.php file. This file is automatically located by CodeIgniter when it is processing the routes. If you would like to customize the routes, you should copy the file to the app/Config directory, update the namespace, and make your route changes there. You may also use the $reservedRoutes property of Config\Auth to redirect internal route names.

Views

Basic views are provided that are based on Bootstrap 4 for all features.

You can easily override the views used by editing Config/Auth.php, and changing the appropriate values within the $views variable:

public $views = [
    'login'       => 'Myth\Auth\Views\login',
    'register'    => 'Myth\Auth\Views\register',
    'forgot'      => 'Myth\Auth\Views\forgot',
    'reset'       => 'Myth\Auth\Views\reset',
    'emailForgot' => 'Myth\Auth\Views\emails\forgot',
];

NOTE: If you're not familiar with how views can be namespaced in CodeIgniter, please refer to the CodeIgniter User Guide for section on Code Module support.

Services

The following Services are provided by the package:

authentication

Provides access to any of the authentication packages that Myth:Auth knows about. By default it will return the "Local Authentication" library, which is the basic password-based system.

    $authenticate = service('authentication');

You can specify the library to use as the first argument:

    $authenticate = service('authentication', 'jwt');

authorization

Provides access to any of the authorization libraries that Myth:Auth knows about. By default it will return the "Flat" authorization library, which is a Flat RBAC (role-based access control) as defined by NIST. It provides user-specific permissions as well as group (role) based permissions.

    $authorize = service('authorization');

passwords

Provides direct access to the Password validation system. This is an expandable system that currently supports many of NIST's latest Digital Identity guidelines. The validator comes with a dictionary of over 620,000 common/leaked passwords that can be checked against. A handful of variations on the user's email/username are automatically checked against.

    $authenticate = service('passwords');

Most of the time you should not need to access this library directly, though, as a new Validation rule is provided that can be used with the Validation library, strong_password. In order to enable this, you must first edit app/Config/Validation.php and add the new ruleset to the available rule sets:

     public $ruleSets = [
        \CodeIgniter\Validation\Rules::class,
        \CodeIgniter\Validation\FormatRules::class,
        \CodeIgniter\Validation\FileRules::class,
        \CodeIgniter\Validation\CreditCardRules::class,
        \Myth\Auth\Authentication\Passwords\ValidationRules::class,
    ];

Now you can use strong_password in any set of rules for validation:

    $validation->setRules([
        'username' => 'required',
        'password' => 'required|strong_password'
    ]);

Helper Functions

Myth:Auth comes with its own Helper that includes the following helper functions to ease access to basic features. Be sure to load the helper before using these functions: helper('auth');

Hint: Add 'auth' to any controller's $helper property to have it loaded automatically, or the same in app/Controllers/BaseController.php to have it globally available. the auth filters all pre-load the helper so it is available on any filtered routes.

logged_in()

  • Function: Checks to see if any user is logged in.
  • Parameters: None
  • Returns: true or false

user()

  • Function: Returns the User instance for the current logged in user.
  • Parameters: None
  • Returns: The current User entity, or null

user_id()

  • Function: Returns the User ID for the current logged in user.
  • Parameters: None
  • Returns: The current User's integer ID, or null

in_groups()

  • Function: Ensures that the current user is in at least one of the passed in groups.
  • Parameters: Group IDs or names, as either a single item or an array of items.
  • Returns: true or false

has_permission()

  • Function: Ensures that the current user has at least one of the passed in permissions.
  • Parameters: Permission ID or name.
  • Returns: true or false

Users

Myth:Auth uses CodeIgniter Entities for it's User object, and your application must also use that class. This class provides automatic password hashing as well as utility methods for banning/un-banning, password reset hash generation, and more.

It also provides a UserModel that should be used as it provides methods needed during the password-reset flow, as well as basic validation rules. You are free to extend this class or modify it as needed.

The UserModel can automatically assign a role during user creation. Pass the group name to the withGroup() method prior to calling insert() or save() to create a new user and the user will be automatically added to that group.

    $user = $userModel
                ->withGroup('guests')
                ->insert($data);

User registration already handles this for you, and looks to the Auth config file's, $defaultUserGroup setting for the name of the group to add the user to. Please, keep in mind that $defaultUserGroup variable is not set by default.

Toolbar

Myth:Auth includes a toolbar collector to make it easy for developers to work with and troubleshoot the authentication process. To enable the collector, edit app/Config/Toolbar.php and add it to the list of active collectors:

	public $collectors = [
		\CodeIgniter\Debug\Toolbar\Collectors\Timers::class,
		\CodeIgniter\Debug\Toolbar\Collectors\Database::class,
        ...
		\Myth\Auth\Collectors\Auth::class,
	];

Restricting by Route

If you specify each of your routes within the app/Config/Routes.php file, you can restrict access to users by group/role or permission with Controller Filters.

First, edit application/Config/Filters.php and add the following entries to the aliases property:

    'login'      => \Myth\Auth\Filters\LoginFilter::class,
    'role'       => \Myth\Auth\Filters\RoleFilter::class,
    'permission' => \Myth\Auth\Filters\PermissionFilter::class,

Global restrictions

The role and permission filters require additional parameters, but LoginFilter can be used to restrict portions of a site (or the entire site) to any authenticated user. If no logged in user is detected then the filter will redirect users to the login form.

Restrict routes based on their URI pattern by editing app/Config/Filters.php and adding them to the $filters array, e.g.:

public filters = [
    'login' => ['before' => ['account/*']],
];

Or restrict your entire site by adding the LoginFilter to the $globals array:

    public $globals = [
        'before' => [
            'honeypot',
            'login',
    ...

Restricting a single route

Any single route can be restricted by adding the filter option to the last parameter in any of the route definition methods:

$routes->get('admin/users', 'UserController::index', ['filter' => 'permission:manage-user'])
$routes->get('admin/users', 'UserController::index', ['filter' => 'role:admin,superadmin'])

The filter can be either role or permission, which restricts the route by either group or permission. You must add a comma-separated list of groups or permissions to check the logged in user against.

Restricting Route Groups

In the same way, entire groups of routes can be restricted within the group() method:

$routes->group('admin', ['filter' => 'role:admin,superadmin'], function($routes) {
    ...
});

Customization

See the Extending documentation.

myth-auth's People

Contributors

abusalam avatar agungsugiarto avatar ballpumpe avatar colethorsen avatar dafriend avatar dependabot[bot] avatar eafarooqi avatar eeel-12 avatar fefo-p avatar guxmartin avatar hatsat32 avatar jamesshaver avatar lonnieezell avatar lyimolucasl avatar manageruz avatar mgatner avatar michalsn avatar mjamilasfihani avatar najdanovicivan avatar ncontrol88 avatar nynsen avatar oleg1540 avatar paulbalandan avatar rafinhaa avatar sclubricants avatar timz99 avatar titounnes avatar vizzielli avatar xlii-chl avatar yassinedoghri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

myth-auth's Issues

Validation errors

Hi,
I don't see how I can get validation errors. When eg my group edit was failed I try to get an error from FlatAuthorization::error() but I get nothing. Validation errors we should get from $this->groupModel->errors() but we don't have access for that.

I am talking about this part (and more)

        if (! $this->groupModel->update($id, $data))
        {
            $this->error = $this->groupModel->error();

            return false;
        }

Error Register

Codeigniter Version 4.0.0-rc.2.1
Myth\Auth Version dev-develop

ErrorException
Undefined variable: errors

SYSTEMPATH/Validation\Validation.php at line 651

/span>         // If we already have errors, we'll use those.
/span>         // If we don't, check the session to see if any were
/span>         // passed along from a redirect_with_input request.
/span>         if (empty($this->errors) && ! is_cli())
/span>         {
/span>             if (isset($_SESSION) && session('_ci_validation_errors'))
/span>             {
/span>                 $this->errors = unserialize($errors);
/span>             }
/span>         }
/span> 
/span>         return $this->errors ?? [];
/span>     }
/span> 
/span>     //--------------------------------------------------------------------

APPPATH/Controllers\AuthController.php : 156 — CodeIgniter\Model->errors ()

/span>             'email'            => 'required|valid_email|is_unique[users.email]',
/span>             'password'        => 'required|strong_password',
/span>             'pass_confirm'    => 'required|matches[password]',
/span>         ]);
/span> 
/span>         if (! $this->validate($rules))
/span>         {
/span>             return redirect()->back()->withInput()->with('errors', $users->errors());
/span>         }
/span> 
/span>         // Save the user
/span>         $user = new User($this->request->getPost());
/span> 
/span>         if (! $users->save($user))
/span>         {

Permission ID not being get

When trying to restrict a method or controller with
$this->restrictWithPermissions('informes.en_sector.create', site_url('dashboard') )
it always redirects as if no permission exited or user is not allowed

PASSWORD_ARGON2ID is a conditional constant

#68 introduced alternate hashing algorithms, but the constant PASSWORD_ARGON2ID is only available if PHP has been compiled with Argon2 support, not a current requirement for Myth:Auth or CodeIgniter4. This causes syntax errors when trying to load the config file or using the User entity or LocalAuthenticator.

Either backing out the changes for Argon2 or adding some conditional constant definition?

Undefined property CSRFHeaderName

After installation appears this error:
Error shows at any routes URLs (register, login, forgot)

Undefined property: Config\App::$CSRFHeaderName
SYSTEMPATH/Security\Security.php at line 183

I can not change user password on check of current password

@lonnieezell I have been trying to update users password but no success. I try to scan through the folk tales of this script. I saw you are using password_hash with base64_encode together so I try using password_verify but no way. Please Can you show me how to do this in order to pass through it. I am trying to verify the current password before changing it.

AuthTrait redirects won't currently

They still follow the CI3 pattern where it would spit out the headers immediately, instead of returning the result. They need to be updated to return redirect().

Rolefilter does not end well when more than one role is checked

Maybe better with an example:

$user= 'dog';
$role= 'doberman';

Routes set:

$routes->get('changepass', 'Admin::changePassword', ['filter' => 'role:doberman,german_sheppard', 'as' => 'change-password']);

Then, analyzing step by step:

$result = true;
// Check each requested permission
foreach (['doberman','german_sheppard'] as $group)
{
	$result = $result && $authorize->inGroup($group, $authenticate->id());
}

$result would be true on first iteration, but would become false on second.
Therefore, final result is FALSE, though $user belongs to role "doberman".

Proposed solution:

$result = false;
// Check each requested permission
foreach ($params as $group)
{
	if (!$result)
	{
		$result = $authorize->inGroup($group, $authenticate->id());
	}
}

Issue on installing with composer

Can not install the myth auth with composer please can you make it compatible.

composer require myth/auth

[InvalidArgumentException]
Could not find a version of package myth/auth matching your minimum-stabili
ty (stable). Require it with an explicit version constraint allowing its de
sired stability.

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest]
 [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--
update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--pref
er-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authorita
tive] [--apcu-autoloader] [--] [<packages>]...

Please check this issue

name is not a property of the Entity user

DictionaryValidator uses the following to check for personal information in the password

if ($user !== null)
{
    $names = [
        strtolower($user->name),
        strtolower(str_replace(' ', '', $user->name)),
        strtolower(str_replace(' ', '.', $user->name)),
        strtolower(str_replace(' ', '-', $user->name)),
    ];

The problem is that, as far as I can determine, the Entity used in myth/auth does not have a name property. Should they all be $user->username?

I have been thinking of offering a PR on this functionality anyway and, if $user->name needs fixing I can fix it there.

Take builder out from $this->builder()->select() in GroupModel.php

return $this->builder()->select('auth_groups_users.*, auth_groups.name, auth_groups.description')

In the last commit, you changed the line (along with namespacing issues)

return $this->select('auth_groups_users.*, auth_groups.name, auth_groups.description') 

to

return $this->builder()->select('auth_groups_users.*, auth_groups.name, auth_groups.description') 

Now it complains about not finding toArray() method.
I took ->builder() out from the statement and it started working again.

Error forgot password

ErrorException
Object of class CodeIgniter\Email\Email could not be converted to string

APPPATH/Controllers\AuthController.php at line 212

205               ->setSubject(lang('Auth.forgotSubject'))
206               ->setMessage(view($this->config->views['emailForgot'], ['hash' => $user->reset_hash]))
207               ->setMailType('html')
208               ->send();
209 
210         if (! $sent)
211         {
212             log_message('error', "Failed to send forgotten password email to: {$email}");
213             return redirect()->back()->withInput()->with('error', lang('Auth.unknownError'));
214         }
215 
216         return redirect()->route('reset-password')->with('message', lang('Auth.forgotEmailSent'));
217     }
218 
219     /**
  • Codeigniter version 4.0.0-rc.1
  • myth-auth version dev-develop

CPU 100%

Hi,

I try use this Auth package with cPanel and I noticed when I refresh 4-7 fast page CPU up to 100% in cPanel

And this happening when I try setup Auth Classes

Example:

public function __construct() {
        $this->setupAuthClasses();
}

And I am thinking in this place
session('logged_in')

Old version of Migration commands

@lonnieezell , I know you now focused to CI4 RC but please, change migration commands to newer version. People and me also want to test package out.
New Migration commands running without error but not creating table(s)

php spark migrate:latest -all

And as I understood we don't need do anything about set discoverLocal to true. Because it is enabled by default?

Application view files do not override packaged views.

When installing with spark several files are copied to App namespace and a conversion is made dealing with their namespaces.
However, when App view-files are loaded, several path error appear as namespace get converted to Auth\Views\etc... instead of \App\Views\Auth\etc...

<?= view('\App\Views\Auth\_header') ?>

This happens in all of the Auth View files, but _footer, _message_block and _navbar

Permission error

Hi,

I get permission error

I try do this

class Test extends Controller {

    use \Myth\Auth\AuthTrait;

    public function __construct() {


    }

    public function index() {

        $this->restrictWithPermissions('price', '/');

    }

}

And I get this error:
Argument 3 passed to Myth\Auth\Config\Services::authorization() must be an instance of CodeIgniter\Model or null, boolean given, called in /Applications/XAMPP/xamppfiles/htdocs/TrackTrace/web.track-trace/system/Config/BaseService.php on line 114

Permissions for user

Hi,
I try to add permissions to the user and I found an error because method addPermissionToUser working with User entity and add permission as a column of user table. Checking user permissions (method doesUserHavePermission) working with auth_users_permissions table so here we have some differences.

Even if I want to add permission to User entity then I get another error as below:

TypeError

Argument 1 passed to Myth\Auth\Entities\User::setPermissions() must be of the type array or null, string given

I pass an array of permission but here Entities/User.php:175
should be (or use Entity JSON casting)

$this->attributes['permissions'] = json_encode($permissions);

not

$this->permissions = json_encode($permissions);

becouse array converted into json is again converter to json but now it isn't array but string.

Request: Publish to Packagist

I believe this package is stable enough to merit a release (at least a pre-release) that could then be published to Packagist.org to support Composer installs.

Namespace: Auth missing

Don't know if I'm bothering you with these errors, but I'm trying to use it in a project with CI4 and whenever I find what I think is an error I try to report it to you.
If you don't like/want me doing this, please let me know and I'll stop.
Thanks for all your code & work!

use Myth\Authorization\GroupModel;

Missing id() func in AuthenticationBase

I added the missing id() function to AuthenticationBase.
I'll look into "pulling requests" shortly so I can propose changes there

  • /**
  • * Returns the User ID for the current logged in user.
    
  • *
    
  • * @return int|null
    
  • */
    
  • public function id()
  • {
  •    return $this->user->id;
    
  • }
  • /**

Publish views error

php spark auth:publish
Publish Views? [y, n]: y

An uncaught Exception was encountered

Type:        ErrorException
Message:     mkdir(): No such file or directory
Filename:    C:\xampp\htdocs\codeigniter4-admin\vendor\myth\auth\src\Commands\Publish.php
Line Number: 273

        Backtrace:
           -273 - C:\xampp\htdocs\codeigniter4-admin\vendor\myth\auth\src\Commands\Publish.php::mkdir
           -182 - C:\xampp\htdocs\codeigniter4-admin\vendor\myth\auth\src\Commands\Publish.php::writeFile
           -162 - C:\xampp\htdocs\codeigniter4-admin\vendor\myth\auth\src\Commands\Publish.php::publishView
            -97 - C:\xampp\htdocs\codeigniter4-admin\vendor\myth\auth\src\Commands\Publish.php::publishViews
           -136 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CLI\CommandRunner.php::run
           -109 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CLI\CommandRunner.php::runCommand
            -85 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CLI\CommandRunner.php::index
           -840 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CodeIgniter.php::_remap
           -335 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CodeIgniter.php::runController
           -245 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CodeIgniter.php::handleRequest
            -85 - C:\xampp\htdocs\codeigniter4-admin\vendor\codeigniter4\framework\system\CLI\Console.php::run
            -57 - C:\xampp\htdocs\codeigniter4-admin\spark::run
  • Codeigniter version 4.0.0-rc.1
  • Myth-auth version dev-develop

Core Version

Hello Guys !

I will take the weekend to try CI4 and the main thing I needed was a reliable auth library.

Thank god I found this... I am already a Lonnie´s HUGE fan ( just got my patron status ).

What I want to ask/propose is a CORE version of this auth library. A version with only the login, create user, check credentials, etc...

Is it possible ? What do you think about this idea ?

Thank you !

Filter parameters don't seem to be in CI4

Revisiting #30, the auth filters don't seem to be working. Tracking it down, it looks like $params is empty no matter what is passed. If I'm understanding system/Filters/Filters.php correctly, it looks like only the request object is passed in and no additional parameters:
https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Filters/Filters.php#L150

Is this something still coming down the pipe? or incorrectly missing? or am I misunderstanding?

route to reset-password being redirected to login

Now that we (sort of) have Email working again in CI4, I tried using the forgot password feature.
All works fine until I click on the email link sent to the user.
Login filter tests the current_url() to see if it's a login page, but doesn't take into account the reset-password url. Therefore, it keeps on redirecting to login. Once logged in, it obviously redirects to reset-password form so you can enter the sent token. No point in this as you might definitely don't know your password.
Easy enough, adding a third 'OR' to the if will make it work fine.

if ( (current_url() == site_url(route_to('login'))) || (current_url() == site_url(route_to('forgot')))
|| (current_url() == site_url(route_to('reset-password')))
) { return; }

Register Error

It’s a problem after the publish command

TypeError
Argument 1 passed to Myth\Auth\Authentication\Passwords\PasswordValidator::__construct() must be an instance of Myth\Auth\Config\Auth, instance of App\Config\Auth given, called in C:\xampp\htdocs\codeigniter4-admin\vendor\myth\auth\src\Config\Services.php on line 90
  • Codeigniter version 4.0.0-rc.1
  • myth-auth version dev-develop

discoverLocal

It looks like $routes->discoverLocal never made it into beta. I see it in codeigniter4/CodeIgniter4@9a1ffb5 but maybe plans were dropped to include it? Is this still a valid step for configuration, or is it superseded by namespaced route discovery?

Error with failed login

Hi,
I am trying to log a user via username + password and if these credentials are wrong I get a error as below:

ErrorException
Undefined index: email
vendor/myth/auth/src/Authentication/LocalAuthenticator.php at line 25
$this->recordLoginAttempt($credentials['email'], $ipAddress, $this->user->id ?? null, false);

I allow to credential via (Config/Auth.php)

    public $validFields = [
        'email', 'username'
    ];

attemptReset does not check for token existance before resetting passwd

Just adding a second 'where' condition will do:
$user = $users->where('email', $this->request->getPost('email'))->where('reset_hash', $this->request->getPost('token'))->first();

On the other hand, what's the logic you thought for "reset-time" field in DB?
I guess it'd mean that you could put a certain amount of minutes of token validity that could be checked just after the $user = $user->where()...->first() above. Am I right?

Filter parameters

Filters can take parameters?? Anywhere this is documented? I dug through the CI4 Router code but there’s a lot of different pieces there...

Reset* vars in user don't get nullified when password is changed

Set these vars to null in case a reset password was asked.
Scenario:
user (one with short memory) requests a
reset-token and then does nothing => asks the
administrator to reset his password.
User would have a new password but still anyone with the
reset-token would be able to change the password.

Fresh install - Invalid File

Using current CodeIgniter version:
https://github.com/codeigniter4/CodeIgniter4

cloned myth-auth to app/ThirdParty/auth

added to Autoload.php $psr4:

'Myth\\Auth' => APPPATH . 'ThirdParty\\auth\\src', // Auth system

added to Validations.php

\Myth\Auth\Authentication\Passwords\ValidationRules::class,

and migrated

php spark migrate:latest -all

when i try
localhost:8080/login

result:
image

i not checked if is a issue with this system or with CI4

a workaround that worked to me:
CI4\system\Autoloader\FileLocator.php

commented line 135:
//$filename = $folder . '/' . $filename;

result:
image

Exception when logging in with non-existant username

Authentication fails with an exception when a user that doesn't exist tries to log in with a username instead of email.
This is because when it tries to log the failed attempt, it forcefully uses $credentials['email'] only

redirect not working in AuthTrait

Redirect is doing nothing here. No companies either.
Don't know exactly why, but changing redirect to header works fine.
I know it's not a solution, but it helps to continue with the rest in the meantime.

         if (empty($uri))
         {
+            header("Location: ".route_to('login'));
+            die();
             redirect( route_to('login') );
         }

However, header will not take into account the redirect_uri passed as a GET parameter

LoginFilter messes with get's token parameter (reset-password)

Scenario:

  • Login filter is applied globally (in App\Config\Filters)
  • LoginFilter's before($request) method avoids checking for logged in user when route is login, forgot or reset-password
  • App is set to send emails with the token code when a user want's to reset his password

So far, everything works as expected. But, when I click on the reset form link (http://whatever.com/reset-password?token=e6290a3d8d156339963092e08228f039) I keep being redirected to login form.
Routes work as expected too. If, for instance, I write the URL like http://whatever.com/reset-password I get the reset-password form OK.
If I write the URL like http://whatever.com/reset-password? works fine too.
And so on...
...until I write http://whatever.com/reset-password?token=
Then, it redirects to login form. Whatever I write after the = sign makes no difference

Now, if I log-in, I am redirected to the reset-password form and the token input field gets populated just fine.

Tried d($request) first thing inside the before() method of LoginFilter and URL is fine.
But when I d($request) after the current_url() check and before the return, d($request) shows /login as the URL

Also, if I get rid of the global login filter, everything works as expected.

Any ideas?

Social login

Lonnie,
You may want to consider using https://github.com/socialite-manager/socialite instead of hybridauth. It's based off the Laravel component of the same name, and seems to be pretty robust.
Btw, just curious, how does myth-auth compare against php-auth or others?

Core Providers
twitter
github
google
facebook
bitbucket
linkedin

Other Providers
Instagram
Line
VKontakte
Weixin
QQ
Weibo
Twitch
Slack
Discord
Dropbox
Yahoo
Spotify
GitLab
Yandex
Add more...

Config autoload causing Composer failures

composer.json includes the library path as well as mapping '\Config' to this library's support\Config (https://github.com/lonnieezell/myth-auth/blob/develop/composer.json#L31), which overwrites the namespace for app/Config causing issues with older versions of the config files, for example:
Undefined property: Config\Toolbar::$maxQueries

Is the intent for this library to be added via Composer to existing CodeIgniter projects? And if so, what purpose is autoloading support/Config service?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.