oauth-2.0 - (如何)我可以使用 Gitlab.com 对我的 Angular 应用程序进行身份验证吗?
问题描述
我想看看如何通过 Gitlab.com 进行身份验证的用户可以通过我们的 Angular 网站进行身份验证。
我已经看到了一些使用https://gitlab.com/oauth/applications/
的建议
我们使用 gitlab.com 作为我们的 CI/CD 但这似乎并不特别值得注意。我发现的许多示例都是用于在 Enterprise Edition 中注册应用程序。
我尝试使用以下内容查询 gitlab.com:
<a href="https://gitlab.com/authorize?response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Foauth-redirect&client_id=<provided by gitlab.com>&state=<Not sure where this is explained>">Connect Your Account</a>
似乎参数的顺序比我想象的更重要。一个有效的查询是:
https://gitlab.com/oauth/authorize?client_id=<from gitlab>&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Fredirect&response_type=code&state=bob&scope=profile
其中,&redirect_uri=
是提供给 gitlab.com 的 URL,
并且state
是一些唯一值,例如state=bob
,state=hashlib.sha256(os.urandom(1024)).hexdigest()
Gitlab.com 然后回应:
http://localhost:4200/oauth-redirect
创建了一个 Angular 服务,即ng g s oauth-redirect
返回值然后使用 Angular 回调魔法进行解析,例如这里描述的
目前的症结所在:
如何正确解析并重定向到正确的网页?
解决方案
推荐阅读
- python - Get closest dictionary of data with Python
- javascript - Why can't I use Jinja in Javascript for a django site?
- smartystreets - 如何从 SmartyStreet API 获取国家、州、县和城市?
- c++ - 将数组写入位图c ++
- c# - 无法在 MVC 客户端中使用 JWT 进行身份验证
- dart - Flutter 菜单和导航
- function - 带有 security() 的 Tradingview 自定义函数
- c++ - OpenGL:读取颜色缓冲区
- php - How to get last inserted non incremental id using eloquent in Laravel?
- angular - 在 Angular 中使用自定义 http 请求时,如何禁用 'sent' event.type?