Slim framework admin credential


#1

Hi !

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

Thank You :slight_smile:


#2

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.


#3

Thank You for ur feedback :slight_smile:


#4

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?


#5

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.


#6

Hi

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.


#7

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.


#8

Thanks Sir for your help