plugin-oauth2 icon indicating copy to clipboard operation
plugin-oauth2 copied to clipboard

请问是否可以开发支持通用的OAuth? 近期是否有计划?谢谢!

Open DarkWayne opened this issue 2 years ago • 22 comments

请问是否可以开发支持通用的OAuth(接入三方OAuth认证体系)? 近期是否有计划?望答复,谢谢!~~

DarkWayne avatar Apr 25 '23 06:04 DarkWayne

本身是支持通过配置来适配其他的 OAuth 提供方的,你可以详细描述一下你期望的使用方式。

ruibaby avatar Apr 25 '23 10:04 ruibaby

@ruibaby 老大好! ~ 我的场景是,我自身有一套内部的IDaaS身份认证系统,想通过OAuth来进行内部用户的登录认证。 但是看咱们目前标准的OAuth插件,只是支持gitLab、gitee等外部系统对接; 看这个后续是有可以有支持内部认证系统的标准插件吗? 或者有什么临时的折中解决方案,多谢老大给予指导 [拱手][拱手]

DarkWayne avatar Apr 27 '23 01:04 DarkWayne

Hi @DarkWayne ,你可以试试根据下面的 AuthProvider 样例自己配置一个符合你的认证系统的 AuthProvider:

apiVersion: auth.halo.run/v1alpha1
kind: AuthProvider
metadata:
+ name: gitlab
  labels:
    auth.halo.run/auth-binding: "true"
spec:
+ displayName: GitLab
+ description: GitLab Inc. is an open-core company that operates GitLab, a DevOps software package which can develop, secure, and operate software.
+ logo: /plugins/plugin-oauth2/assets/static/gitlab.svg
+ website: https://gitlab.com
+ authenticationUrl: /oauth2/authorization/gitlab
+ bindingUrl: /apis/api.plugin.halo.run/v1alpha1/plugins/plugin-oauth2/connect/gitlab
+ unbindUrl: /apis/api.plugin.halo.run/v1alpha1/plugins/plugin-oauth2/disconnect/gitlab
  settingRef:
    name: generic-oauth2-setting
    group: genericOauth
  configMapRef:
+   name: oauth2-gitlab-config

然后通过 API 创建对应的 AuthProvider,示例如下(需要自行替换 URL、用户名和密码、请求体):

curl -X 'POST' \
  'http://localhost:8090/apis/auth.halo.run/v1alpha1/authproviders' \
  -u admin:admin \
  -H 'accept: */*' \
  -H 'Content-Type: */*' \
  -d '{
  "apiVersion": "auth.halo.run/v1alpha1",
  "kind": "AuthProvider",
  "metadata": {
    "name": "gitlab",
    "labels": {
      "auth.halo.run/auth-binding": "true"
    }
  },
  "spec": {
    "displayName": "GitLab",
    "description": "GitLab Inc. is an open-core company that operates GitLab, a DevOps software package which can develop, secure, and operate software.",
    "logo": "/plugins/plugin-oauth2/assets/static/gitlab.svg",
    "website": "https://gitlab.com",
    "authenticationUrl": "/oauth2/authorization/gitlab",
    "bindingUrl": "/apis/api.plugin.halo.run/v1alpha1/plugins/plugin-oauth2/connect/gitlab",
    "unbindUrl": "/apis/api.plugin.halo.run/v1alpha1/plugins/plugin-oauth2/disconnect/gitlab",
    "settingRef": {
      "name": "generic-oauth2-setting",
      "group": "genericOauth"
    },
    "configMapRef": {
      "name": "oauth2-gitlab-config"
    }
  }
}'

JohnNiang avatar Apr 27 '23 02:04 JohnNiang

@JohnNiang 感谢啊! 有个细节问一下:在创建自定义配置的情况下, redirect_uri 是多少? authenticationUrl / bindingUrl / unbindUrl 的 path 最后的 "gitlab" 是不是来自于 metadata.name ? 请给下指导 [拱手]

DarkWayne avatar Apr 27 '23 03:04 DarkWayne

https://github.com/halo-sigs/plugin-oauth2/issues/23#issuecomment-1524493085

Hi @DarkWayne ,还需要创建一个 Oauth2ClientRegistration 才行,示例如下:

apiVersion: oauth.halo.run/v1alpha1
kind: Oauth2ClientRegistration
metadata:
  name: gitlab
spec:
  clientAuthenticationMethod: "client_secret_basic"
  authorizationGrantType: "authorization_code"
  redirectUri: "{baseUrl}/login/oauth2/code/gitlab"
  scopes:
    - "read_user"
  authorizationUri: "https://gitlab.com/oauth/authorize"
  tokenUri: "https://gitlab.com/oauth/token"
  userInfoUri: "https://gitlab.com/api/v4/user"
  userInfoAuthenticationMethod: "header"
  userNameAttributeName: "username"
  clientName: "GitLab"

JohnNiang avatar Apr 27 '23 03:04 JohnNiang

@JohnNiang @ruibaby 大神好!我已经做了一下尝试,目前本地的认证服务已通过配置接入了,已经可获取内部用户凭证和信息。 但是仍有个问题,就是无法向halo里自动同步注册用户,看咱们的插件是否有什么解决方案或计划

DarkWayne avatar May 05 '23 01:05 DarkWayne

@JohnNiang @ruibaby 大神好!我已经做了一下尝试,目前本地的认证服务已通过配置接入了,已经可获取内部用户凭证和信息。 但是仍有个问题,就是无法向halo里自动同步注册用户,看咱们的插件是否有什么解决方案或计划

@JohnNiang @ruibaby 两位有空帮回复一下[拱手]

DarkWayne avatar May 06 '23 06:05 DarkWayne

/cc @guqing

JohnNiang avatar May 08 '23 04:05 JohnNiang

你想实现使用 IDaas 已有账户就能登录到 Halo,可能需要一个类似自动注册的功能,比如登录时没有账号就自动注册 Halo 账号关联它,但是目前不支持自动注册只支持先创建 Halo 账号然后绑定第三方账号实现登录或者登录时没有账号需要注册再绑定。

自动注册的功能有计划支持,会提供一个选项比如开启自动注册后使用 OAuth2 登录时自动创建 Halo 账号

guqing avatar May 08 '23 04:05 guqing

@guqing 感谢感谢!看后续计划的大时间概会很久么?

DarkWayne avatar May 10 '23 06:05 DarkWayne

@guqing 感谢感谢!看后续计划的大时间概会很久么?

不确定,因为目前要维护的仓库实在太多了,主要还是先紧 halo-dev/halo 主仓库的维护

guqing avatar May 10 '23 07:05 guqing

/reopen issue 关联错误导致关闭,我将重新打开

guqing avatar Jul 03 '23 07:07 guqing

@guqing: Reopened this issue.

In response to this:

/reopen issue 关联错误导致关闭,我将重新打开

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

f2c-ci-robot[bot] avatar Jul 03 '23 07:07 f2c-ci-robot[bot]

同样需要自定义OAuth和OICD

LGY07 avatar Feb 15 '24 05:02 LGY07

同样需要自定义OAuth和OICD

chenjuefei avatar Apr 01 '24 03:04 chenjuefei

同样需要自定义OAuth和OICD

hhhguany avatar Apr 28 '24 09:04 hhhguany