E
E
Evgeny Akhmetov2015-09-23 15:13:32
Yii
Evgeny Akhmetov, 2015-09-23 15:13:32

Are there any good examples of JWT implementation for Yii?

The application is written in Yii + AngularJs, now there is a need for a mobile application, everything except authorization uses Rest, now we need to transfer it to work through tokens (JWT).
Maybe someone has seen good implementation examples for this bundle, or at least in parts, Google gives a lot of information, but I didn’t see really good (in my opinion) solutions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2015-09-23
@matperez

As an implementation for PHP, you should take firebase / php-jwt. I can't tell you for Angular, but you can probably use the jsrsasign package from bower.
I don't know how exactly you implemented REST. In standard Yii2, everything is easy to do. You will need to override the \yii\web\User::loginByAccessToken method in the user model and then you can use the standard \yii\filters\auth\HttpBearerAuth or \yii\filters\auth\QueryParamAuth for authorization in the REST API. The first requires a token in the header, the second as a parameter in the GET request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question