跳转到主要内容

基于Guillotina的hydra身份提供者

项目描述

此插件旨在通过Guillotina为hydra提供身份提供者。

它还实现了hydra的登录和同意流程。

端点

配置

配置取决于您的登录前端实现。使用可以渲染HTML并将其作为认证端点的应用程序可以使流程更加简单。

请参阅仓库中的angular应用程序示例和集成测试流程,以了解它是如何工作的。

测试需要一个运行以下配置的hydra实例

  • OAUTH2_ISSUER_URL=http://localhost:4444

  • OAUTH2_CONSENT_URL=http://localhost:8080/@hydra-consent

  • OAUTH2_LOGIN_URL=http://localhost:8080/@hydra-login

  • DATABASE_URL=postgres://hydra:secret@postgresd:5432/hydra?sslmode=disable

  • SYSTEM_SECRET=youReallyNeedToChangeThis

  • OAUTH2_SHARE_ERROR_DEBUG=1

  • OIDC_SUBJECT_TYPES_SUPPORTED=public,pairwise

  • OIDC_SUBJECT_TYPE_PAIRWISE_SALT=你真的需要更改这个

然后你需要配置 guillotina

auth_providers:
  hydra:
    configuration:
      client_id: auth-code-client
      client_secret: secret
      base_url: http://localhost:4444/
      authorize_url: http://localhost:4444/oauth2/auth
      access_token_url: http://localhost:4444/oauth2/token
    state: true
    scope: openid offline
hydra:
  db:
    dsn: postgres://hydra:secret@localhost:5432/hydra
    pool_size: 20
  # hydra admin url should be internal, protected!
  admin_url: http://localhost:4445/
  allow_registration: false
recaptcha_private_key: null
recaptcha_public_key: null

将 oauth 客户端添加到 hydra

curl -XPUT http://localhost:4445/clients/auth-code-client -d '{
    "client_id": "auth-code-client",
    "client_name": "",
    "redirect_uris": [
        "http://localhost:8080/@callback/hydra"
    ],
    "grant_types": [
        "authorization_code",
        "refresh_token"
    ],
    "response_types": [
        "code",
        "id_token"
    ],
    "scope": "openid offline",
    "owner": "",
    "policy_uri": "",
    "allowed_cors_origins": [],
    "tos_uri": "",
    "client_uri": "",
    "logo_uri": "",
    "contacts": [],
    "client_secret_expires_at": 0,
    "subject_type": "public",
    "jwks": {
        "keys": null
    },
    "token_endpoint_auth_method": "client_secret_post",
    "userinfo_signed_response_alg": "none"
}'

有关使用流程的示例,请参阅 https://github.com/guillotinaweb/guillotina_hydraidp/blob/master/integration_tests.py

这仅仅是 API 实现。你仍然需要实现前端!

作用域格式

使用作用域来授予对 guillotina 容器的访问权限。

作用域的格式为:[容器 ID]:[类型]:[值]

例如,为了授予用户访问容器 cms 作为用户的权限,作用域应该是 cms:role:guillotina.Member

其他示例:- cms:role:guillotina.Reader - cms:permission:guillotina.AccessContent

开发前端

启动持久层

docker-compose up redis postgres hydra-migrate hydra hydra-proxy

启动 idp

virtualenv .
source bin/activate
g -c config-pg.yaml

启动 ngapp

cd loginapp
ng serve

打开浏览器

http://localhost:4200

1.0.3 (2018-10-27)

  • 添加事件 [bloodbare]

1.0.2 (2018-10-25)

  • 加入 RSA 公钥 [bloodbare]

1.0.1 (2018-10-22)

  • 能够作为一个常规登录端点工作 [vangheem]

  • 提供 angular 登录应用 [bloodbare]

1.0.0 (2018-10-09)

  • 初始

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

guillotina_hydraidp-1.0.3.tar.gz (15.0 kB 查看散列)

上传时间

由以下支持