cream 0.8.9 → 0.8.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,8 @@ The gems "devise-links":http://github.com/kristianmandrup/devise-links and "canc
22
22
 
23
23
  Cream comes with a suite of specialized generators that should let you configure your Rails 3 app with these systems to a large degree.
24
24
 
25
+ Note: Lately Cream also has options for some common customizations such as allowing login using either username or email.
26
+
25
27
  h2. Objectives
26
28
 
27
29
  * Integrate a set of widely accepted sub-systems for a fully integrated solution
@@ -39,7 +41,9 @@ Please let me know of other areas that you think should be covered in the Wiki o
39
41
  h2. The magic behind the curtain...
40
42
 
41
43
  Cream leverages an extensive "Tool suite":https://github.com/kristianmandrup/cream/wiki/Tool-suite-for-designing-powerful-generators-and-gems-for-Rails-3 I have created specifically to make it much easier/faster to create gems and generators for Rails 3 and spec/test them with RSpec 2, all using more natural DSLs and APIs.
42
- If you look into the Cream code you can see extensive usage of this "magic" (especially in the generators).
44
+ If you look into the Cream code you can see extensive usage of this "magic" (especially in the generators).
45
+
46
+ Status (Jan 15): I'm currently in the process of refactoring and improving this underlying "tool suite". I might call it _rails-mixer_ or something :P ?
43
47
 
44
48
  h2. Cream user group
45
49
 
@@ -49,10 +53,31 @@ h2. Inspiration and Ideas
49
53
 
50
54
  _Tony Amoyal_ has written a two part series ("Part I":http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/, "Part II":http://www.tonyamoyal.com/2010/09/29/rails-authentication-with-devise-and-cancan-part-2-restful-resources-for-administrators/) on how to setup a fully integrated Devise/CanCan solution with Roles. You might want to take a look at this for further customization needs. It might also provide food for thought for suggestions on improvements to the Cream framework ;) I have started work on a _devise:customize_ generator to facilitate some of these customization needs...
51
55
 
56
+ Currently there is support for seting up a Guest user and and option to use both username and password as valid credentials.
57
+
52
58
  h3. Design ideas
53
59
 
54
60
  Please see the "Design ideas":https://github.com/kristianmandrup/cream/wiki/Design-ideas section on the wiki for possible enhancements you might want to add and/or ideas for further improvments to the framework. Feel free to add your own suggestions and ideas!
55
61
 
62
+ Currently when the Cream config generator is given a set of roles, it both sets up the Roles creates Devise Users for all those roles. In real life scenarios, you will likely want a set of roles and a set of user types. The user types are distinct types of users, possibly with distinct data, registration pages, authentication rules (devise config) etc. The roles are more generic in nature, and users of various user types can each share one or more roles. The API should also include a DSL to easily customize this.
63
+
64
+ Please also see "Cream Guest user":https://github.com/kristianmandrup/cream/wiki/Cream-Guest-user for more info on the current approach and the inherent problems with this.
65
+
66
+ Example idea:
67
+
68
+ <pre>
69
+ class Editor < User
70
+ default_role :editor
71
+
72
+ valid_roles_are :publisher, blog_editor
73
+ roles_config :multi
74
+ end
75
+ </pre>
76
+
77
+ This way, any editor user created will always be given the :editor role on creation and he can later add the :publisher and/or :blog_editor roles, depending on whether Cream is set up as a single or multi role system. In the future, the framework might even allow some user types to have multiple roles and others to have only a single role (here indicated by the _roles_config :multi_ statement) ? What do you think?
78
+
79
+ *Ideas and suggestions are most welcome!*
80
+
56
81
  h2. Cream edge, debugging and assisting developing the framework
57
82
 
58
83
  Cream edge (directly from trunk or a feature branch), might have some extra goodies you could be interested in. To help develop Cream or use the edge version, just do:
@@ -85,31 +110,7 @@ h2. Authentication systems
85
110
 
86
111
  Cream targets "Devise":http://github.com/plataformatec/devise as the Authentication system of choice
87
112
 
88
- Devise Configuration options:
89
-
90
- 1. Database Authenticatable: encrypts and stores a password in the database to validate the authenticity of an user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.
91
- 2. Token Authenticatable: signs in an user based on an authentication token (also known as “single access token”). The token can be given both through query string or HTTP Basic Authentication.
92
- 3. Oauthable: adds OAuth2 support
93
- 4. Confirmable: sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.
94
- 5. Recoverable: resets the user password and sends reset instructions.
95
- 6. Registerable: handles signing up users through a registration process, also allowing them to edit and destroy their account.
96
- 7. Rememberable: manages generating and clearing a token for remembering the user from a saved cookie.
97
- 8. Trackable: tracks sign in count, timestamps and IP address.
98
- 9. Timeoutable: expires sessions that have no activity in a specified period of time.
99
- 10. Validatable: provides validations of email and password. It’s optional and can be customized, so you’re able to define your own validations.
100
- 11. Lockable: locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.
101
-
102
- Configuration is done using the _devise_ statement in the User class (and subclasses).
103
-
104
- Example: Use _Confirmable_ and _Validatable_ devise options/strategies
105
-
106
- <pre>
107
- class User
108
- devise :confirmable, :validatable
109
- end
110
- </pre>
111
-
112
- Note: For Active Record your User table (via migration fx) must support the columns needed for the devise options you are using (See Devise documentation).
113
+ See "Devise Configuration options":https://github.com/kristianmandrup/cream/wiki/Devise-Configuration-options for more details on configuring your devise User models.
113
114
 
114
115
  h3. Devise links
115
116
 
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ begin
20
20
 
21
21
  gem.add_dependency "devise-links", ">= 0.2.1"
22
22
  gem.add_dependency "cancan-rest-links", ">= 0.2.1"
23
- gem.add_dependency "cancan-permits", ">= 0.3.9"
23
+ gem.add_dependency "cancan-permits", ">= 0.3.10"
24
24
 
25
25
  gem.add_dependency "devise", ">= 1.1.5"
26
26
  gem.add_dependency "cancan", ">= 1.4.1"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.9
1
+ 0.8.9.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cream}
8
- s.version = "0.8.9"
8
+ s.version = "0.8.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2011-01-10}
12
+ s.date = %q{2011-01-15}
13
13
  s.description = %q{An integrated Authentication, Authorization and Roles solution for your Rails 3 app with support for multiple ORMs}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -155,7 +155,7 @@ Gem::Specification.new do |s|
