aerpe_auth 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +57 -0
- data/README.rdoc +27 -0
- data/lib/aerpe_auth.rb +51 -0
- metadata +65 -0
data/LICENSE
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
+
(see COPYING.txt file), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
21
|
+
with standard executables, which must also be provided.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or executable
|
26
|
+
form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the executables and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard executables non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under this terms.
|
43
|
+
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
45
|
+
files under the ./missing directory. See each file for the copying
|
46
|
+
condition.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= AerpeAuth
|
2
|
+
|
3
|
+
Setting up authlogic and declarative authorization to DRY up your workflow.
|
4
|
+
|
5
|
+
Supports Rails 2 and Rails 3
|
6
|
+
|
7
|
+
== Dependencies
|
8
|
+
|
9
|
+
authlogic
|
10
|
+
declarative_authorization
|
11
|
+
|
12
|
+
== Restrictions
|
13
|
+
|
14
|
+
* Class names has to be User, Role and UserSession.
|
15
|
+
* User and role has to have a many to many relationship.
|
16
|
+
|
17
|
+
== Installation
|
18
|
+
|
19
|
+
Gem
|
20
|
+
gem install aerpe_auth
|
21
|
+
|
22
|
+
And in app/models/user.rb
|
23
|
+
class User < ActiveRecord::Base
|
24
|
+
acts_as_authentic
|
25
|
+
symbolize_roles
|
26
|
+
# ...
|
27
|
+
end
|
data/lib/aerpe_auth.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module AerpeAuth
|
2
|
+
module Controller
|
3
|
+
def self.included(controller)
|
4
|
+
controller.send :helper_method, :current_user_session, :current_user, :logged_in
|
5
|
+
controller.send :before_filter, AuthorizationSubject
|
6
|
+
end
|
7
|
+
|
8
|
+
def logged_in
|
9
|
+
!!current_user
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_user_session
|
13
|
+
return @current_user_session if defined?(@current_user_session)
|
14
|
+
@current_user_session = UserSession.find
|
15
|
+
end
|
16
|
+
|
17
|
+
def current_user
|
18
|
+
return @current_user if defined?(@current_user)
|
19
|
+
@current_user = current_user_session && current_user_session.record
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Model
|
24
|
+
def self.included(base)
|
25
|
+
base.extend ClassMethods
|
26
|
+
end
|
27
|
+
|
28
|
+
module ClassMethods
|
29
|
+
def symbolize_roles
|
30
|
+
send :include, InstanceMethods
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module InstanceMethods
|
35
|
+
def role_symbols
|
36
|
+
roles.map do |role|
|
37
|
+
role.name.underscore.to_sym
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class AuthorizationSubject
|
44
|
+
def self.filter(controller)
|
45
|
+
Authorization.current_user = controller.current_user
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
ActiveRecord::Base.send :include, AerpeAuth::Model
|
51
|
+
ActionController::Base.send :include, AerpeAuth::Controller
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aerpe_auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Robert Brewitz
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-27 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Helper and class methods for authlogic and declarative authorization, drying up the workflow.
|
22
|
+
email: robert@brewitz.nu
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- lib/aerpe_auth.rb
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://github.com/aerpe/aerpe_auth
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --charset=UTF-8
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
segments:
|
48
|
+
- 0
|
49
|
+
version: "0"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.6
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: DRYing up workflow for authlogic and declarative authorization.
|
64
|
+
test_files: []
|
65
|
+
|