【问题标题】:authentication for custom web application with mod_auth_openidc使用 mod_auth_openidc 对自定义 Web 应用程序进行身份验证
【发布时间】:2016-08-08 02:58:03
【问题描述】:

我有一个在 apache 2.2 上运行且没有任何身份验证的基本 Web 应用程序。网站内容为静态网页。
我们的小型组织目前正致力于为所有网站实施 mod_auth_openidc
我想在基本的静态 Web 应用程序之上实现 mod_auth_openidc 身份验证。

我怎样才能实现它?
我是 apache 配置和 mod_auth_openidc 的新手。我用谷歌搜索了一些文章来实现它,但我找不到任何文章。我在 Oauth2 服务器上为我的应用程序创建了一个静态帐户。

有人可以为我指出如何使用 mod_auth_openidcmod_proxy 配置为我的静态网页应用程序启用身份验证的正确方向吗?

<Location />
   AuthType openid-connect
   Require valid-user
</Location>
OIDCProviderMetadataURL https://example.com/fss/.well-known/openid-configuration
OIDCClientID ExampleCorp_Prod_web01
OIDCClientSecret <client-secret>
OIDCRedirectURI http://<ip>/redirect_uri
OIDCScope "profile openid"
OIDCCryptoPassphrase example@3003
OIDCCookiePath /
ProxyPass /  http://<ip>:8080/ nocanon
ProxyPassReverse / http://<ip>:8080/
ProxyRequests     Off
AllowEncodedSlashes on
<Proxy http://<ip>:8080/*>
</Proxy>
OIDCAuthNHeader X-Forwarded-User
OIDCRemoteUserClaim sub
OIDCClaimPrefix example_
LoadModule auth_openidc_module modules/mod_auth_openidc.so

【问题讨论】:

  • 您会针对哪个提供商进行配置?
  • 嗨,汉斯,我们正在使用 pingfederate

标签: apache mod-proxy mod-auth-openidc


【解决方案1】:

Github 项目页面上的 README 中有示例:https://github.com/zmartzone/mod_auth_openidc。假设静态网页位于/example,在您的特定(PingFederate)示例中,它将类似于:

OIDCProviderMetadataURL https://<pingfederate-host>:9031/.well-known/openid-configuration

OIDCClientID <client-id-as-registered-with-pingfederate>
OIDCClientSecret <client-secret-as-registered-with-pingfederate>

OIDCRedirectURI https://<your-apache-host>/example/redirect_uri/
OIDCCryptoPassphrase <password>
OIDCScope "openid email profile"

<Location /example/>
   AuthType openid-connect
   Require valid-user
</Location>

基于 OPs 环境的完整工作示例:

Listen 80
User www
Group www
DocumentRoot /opt/local/apache2/htdocs/
ErrorLog "logs/error_log"
LogLevel info
ServerName example.org

LoadModule ssl_module modules/mod_ssl.so
LoadModule authz_user_module   modules/mod_authz_user.so
LoadModule auth_openidc_module modules/mod_auth_openidc.so

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<Location />
   AuthType openid-connect
   Require valid-user
</Location>

OIDCProviderMetadataURL https://accounts.google.com/.well-known/openid-configuration
OIDCClientID myclientid
OIDCClientSecret mysecret
OIDCRedirectURI http://example.org/protected/
OIDCScope "profile openid"
OIDCCryptoPassphrase example@3003
OIDCCookiePath /

ProxyPass /  http://192.168.10.1:80/ nocanon
ProxyPassReverse / http://192.168.10.1:80/
ProxyRequests     Off
AllowEncodedSlashes on
<Proxy http://192.168.10.1:8080/*>
</Proxy>

OIDCAuthNHeader X-Forwarded-User
OIDCRemoteUserClaim sub
OIDCClaimPrefix example_

【讨论】:

  • 嗨,汉斯,感谢您提供的信息。我正在尝试在 openidc 登录后面使用一个 hello world 页面。我使用了来自 openidc wiki 10 的示例。
  • 我正在使用下面的 url 配置一个带有 mod_auth_openidc+mod_proxy+hello world 程序 github.com/pingidentity/mod_auth_openidc/… 的 hello world 网页。但我看到“401 授权错误”
  • 并且日志显示 oidc_unsolicited_proto_state:无法从状态解析 JWT:无效的主动响应:[src/jose/apr_jwt.c:177:apr_jwt_base64url_decode_object]:JSON 解析(json_loads)失败:'[' 或'{' 预计在 'l' 附近(l\\\xb4\xe7r\x12\x97\xec\x0e\x1d\xea\xde\x8az\xe5|\xccb\xf0\xcd)\n oidc_authorization_response_match_state:无法恢复状态oidc_handle_authorization_response:授权响应状态无效且未设置默认 SSO URL,发送错误...对于混合日志和短 cmets 非常抱歉。我无法在每条评论中创建下一行
  • 不要直接访问redirect_uri;这是一个仅由模块本身使用的虚 URL
  • 哦,我的错,谢谢你..几乎在那里......我已经正确了我现在点击的网址。但我仍然看到“授权错误 401”,并且我已经设置了 loglevel 进行调试。但我现在没有看到任何与 oidc 相关的错误。但是当我禁用 oidc 配置模板和 httpd 重新启动时。我看到你好世界回来了。我必须在静态网页上设置任何基本身份验证吗?请建议
猜你喜欢
  • 1970-01-01
  • 2018-03-14
  • 2017-02-16
  • 2020-11-16
  • 2017-03-03
  • 2014-04-26
  • 2021-06-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多