Skip to content

Bug: ValidationRules strong_password is not working when called using tokens in before filters API routes. #438

@arif-rh

Description

@arif-rh

PHP Version

8.1.0

CodeIgniter4 Version

4.2.6

Shield Version

dev-develop

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

MySQL 8.0.27

Did you customize Shield?

No

What happened?

I develop API for registration. To secure an API, I implement tokens on before-filters. When calling registration API, I sent my developer tokens in the Authorization header.

But when I post password contains personal information, it can be passed. strong_password valdiation is not working.

Steps to Reproduce

  1. make simple API for registration
  2. implements tokens on before-filter to secure the API routes
  3. Set the token in the Authorization header
  4. post any password contains personal information

Expected Output

Api should return error that "Passwords cannot contain re-hashed personal information."

Anything else?

I am new in this library, so this report could be false, maybe I do wrong setup or implementation of this library. But for now, I am thinking, the cause could be this line:

    if (function_exists('auth') && auth()->user()) {  
            $user = auth()->user();
    }

when I change those line to:

    if (function_exists('auth') && auth('session')->user()) {  
            $user = auth('session')->user();
    }

then strong_password validation is working as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions