Slim framework admin credential

Hi !

May i know how to add an admin credential to slim framework web application or edit a previous one

Thank You :slight_smile:

Hi @Yazee,

Slim does not come with any authentication package, however there are many you can implement. The package you implement will depend on your needs. If something basic from the browser you might try tuupola/slim-basic-auth. I use auraphp/Aura.Auth for a few of my projects. From an API you might want to look at something like thephpleague/oauth2-server.

1 Like

Thank You for ur feedback :slight_smile:

Hi, Could you please let me know how did you integrated Aura.Auth in SLIM auth. Any some example or some steps to integrate the same?

In my container I define how the Auth::class, AuthFactory::class, and AdapterInterface::class should be setup, as per the Instantiation section of the docs.

I created an AuthController to handle login login and logout routes which takes the AdapterInterface and checks the credentials against the LoginService, logs the user out, etc. See the services part of the docs.

Then I created a AuthenticationMiddleware applied to protected routes that checks the isValid() method of the Auth object and returns a 403 if it isnโ€™t valid.


Thanks a lot for your prompt reply with examples

Could you pls let me know how to did you handle authorization part as well?

I am very new to SLIM but still i am passionate to learn this middleware part completely.

It would be nice if you are able to share some glimpse of code in slim container part and controller related on the same.

Iโ€™m not using Aura.Auth for authorization, instead Iโ€™m using zend-permissions-acl or rolling my own. Iโ€™ll see if I can find some code samples.

Thanks Sir for your help