菜鸟的 Rails 身份验证策略 [英] Rails authentication strategy for noob

查看:30
本文介绍了菜鸟的 Rails 身份验证策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这不是太宽泛,但经过大量谷歌搜索后,我不知道从哪里开始.我正在寻找介绍/新手概述,以帮助我开始为 rails 3 应用程序构建身份验证实现.

Hope this is not too broad but after a lot of googling I am not sure where to start. I am looking for a introductory/noob overview to help me get started on building an authentication implementation for a rails 3 application.

基本技术要求:

  • Rails 3 应用程序托管在第三方服务 (heroku) 上
  • 需要使用特定的外部私有 SSO 服务来验证用户.
  • rails 应用程序中没有本地用户数据库或模型.
  • 身份验证是基于令牌的,这意味着需要读取一个特殊的 cookie,并将令牌传递回 SSO 服务器(不是基于 Rails).
  • 我无法控制 SSO 服务器或基础架构.
  • 对 SSO 服务器的信任是隐含的,不想维护用户、密码或敏感信息的本地数据库.用户信息仅在会话期间存在,且 SSO 服务器具有权威性.
  • 会话令牌信息基于 cookie,并在浏览器会话期间有效.

我正在寻找基本的示例/教程/策略/说明,该过程将如何在具有上述设置的 Rails 中工作.我希望这个过程对于用户来说是无缝的,工作流程基本上是这样的:

I am looking for basic example/tutorial/strategy/explanation of how the process would work in rails with the above setup. I would like the process to be seamless for user with workflow that basically looks like this:

  • 导航到 rails 应用程序 -->
  • 将未经身份验证的用户重定向到 SSO 服务器 -->
  • 通过远程 SSO 服务器登录和验证 -->
  • 回调/重定向到 rails 应用程序 -->
  • 捕获从 SSO 服务器传回的用户信息并在 Rails 应用程序中加载受保护的资源

策略是完全自定义的,使用私有 SSO 资源,不使用公开发布的身份验证机制(换句话说,不是 Facebook、Google、Twitter、OAuth 等).

Strategy is completely custom using a private SSO resource and does not use a well published auth mechanism (in other words not Facebook, Google, Twitter, OAuth, etc).

任何有关术语、连贯教程、示例的帮助将不胜感激.

Any help on terminology, coherent tutorials, examples would be appreciated.

编辑/更新:

更具体地说,我也在寻找如何创建 omniauth 自定义开发人员策略的良好文档.一些教程介绍了与任意 SSO 服务器通信所需的代码类型,从 cookie 中读取令牌,并完成身份验证握手和回调/重定向.

To be more specific I am also looking for good documentation how to create an omniauth custom developer strategy. Some tutorial that goes through the kind of code required to talk to an arbitrary SSO server, read a token out of a cookie, and complete the authentication handshake and callback/redirect.

推荐答案

这不是一个真正的答案,但我发布这个是因为评论是行不通的.我不知道任何全面的指南,所以我建议您这样做:

This isn't really an answer but I'm posting this because a comment just wouldn't do. I don't know of any comprehensive guides so here's what I'd suggest you do:

  1. 了解 Omniauth 的工作原理.Railscast 关于使用 Twitter 进行身份验证有一个很棒的介绍.这真的很简单,它会让你进入事情的流程.

  1. Learn how Omniauth works. There's a great Railscast about authentication using Twitter. It's really simple and it will get you in the flow of the thing.

构建您自己的 Omniauth 策略.转到 Omniauth 策略 列表并滚动到 开发人员策略.在该表中,选择可用于连接到 SSO 服务器的策略.

Build your own Omniauth strategy. Go to the list of Omniauth Strategies and scroll to Developer Strategies. In that table, choose the strategy you can use to connect to your SSO server.

理想情况下,您可以使用 OAuth2,并且有几个指南讨论了如何实施您自己的 OAuth 策略:

Ideally, you'd be able to use OAuth2 and there are a couple of guides that talk about implementing your own OAuth strategy:

  1. 自定义 OAuth 1.0 策略以连接到 Rdio
  2. Intride(Omniauth 的创建者)的自定义 OAuth 2.0 策略
  3. 通过 Heroku 连接到 Force.com 的自定义 OAuth 2.0 策略

但既然你不能,那就快速浏览一下这些指南吧.没有任何细节,(对我来说)很难提供更多帮助,但希望其他人能填写详细信息.

But since you can't, just give a quick look at those guides. Without any specifics it's kind of hard (for me) to give any more help, but hopefully someone else will fill in the details.

这篇关于菜鸟的 Rails 身份验证策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