简体   繁体   English

Laravel Passport:重写客户端中间件以检查来自授权的自定义标头名称的访问令牌

[英]Laravel Passport: rewrite client middleware for check access token from custom header name insted of Authorization

Laravel Passport Client Credentials Grant Tokens can be protected with their middleware Laravel Passport Client Credentials Grant Tokens可以用它们的中间件来保护

Client middleware客户端中间件

\\Laravel\\Passport\\Http\\Middleware\\CheckClientCredentials;

This middleware will check user credential from Authorization header field.该中间件将从Authorization标头字段中检查用户凭据。 How I can change it and for checking from custom header name?我如何更改它并从自定义标题名称进行检查? For example: clientAuthorization ?例如: clientAuthorization ?

Create a custom middleware, extend it from \\Laravel\\Passport\\Http\\Middleware\\CheckClientCredentials middleware in your Laravel application and re-write the method to use your custom header ( clientAuthorization ).创建一个自定义中间件,从 Laravel 应用程序中的\\Laravel\\Passport\\Http\\Middleware\\CheckClientCredentials中间件扩展它,并重新编写方法以使用您的自定义标头( clientAuthorization )。

Then use the custom middleware in your application.然后在您的应用程序中使用自定义中间件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM