gpt4 book ai didi

Laravel 护照 : Authenticate api requests based on access token issued by another microservice

转载 作者:行者123 更新时间:2023-12-01 04:27:17 25 4
gpt4 key购买 nike

我有 3 项服务。 app.mydomain.com、accounts.mydomain.com 和 api.mydomain.com。 accounts.mydomain.com 使用护照进行身份验证并颁发访问 token 。我的问题是如何使用帐户服务颁发的访问 token 来允许访问 api 服务的资源。

最佳答案

你有两种方法:

1) 在 account.mydomain.com 上创建自省(introspection)端点api.mydomain.com 调用的服务器检查访问 token 。

通过 token 自省(introspection)端点,资源服务器 (api.mydomain.com) 可以检查访问 token 的有效性,并找出其他信息,例如与 token 关联的用户和范围。

有关 token 自省(introspection)的更多信息,请参阅 https://oauth.net/2/token-introspection/

这是更好但更难的解决方案,因为您需要在 api.mydomain.com 中编写中间件或保护验证器从 account.mydomain.com 调用自省(introspection)端点的服务

2) 分享oauth-private.keyoauth-public.key在你所有的项目中。

这是更简单的方法,因为您唯一需要做的就是从 storage 复制和粘贴这两个文件。目录

关于Laravel 护照 : Authenticate api requests based on access token issued by another microservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57465519/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com