How to Create a Simple Symfony Application with Authentication

How to Create a Simple Symfony Application with Authentication

In this tutorial, you’ll learn how to create a simple Symfony application and add user authentication with Okta.

cs_ib

Thanks for the great article. I’ve used the information above in an existing Symfony app I’ve developed. I am getting a 401 “Full authentication is required to access this resource.”. When opening the /login url, I can see the browser redirecting to my Okta domain and back. It appears to come back to the callback function and redirects to a page that is secured (with Access Control - ROLE_USER). The page still appears with the 401 exception message as above. Is the example missing a Guard Authenticator? From my experience, its required for the authentication workflow.

I’d be interested to hear others’ experience with the solution above, but if you can advise, I’d be grateful.

Marcus

$user->setToken($accessToken);

This is returning “Notice: Undefined variable: accessToken”

Andrew Callan

Change $user->setToken($accessToken); to $user->setToken($token);

$ Argument #1 ($token) must be of type string, stdClass given, called in /var/www/html/src/Controller/Security/LoginController.php

I did notice the service set token_id un the session before getting here; attempting to use that instead …