- 浏览: 2065531 次
- 性别:
- 来自: NYC
文章分类
- 全部博客 (628)
- Linux (53)
- RubyOnRails (294)
- HTML (8)
- 手册指南 (5)
- Mysql (14)
- PHP (3)
- Rails 汇总 (13)
- 读书 (22)
- plugin 插件介绍与应用 (12)
- Flex (2)
- Ruby技巧 (7)
- Gem包介绍 (1)
- javascript Jquery ext prototype (21)
- IT生活 (6)
- 小工具 (4)
- PHP 部署 drupal (1)
- javascript Jquery sort plugin 插件 (2)
- iphone siri ios (1)
- Ruby On Rails (106)
- 编程概念 (1)
- Unit Test (4)
- Ruby 1.9 (24)
- rake (1)
- Postgresql (6)
- ruby (5)
- respond_to? (1)
- method_missing (1)
- git (8)
- Rspec (1)
- ios (1)
- jquery (1)
- Sinatra (1)
最新评论
-
dadadada2x:
user模型里加上 protected def email ...
流行的权限管理 gem devise的定制 -
Sev7en_jun:
shrekting 写道var pattern = /^(0| ...
强悍的ip格式 正则表达式验证 -
jiasanshou:
好文章!!!
RPM包rpmbuild SPEC文件深度说明 -
寻得乐中乐:
link_to其实就是个a标签,使用css控制,添加一个参数: ...
Rails在link_to中加参数 -
aiafei0001:
完全看不懂,不知所然.能表达清楚一点?
"$ is not defined" 的问题怎么办
http://github.com/technoweenie/restful-authentication/
很热的一个插件下载
http_authentication比较轻量级
示例如下:
http://github.com/binarylogic/authlogic/
本地下载
用法示例:
很热的一个插件下载
http_authentication比较轻量级
示例如下:
Simple Basic example: class PostsController < ApplicationController USER_NAME, PASSWORD = "dhh", "secret" before_filter :authenticate, :except => [ :index ] def index render :text => "Everyone can see me!" end def edit render :text => "I'm only accessible if you know the password" end private def authenticate authenticate_or_request_with_http_basic do |user_name, password| user_name == USER_NAME && password == PASSWORD end end end #Here is a more advanced Basic example where only Atom feeds and the XML API is #protected by HTTP authentication, #the regular HTML interface is protected by a session approach (NOTE: This example requires Rails Edge as #it uses Request#format, which is not available in Rails 1.2.0): class ApplicationController < ActionController::Base before_filter :set_account, :authenticate protected def set_account @account = Account.find_by_url_name(request.subdomains.first) end def authenticate case request.format when Mime::XML, Mime::ATOM if user = authenticate_with_http_basic { |u, p| @account.users.authenticate(u, p) } @current_user = user else request_http_basic_authentication end else if session_authenticated? @current_user = @account.users.find(session[:authenticated][:user_id]) else redirect_to(login_url) and return false end end end end #In your integration tests, you can do something like this: def test_access_granted_from_xml get( "/notes/1.xml", nil, :authorization => HttpAuthentication::Basic.encode_credentials(users(:dhh).name, users(:dhh).password) ) assert_equal 200, status end
http://github.com/binarylogic/authlogic/
本地下载
用法示例:
class UserSession < Authlogic::Session::Base # specify configuration here, such as: # logout_on_timeout true # ...many more options in the documentation end
class UserSessionsController < ApplicationController def new @user_session = UserSession.new end def create @user_session = UserSession.new(params[:user_session]) if @user_session.save redirect_to account_url else render :action => :new end end def destroy current_user_session.destroy redirect_to new_user_session_url end end #As you can see, this fits nicely into the RESTful development pattern. What about the view… <% form_for @user_session do |f| %> <%= f.error_messages %> <%= f.label :login %><br /> <%= f.text_field :login %><br /> <br /> <%= f.label :password %><br /> <%= f.password_field :password %><br /> <br /> <%= f.submit "Login" %> <% end %> #Or how about persisting the session… class ApplicationController helper_method :current_user_session, :current_user private def current_user_session return @current_user_session if defined?(@current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined?(@current_user) @current_user = current_user_session && current_user_session.user end end
- restful-authentication.rar (1 MB)
- 下载次数: 62
- http_authentication.rar (11.9 KB)
- 下载次数: 40
- authlogic.rar (768.4 KB)
- 下载次数: 24
发表评论
-
Destroying a Postgres DB on Heroku
2013-04-24 10:58 915heroku pg:reset DATABASE -
VIM ctags setup ack
2012-04-17 22:13 3246reference ctags --extra=+f --e ... -
alias_method_chain方法在3.1以后的替代使用方式
2012-02-04 02:14 3274alias_method_chain() 是rails里的一个 ... -
一些快速解决的问题
2012-01-19 12:35 1463问题如下: 引用Could not open library ... -
API service 安全问题
2011-12-04 08:47 1368这是一个长期关注的课题 rest api Service的 ... -
Module方法调用好不好
2011-11-20 01:58 1332以前说,用module给class加singleton方法,和 ... -
一个ajax和rails交互的例子
2011-11-19 01:53 1894首先,这里用了一个,query信息解析的包,如下 https: ... -
Rails 返回hash给javascript
2011-11-19 01:43 2262这是一个特别的,不太正统的需求, 因为,大部分时候,ajax的 ... -
关于Rubymine
2011-11-18 23:21 2250开个帖子收集有关使用上的问题 前一段时间,看到半价就买了。想 ... -
ruby中和javascript中,动态方法的创建
2011-11-18 21:01 1224class Klass def hello(*args) ... -
textmate快捷键 汇总
2011-11-16 07:20 8126TextMate 列编辑模式 按住 Alt 键,用鼠标选择要 ... -
Ruby面试系列六,面试继续面试
2011-11-15 05:55 2010刚才受到打击了,充分报漏了自己基础不扎实,不肯向虎炮等兄弟学习 ... -
说说sharding
2011-11-13 00:53 1467这个东西一面试就有人 ... -
rails面试碎碎念
2011-11-12 23:51 1932面试继续面试 又有问ru ... -
最通常的git push reject 和non-fast forward是因为
2011-11-12 23:29 17191git push To git@github.com:use ... -
Rails 自身的many to many关系 self has_many
2011-11-12 01:43 2713简单点的 #注意外键在person上people: id ... -
Rails 3下的 in place editor edit in place
2011-11-12 01:20 939第一个版本 http://code.google.com/p ... -
Heroku 的诡异问题集合
2011-11-11 07:22 1688开个Post记录,在用heroku过程中的一些诡异问题和要注意 ... -
SCSS 和 SASS 和 HAML 和CoffeeScript
2011-11-07 07:52 12942Asset Pipeline 提供了内建 ... -
Invalid gemspec because of the date format in specification
2011-11-07 02:14 2100又是这个date format的错误。 上次出错忘了,记录下 ...
相关推荐
根据提供的文件信息,我们可以推断出这是一本关于如何使用Ruby on Rails框架来构建RESTful应用程序和服务的专业书籍。书名为《RESTful Rails Development》,作者为Silvia Puglisi,出版时间为2015年10月。接下来,...
第六章至第八章涉及 **身份验证(Authentication)** 和 **授权(Authorization)**,这两个概念对于构建安全的 Web 应用至关重要。 - **身份验证**:确认用户的身份,通常通过用户名和密码组合完成。 - **授权**:根据...
在Rails 6中开发纯后端API项目是一个常见的任务,特别是在构建现代Web应用程序时,前端与后端分离的架构越来越流行。Rails作为一个强大的Ruby框架,提供了丰富的功能来帮助开发者高效地构建API服务。下面我们将详细...
rails2.0的内容管理系统,可以发布文档、CVS库和Web资源3中资源,其中文档可以上传下载附件。支持打Tag。用户注册登录使用restful_authentication,分页使用will_paginate,Gem版本1.3.5
它在后端使用Ruby on Rails生成RESTful API,在前端使用React / Redux,并使用Pusher无缝实现WebSockets。 特征 使用Devise通过自动演示登录进行用户身份验证 即时通讯 讯息格式 通知事项当前频道通知 频道数 直接...
Laravel 试图通过简化大多数 Web 项目中使用的常见任务(例如身份验证、路由、会话和缓存)来减轻开发过程中的痛苦。 Laravel 的目标是在不牺牲应用程序功能的情况下使开发过程对开发人员来说是一种愉快的过程。 ...
GYMIFY API 使用Ruby on Rails构建的RESTFUL API。 该应用程序公开了健身房前端应用程序的API端点。 该应用程序允许用户注册,登录,查看培训师并与培训师预约约会。终点此api公开了两个端点,可以使用...
书中有许多关于模型关联、查询优化、事务处理和复杂数据库设计的实例,帮助开发者更好地管理数据和数据库交互。 3. **Caching**:Rails提供了多种缓存策略,如页面缓存、动作缓存和碎片缓存,以提高应用程序性能。...
Rails推崇敏捷开发,具有强大的社区支持和丰富的插件库。 (4) Laravel:PHP领域的热门框架,以优雅的语法和全面的特性和工具闻名。Laravel包含了艺术级别的路由、缓存、队列和任务调度,以及强大的Eloquent ORM。 ...
例如,`Meeting`和`Participant`模型可能会包含数据验证、关联和其他业务规则。Rails的ActiveRecord库使得与数据库的交互变得简单。 4. **视图(Views)**:尽管API通常不涉及视图,因为它们主要处理数据交换,但...
在IT行业中,Angular和Rails是两个非常重要的框架,分别用于前端和后端开发。这篇文本将深入探讨这两个技术,以及如何将它们结合使用。 Angular,由Google维护,是一款强大的JavaScript框架,主要用于构建单页应用...
RailsAPI 是一个专门为构建RESTful API设计的Ruby on Rails框架的子集。它专注于提供一个轻量级的、高效的环境,用于开发仅处理JSON或XML数据的后端服务,而无需传统的Web应用程序视图和路由。RailsAPI的目标是减少...
框架可能包含了身份验证(Authentication)和授权(Authorization)机制,例如JWT(JSON Web Tokens)或OAuth2,来实现用户登录验证和权限分配。 4. **模板引擎** 框架内可能集成了模板引擎,如Thymeleaf(Java)...
这涉及到身份验证(Authentication)和授权(Authorization)机制,如JWT(JSON Web Tokens)或OAuth。 6. **API接口**:如果系统需要与其他应用集成,可能包含RESTful API接口,用于数据交换。这些接口遵循HTTP...