Keycloak password policy in PHP

So, I have integrated keycloak API endpoints in my Symfony project..

Regarding https://ultimatesecurity.pro/post/password-policy/ we have added ‘not username’ policy to test on creating new user within the app.

Idea is to delcare specific method with defined endpoint which will do this.

I was checking the documentation and could not find any endpoint that can check for password policy rules –> documentation

Idea for it:

public function checkPassword(string $firstName, string $lastName, string $email, string $password)
{
    $options = [
        'headers' => $this->getAuthJsonHeaders(),
        'body' => json_encode([
            'firstName' => $firstName,
            'lastName' => $lastName,
            'username' => $email,
            'email' => $email,
            'password' => $password
        ])
    ];

    $endpoint = sprintf('/auth/admin/here-would-go-password-policy-endpoint');

    try {
        $this->request('GET', $endpoint, $options);
    } catch (Exception $e) {
        $this->exception('Can`t create user on Keycloak. ' . $e->getMessage());
    }

    return $this->validatePass($pasword);
}

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *