rch/lexik-jwt-authentication-sandbox

此包已被放弃,不再维护。作者建议使用 chalasr/lexik-jwt-authentication-sandbox 包。

LexikJWTAuthenticationBundle Symfony 扩展的沙箱

v1.0.0 2016-11-01 10:36 UTC

README

这是一个LexikJWTAuthenticationBundle扩展(通过JWT进行身份验证的强大扩展)的实验/演示应用的示例。

包含内容

开始使用

克隆项目

$ git clone https://github.com/chalasr/lexik-jwt-authentication-sandbox
$ cd lexik-jwt-authentication-sandbox
$ git checkout flex

创建数据库模式

$ php bin/console doctrine:database:create
$ php bin/console doctrine:schema:update --force

用法

运行网络服务器

$ php bin/console server:run

注册新用户

$ curl -X POST https://:8000/register -d _username=johndoe -d _password=test
-> User johndoe successfully created

获取JWT令牌

$ curl -X POST -H "Content-Type: application/json" https://:8000/login_check -d '{"username":"johndoe","password":"test"}'
-> { "token": "[TOKEN]" }  

访问受保护的路由

$ curl -H "Authorization: Bearer [TOKEN]" https://:8000/api
-> Logged in as johndoe