当前位置:网站首页>Laravel configures passport and returns token using JWT
Laravel configures passport and returns token using JWT
2022-06-30 14:11:00 【Ebony feed feed Wayne yetun wyuwenmu Bian OSAS】
First installation passport plug-in unit
composer require laravel/passport
Then execute the migration file , Generate data table , preservation token data
php artisan migrate
After performing Generate client authorization code
php artisan passport:install
The client authorization code will be obtained after use Keep in mind !(secret)
Then modify the interface account model
use Laravel\Passport\HasApiTokens

modify config/auth.php In the document api To configure

stay app/Proivders/AuthServiceProvide.php In the document boot Method add validity period
use Laravel\Passport\Passport;
//token The certification is valid for two hours
Passport::tokensExpireIn(now()‐>addHour(2));
// Refresh Token The period of validity of the certification is 30 God
Passport::refreshTokensExpireIn(now()‐>addDays(30));

After that, generate in the controller token

Use apipost/postman To test
Interface security verification
Used jwt To verify
You need to bind middleware to interface routing , Premise is auth.php Be sure to put... In the document api Nodes in the driver Replace with passport

Bind in the defined route jwt Authentication middleware

Use postman test

notes : sometimes , Not only use jwt To secure authentication , Sometimes you need to encrypt the content , In general use rsa encryption
边栏推荐
- 幸运哈希竞猜系统开发(源码部署)趣投哈希游戏玩法开发(案例需求)
- mysql拒绝访问、管理员身份打开的
- Numpy creates an empty array data = np empty(shape=[1, 64,64,3])
- What network security problems are exposed when a large-scale QQ number theft event occurs?
- Geoffreyhinton: my 50 years of in-depth study and Research on mental skills
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
- 【刷题篇】避免洪水泛滥
- I'd like to ask you, where can I open an account in Foshan? Is it safe to open a mobile account?
- MySQL access denied, opened as Administrator
- Meaning of while (~scanf ("%d%d", & A, & B))
猜你喜欢

The programming competition is coming! B station surrounding, senior members and other good gifts to you!

MySQL back to table query optimization

About the problems encountered when using the timer class to stop with a button (why does the QPushButton (for the first time) need to be clicked twice to respond?)

Apache Doris comparison optimization Encyclopedia

"As a service", the inevitable choice of enterprise digital transformation

香港回归20余年,图扑数字孪生港珠澳大桥,超震撼

单元测试效率优化:为什么要对程序进行测试?测试有什么好处?

Shell programming overview

This article explains the concepts of typed array, arraybuffer, typedarray, DataView, etc

mysql拒绝访问、管理员身份打开的
随机推荐
[the path of system analyst] Chapter V software engineering (software process improvement)
Step by step | help you easily submit Google play data security form
Go language for loop multivariable use
Deep understanding Net (2) kernel mode 3 Kernel mode construct mutex
More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked
Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs
Why can't the database table be written into data
Deep understanding Net (2) kernel mode 2 Kernel mode construct semaphone
exlipse同时操作多行。比如同时在多行同列输入相同的文字
@ResponseBody的作用
Unity Animator 参数
Embedded development: five C features that may no longer be prohibited
Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!
Dart 扩展特性
Mysql database foundation: stored procedures and functions
智慧运维:基于 BIM 技术的可视化管理系统
Details of gets, fgetc, fgets, Getc, getchar, putc, fputc, putchar, puts, fputs functions
remote: Support for password authentication was removed on August 13, 2021. Please use a personal ac
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
优思学院:六西格玛不只是统计!