chalasr / lexik-jwt-authentication-sandbox
LexikJWTAuthenticationBundle Symfony 扩展包的沙盒
v1.0.0
2016-11-01 10:36 UTC
Requires
- php: >=5.5.9
- doctrine/doctrine-bundle: ^1.6
- doctrine/doctrine-cache-bundle: ^1.2
- doctrine/orm: ^2.5
- incenteev/composer-parameter-handler: ^2.0
- lcobucci/jwt: ~3.2
- lexik/jwt-authentication-bundle: ~2.0
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- symfony/monolog-bundle: ^2.8
- symfony/polyfill-apcu: ^1.0
- symfony/swiftmailer-bundle: ^2.3
- symfony/symfony: 3.1.*
Requires (Dev)
- sensio/generator-bundle: ^3.0
- symfony/phpunit-bridge: ^3.0
This package is auto-updated.
Last update: 2024-09-22 17:47:18 UTC
README
这是一个用于实验/演示 LexikJWTAuthenticationBundle 扩展包强大功能的示例应用程序,该扩展包通过 JWT 提供身份验证。
包含内容
- Symfony 4.0 (Flex)
- LexikJWTAuthenticationBundle ~2.4
开始使用
克隆项目
$ 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
用法
运行 web 服务器
$ php bin/console server:run
注册新用户
$ curl -X POST http://localhost:8000/register -d _username=johndoe -d _password=test
-> User johndoe successfully created
获取 JWT 令牌
$ curl -X POST -H "Content-Type: application/json" http://localhost:8000/login_check -d '{"username":"johndoe","password":"test"}'
-> { "token": "[TOKEN]" }
访问受保护的路由
$ curl -H "Authorization: Bearer [TOKEN]" http://localhost:8000/api
-> Logged in as johndoe