从Apollo Studio Explorer到Apollo Express Server的身份验证的API请求,该请求受第三方Auth Service(KeyCloak)保护
我正在使用KeyCloak来验证我的Apollo Server Express API。在Apollo Studio标题中包括携带者令牌不足以对工作室进行身份验证,因为当我登录到前端应用程序时,该请求需要包含浏览器中设置的KeyCloak提供的某些cookie。
前端将此cookie与携带者令牌一起发送到服务器。虽然我可以选择在阿波罗工作室手动定义身份验证令牌,但我不知道将cookie附加到请求的方法。
有趣的是,当我使用Postman查询我的API时,Postman实际上会在浏览器中提取cookie,该cookie已通过登录前端设置并将其包括在与cookie相对应的URL中的任何邮递员请求中,所以我如果我已经登录了我的前端,可以与Postman提出身份验证的请求。不幸的是,阿波罗工作室没有这样做。
如何从Apollo Studio的Cookie提供身份验证?这有点棘手,因为Apollo Studio不是由我的后端应用程序托管的。我可以在来自阿波罗工作室的请求中插入cookie吗?这会是什么样?
我也听说过关于创建代理的谈论,但我真的不理解此选项,这是一个可行的解决方案,它将如何工作?
I am using keycloak to authenticate my Apollo server express API. Including the bearer token in the Apollo studio header is not enough to authenticate the studio as the request needs to contain certain cookies provided by keycloak that are set in the browser when I log into the front end app.
The front end sends this cookie along with the bearer token to the server. While I have the option to manually define an authentication token in Apollo studio, I don’t know of a way to attach the cookie to the request.
Interestingly enough, when I use postman to query my API, postman will actually extract the cookie in the browser that has already been set by logging into the front end and include it in any postman requests to the URL that corresponds to the cookie, so I can make authenticated requests with postman if I have already logged into my front end. Unfortunately Apollo studio does not do this.
How can I provide Authentication with the cookie from my Apollo studio? It’s a bit tricky since Apollo studio is not hosted by my backend application. Can I have express middleware to insert the cookie in requests coming from Apollo studio? What would this look like?
I’ve also heard talk about creating a proxy but I don’t really understand this option, is this a viable solution and how would it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论