slim-jwt-auth | PSR-7 and PSR-15 JWT Authentication Middleware | Authentication library
kandi X-RAY | slim-jwt-auth Summary
kandi X-RAY | slim-jwt-auth Summary
PSR-7 and PSR-15 JWT Authentication Middleware
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handle middleware .
- Fetch token from request .
- Hydrate options .
- Decode JWT token .
- Return a new instance with the rules added .
- Determine if the request should authenticate .
- Process error .
- Set the secret .
- Set the after callback .
- Set the error callback .
slim-jwt-auth Key Features
slim-jwt-auth Examples and Code Snippets
Community Discussions
Trending Discussions on slim-jwt-auth
QUESTION
Can you help me? I'm facing a strange issue. First, I'm downloading this https://github.com/tuupola/slim-jwt-auth using composer:
...ANSWER
Answered 2019-Jun-13 at 08:23First of all, you need to actually add the Slim framework to your Composer package. You can do this by running:
QUESTION
I've created a Rest API based on the PHP Slim framework which uses JSON Web Tokens (JWT) to authenticate and authorize access.
To use the API the client must first authenticate themselves by sending their credentials to a special /auth/token
route which if correct, returns a digitally signed token containing a list of allowed permissions. All subsequent requests to the API require the token for authentication and authorization. This is pretty standard stuff and works well.
But now I now want to separate the /auth/token
service into its own micro-service so I can reuse it with other APIs in the future.
The problem is, how will the APIs now authenticate the JWT as they don't have access to the secret that was used to generate it?
I use the Firebase\JWT\JWT
to generate the token, which will be moved to the new auth service. And I use tuupola/slim-jwt-auth
middleware to authenticate the received token on each API.
As each API and the new auth service will be running on the same host I could maybe share the secret between them all but this feels like bad practice. Is there a better way?
...ANSWER
Answered 2019-Mar-29 at 08:33It is better to sign JWT using private/public key (RSA or ECDSA algorithm) instead of a secret (HMAC algorithm). In that case your auth service would sign JWT with private key and other APIs would validate JWT with public key, well... you still need to distribute a public key to your APIs then, but you have options.
Depends on your architecture, you might look at:
API Gateway pattern
For microservice architecture a good practice is to use API Gateway pattern. More about gateway pattern. API Gateway can validate JWT token and then proxy requests to your services. So auth service would sign JWT token with private key, then requests to APIs would go though API Gateway. API Gateway would validate token with public key, so you would not distribute public key to all APIs behind the proxy.
With this approach your would need an API Gateway, you can look at: express-gateway, kong + jwt plugin, tyk etc, also there is much more benefits from API Gateway rather then just JWT token validation, like traffic control, analytics, logging, requests and responses transformations and so on.
Secrets management
Instead of or additionally to API Gateway you can take a look at centralised secrets management systems, like Hashi Vault. Depends on the project/team size it could be an overkill for your project.
QUESTION
I'm trying to add jwt-auth
to my Symfony project.
trying to execute the below command
...ANSWER
Answered 2019-Jan-28 at 09:11Doing:
QUESTION
I followed the instructions to save token in container with callback function (https://github.com/tuupola/slim-jwt-auth):
...ANSWER
Answered 2017-Feb-07 at 18:14The instruction you linked to states:
Callback is called only when authentication succeeds. It receives decoded token in arguments. If callback returns boolean
false
authentication is forced to be failed.
Do you meet this requirement when testing, i.e do you authenticate successfully? Also consider using var_dump($decode)
instead of print_r($decode)
when testing.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install slim-jwt-auth
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page