155
155
  s.add_runtime_dependency(%q<colorize>, [">= 0.5.8"])
156
156
  s.add_runtime_dependency(%q<devise-links>, [">= 0.2.1"])
157
157
  s.add_runtime_dependency(%q<cancan-rest-links>, [">= 0.2.1"])
158
- s.add_runtime_dependency(%q<cancan-permits>, [">= 0.3.9"])
158
+ s.add_runtime_dependency(%q<cancan-permits>, [">= 0.3.10"])
159
159
  s.add_runtime_dependency(%q<devise>, [">= 1.1.5"])
160
160
  s.add_runtime_dependency(%q<cancan>, [">= 1.4.1"])
161
161
  s.add_runtime_dependency(%q<rails>, [">= 3.0.1"])
@@ -186,7 +186,7 @@ Gem::Specification.new do |s|
186
186
  s.add_dependency(%q<colorize>, [">= 0.5.8"])
187
187
  s.add_dependency(%q<devise-links>, [">= 0.2.1"])
188
188
  s.add_dependency(%q<cancan-rest-links>, [">= 0.2.1"])
189
- s.add_dependency(%q<cancan-permits>, [">= 0.3.9"])
189
+ s.add_dependency(%q<cancan-permits>, [">= 0.3.10"])
190
190
  s.add_dependency(%q<devise>, [">= 1.1.5"])
191
191
  s.add_dependency(%q<cancan>, [">= 1.4.1"])
192
192
  s.add_dependency(%q<rails>, [">= 3.0.1"])
@@ -218,7 +218,7 @@ Gem::Specification.new do |s|
218
218
  s.add_dependency(%q<colorize>, [">= 0.5.8"])
219
219
  s.add_dependency(%q<devise-links>, [">= 0.2.1"])
220
220
  s.add_dependency(%q<cancan-rest-links>, [">= 0.2.1"])
221
- s.add_dependency(%q<cancan-permits>, [">= 0.3.9"])
221
+ s.add_dependency(%q<cancan-permits>, [">= 0.3.10"])
222
222
  s.add_dependency(%q<devise>, [">= 1.1.5"])
223
223
  s.add_dependency(%q<cancan>, [">= 1.4.1"])
224
224
  s.add_dependency(%q<rails>, [">= 3.0.1"])
@@ -1,15 +1,15 @@
1
1
  class ApplicationController < ActionController::Base
2
+
2
3
  def current_user
3
- cu = super
4
4
  if defined? Cream::Role
5
5
  # Try to get instance of any of the available roles as the current user
6
6
  Cream::Role.available.each do |role|
7
7
  method = :"current_#{role}"
8
- cu ||= send method if respond_to?(method)
8
+ @cu ||= send method if respond_to?(method)
9
9
  end
10
10
  end
11
- # if all else fails, the user is likely not signed in so create a Guest user for now
12
- cu ||= Guest.create if defined?(Guest)
11
+ return @cu if @cu
12
+ session[:guest] ||= Guest.create if defined?(Guest)
13
13
  end
14
14
 
15
15
  def user_signed_in?
@@ -74,7 +74,13 @@ require "rails/test_unit/railtie"
74
74
  def create_guest_user
75
75
  remove_model :guest if has_model?(:guest)
76
76
  create_model :guest do
77
- %Q{
77
+ %Q{
78
+ # modify this as needed for now!
79
+ # attr_accessor :login, :username, :email
80
+ # attr_accessor :password
81
+ #
82
+ # attr_accessible :login
83
+
78
84
  def self.create
79
85
  Guest.new
80
86
  end
@@ -92,7 +98,7 @@ require "rails/test_unit/railtie"
92
98
  end
93
99
 
94
100
  def has_any_role? *roles
95
- roles.flat_uniq..to_symbols.include? :guest
101
+ roles.flat_uniq.to_symbols.include?(:guest)
96
102
  end
97
103
  }
98
104
  end
metadata CHANGED
@@ -6,7 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 8
8
8
  - 9
9
- version: 0.8.9
9
+ - 1
10
+ version: 0.8.9.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Kristian Mandrup
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-10 00:00:00 +01:00
18
+ date: 2011-01-15 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -357,8 +358,8 @@ dependencies:
357
358
  segments:
358
359
  - 0
359
360
  - 3
360
- - 9
361
- version: 0.3.9
361
+ - 10
362
+ version: 0.3.10
362
363
  type: :runtime
363
364
  prerelease: false
364
365
  version_requirements: *id023