merb-auth 0.1.0 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 PragmaQuest Inc
1
+ Copyright (c) 2008 Adam French, Daniel Neighman
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.textile ADDED
@@ -0,0 +1,90 @@
1
+ h1. MerbAuth - Merb Merb::Authentication
2
+
3
+ h2. An extensible architecture for authentication
4
+
5
+ * Stupidly Simple
6
+ * Speaks fluent HTTP, even the errors
7
+ * Pluggable Architecture (so that you can use any authentication algorithms you like)
8
+ * Cascading Merb::Authentication (if one method fails, another is attempted, then another. When no methods succeed, authentication fails)
9
+
10
+ h2. Principles
11
+
12
+ # Sessions are authenticated
13
+ # Just because one method of authentication fails doesn't mean the session, can't be authenticated another way. This is especially true if your application has an external API as well as a public interface.
14
+ # HTTP has built-in "Errors":http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html which every web-browser (should) know how to speak. If you're application speaks in HTTP Verbs (GET, POST, PUT, DELETE), it should also serve the correct HTTP Errors when things go wrong.
15
+
16
+ h2. What is it
17
+
18
+ The merb-auth gem is the default implementation of merb-auth-core and merb-auth-more for
19
+ the default Merb Stack. Included are:
20
+
21
+ merb-auth-slice-password # A basic slice that provides everything you need for basic password logins
22
+
23
+ Strategies:
24
+ :default_password_form # Form based login via a "login" field and "password" field
25
+ :default_basic_auth # Basic authentication
26
+
27
+ Mixins:
28
+ redirect_back # For redirect_back_or functionality
29
+ salted_user # Automtaically provides the required methods on your user model
30
+
31
+ h3. Get merb-auth
32
+
33
+ merb-auth is bundled with the merb gem. To get it as stand alone you can get it two ways.
34
+
35
+ Gem Style
36
+ @sudo gem install merb-auth@
37
+
38
+ From Source
39
+ <pre><code>
40
+ git clone http://github.com/wycats/merb-more.git
41
+ cd merb-more/merb-auth
42
+ sudo rake install
43
+ </code></pre>
44
+
45
+ h2. Basic Setup
46
+
47
+ h3. Application Setup
48
+
49
+ h4. Setup your user
50
+
51
+ Setup your User resource
52
+ $ merb-gen resource users
53
+
54
+ Ensure you have a login property
55
+ property :login, String
56
+
57
+ Make sure you have the following in your migrations (if required)
58
+ crypted_password - String
59
+ salt - String
60
+
61
+
62
+ h4. Setup your configuration
63
+
64
+ Include merb-auth in your application config/init.rb
65
+ <pre><code>
66
+ dependency "merb-auth"
67
+ </code></pre>
68
+
69
+ Setup the routing: config/router.rb
70
+
71
+ <pre><code>
72
+ Merb::Router.prepare do
73
+ merb_auth_routes(:name_prefix => nil, :path_prefix => nil)
74
+ end
75
+ </code></pre>
76
+
77
+ Protect Your Controller
78
+ <pre><code>
79
+ class MyController < Application
80
+ before :ensure_authenticated
81
+
82
+ #...
83
+ end
84
+ </pre></code>
85
+
86
+
87
+
88
+
89
+
90
+
data/Rakefile CHANGED
@@ -1,47 +1,91 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'spec/rake/spectask'
4
- require 'merb-core/version'
5
- require 'merb-core/test/tasks/spectasks'
6
-
7
- PLUGIN = "merb-auth"
8
- NAME = "merb-auth"
9
- AUTHOR = "Cuong Tran"
10
- EMAIL = "ctran@pragmaquest.com"
11
- HOMEPAGE = "http://merb-slices.rubyforge.org/merb-auth/"
12
- SUMMARY = "Merb Slice that provides user authentication"
13
- SLICE_VERSION = "0.1.0"
14
-
15
- spec = Gem::Specification.new do |s|
16
- s.name = NAME
17
- s.version = SLICE_VERSION
18
- s.platform = Gem::Platform::RUBY
19
- s.has_rdoc = true
20
- s.extra_rdoc_files = ["README", "LICENSE"]
21
- s.summary = SUMMARY
22
- s.description = s.summary
23
- s.author = AUTHOR
24
- s.email = EMAIL
25
- s.homepage = HOMEPAGE
26
- s.add_dependency('merb-slices', '>= 0.9.4')
27
- s.require_path = 'lib'
28
- s.files = %w(LICENSE README Rakefile) + Dir.glob("{lib,spec,app,public}/**/*")
1
+ require File.join(File.dirname(__FILE__), "../merb-core/lib/merb-core/version.rb")
2
+
3
+ GEM_VERSION = Merb::VERSION
4
+ GEM_NAME = "merb-auth"
5
+ require "rake/clean"
6
+ require "rake/gempackagetask"
7
+ require 'rubygems/specification'
8
+ require "spec/rake/spectask"
9
+ require 'merb-core/tasks/merb_rake_helper'
10
+ require 'fileutils'
11
+ include FileUtils
12
+
13
+ require "extlib/tasks/release"
14
+
15
+ RUBY_FORGE_PROJECT = "merb-auth"
16
+ PROJECT_URL = "http://merbivore.com"
17
+ PROJECT_SUMMARY = "merb-auth. The official authentication plugin for merb. Setup for the default stack"
18
+ PROJECT_DESCRIPTION = PROJECT_SUMMARY
19
+
20
+ GEM_AUTHOR = "Daniel Neighman"
21
+ GEM_EMAIL = "has.sox@gmail.com"
22
+
23
+ GEM_NAME = "merb-auth"
24
+ PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
25
+ GEM_VERSION = Merb::VERSION + PKG_BUILD
26
+
27
+ RELEASE_NAME = "REL #{GEM_VERSION}"
28
+
29
+ gems = %w[
30
+ merb-auth-core merb-auth-more merb-auth-slice-password
31
+ ]
32
+
33
+ merb_auth_spec = Gem::Specification.new do |s|
34
+ s.rubyforge_project = RUBY_FORGE_PROJECT
35
+ s.name = GEM_NAME
36
+ s.version = GEM_VERSION
37
+ s.platform = Gem::Platform::RUBY
38
+ s.author = GEM_AUTHOR
39
+ s.email = GEM_EMAIL
40
+ s.homepage = "http://www.merbivore.com"
41
+ s.summary = PROJECT_SUMMARY
42
+ s.description = PROJECT_SUMMARY
43
+ s.files = %w(LICENSE README.textile Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
44
+ s.add_dependency "merb-core", "~> #{GEM_VERSION}"
45
+ gems.each do |gem|
46
+ s.add_dependency gem, "~> #{GEM_VERSION}"
47
+ end
29
48
  end
30
49
 
31
- Rake::GemPackageTask.new(spec) do |pkg|
32
- pkg.gem_spec = spec
50
+ CLEAN.include ["**/.*.sw?", "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache"]
51
+
52
+ Rake::GemPackageTask.new(merb_auth_spec) do |package|
53
+ package.gem_spec = merb_auth_spec
33
54
  end
34
55
 
35
- desc "Install Foo as a gem"
36
- task :install => [:package] do
37
- sh %{sudo gem install pkg/#{NAME}-#{SLICE_VERSION} --no-update-sources --local}
56
+ task :package => ["lib/merb-auth.rb"]
57
+ desc "Create merb-auth.rb"
58
+ task "lib/merb-auth.rb" do
59
+ mkdir_p "lib"
60
+ File.open("lib/merb-auth.rb","w+") do |file|
61
+ file.puts "### AUTOMATICALLY GENERATED. DO NOT EDIT!"
62
+ gems.each do |gem|
63
+ next if gem == "merb-gen"
64
+ file.puts "require '#{gem}'"
65
+ end
66
+ end
38
67
  end
39
68
 
40
- namespace :jruby do
69
+ desc "install the plugin as a gem"
70
+ task :install do
71
+ Merb::RakeHelper.install(GEM_NAME, :version => GEM_VERSION)
72
+ end
41
73
 
42
- desc "Run :package and install the resulting .gem with jruby"
43
- task :install => :package do
44
- sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{VERSION}.gem --no-rdoc --no-ri}
45
- end
74
+ desc "Uninstall the gem"
75
+ task :uninstall do
76
+ Merb::RakeHelper.uninstall(GEM_NAME, :version => GEM_VERSION)
77
+ end
46
78
 
79
+ desc "Create a gemspec file"
80
+ task :gemspec do
81
+ File.open("#{GEM_NAME}.gemspec", "w") do |file|
82
+ file.puts spec.to_ruby
83
+ end
47
84
  end
85
+
86
+ desc "Run all specs"
87
+ task :spec do
88
+ gems.each do |gem|
89
+ Dir.chdir(gem) { sh "#{Gem.ruby} -S rake spec" }
90
+ end
91
+ end
data/TODO ADDED
File without changes
data/lib/merb-auth.rb CHANGED
@@ -1,72 +1,4 @@
1
- if defined?(Merb::Plugins)
2
-
3
- load_dependency 'merb-slices'
4
- load_dependency 'merb_helpers'
5
-
6
- require File.join(File.dirname(__FILE__), 'merb-auth', 'model')
7
-
8
- Merb::Plugins.add_rakefiles "merb-auth/merbtasks", "merb-auth/slicetasks"
9
-
10
- # Register the Slice for the current host application
11
- Merb::Slices::register(__FILE__)
12
-
13
- # Slice configuration - set this in a before_app_loads callback.
14
- # By default a Slice uses its own layout.
15
- Merb::Slices::config[:merb_auth][:layout] ||= :merb_auth
16
-
17
- # Use a short name for the user model class. Set this to false to use MerbAuth::User
18
- Merb::Slices::config[:merb_auth][:user_class_alias] = "User"
19
-
20
- # All Slice code is expected to be namespaced inside a module
21
- module MerbAuth
22
- # Slice metadata
23
- self.description = "MerbAuth is an user authentication Merb slice!"
24
- self.version = "0.1.0"
25
- self.author = "ctran@pragmaquest.com"
26
-
27
- # Stub classes loaded hook - runs before LoadClasses BootLoader
28
- # right after a slice's classes have been loaded internally.
29
- def self.loaded
30
- MerbAuth.use_adapter(Merb.orm_generator_scope) if Merb.orm_generator_scope != :merb_default
31
- Object.const_set(Merb::Slices::config[:merb_auth][:user_class_alias], MerbAuth::User) if Merb::Slices::config[:merb_auth][:user_class_alias]
32
- end
33
-
34
- # Initialization hook - runs before AfterAppLoads BootLoader
35
- def self.init
36
- end
37
-
38
- # Activation hook - runs after AfterAppLoads BootLoader
39
- def self.activate
40
- end
41
-
42
- # Deactivation hook - triggered by Merb::Slices.deactivate(Bar)
43
- def self.deactivate
44
- end
45
-
46
- # Setup routes inside the host application
47
- #
48
- # @param scope<Merb::Router::Behaviour>
49
- # Routes will be added within this scope (namespace). In fact, any
50
- # router behaviour is a valid namespace, so you can attach
51
- # routes at any level of your router setup.
52
- def self.setup_router(scope)
53
- scope.match('/login').to(:controller => 'users', :action => 'login').name(:login)
54
- scope.match('/logout').to(:controller => 'users', :action => 'logout').name(:logout)
55
- scope.match('/signup').to(:controller => 'users', :action => 'signup').name(:signup)
56
- end
57
- end
58
-
59
- # Setup the slice layout for MerbAuth
60
- #
61
- # Use MerbAuth.push_path and MerbAuth.push_app_path
62
- # to set paths to merb-auth-level and app-level paths. Example:
63
- #
64
- # MerbAuth.push_path(:application, MerbAuth.root)
65
- # MerbAuth.push_app_path(:application, Merb.root / 'slices' / 'merb-auth')
66
- # ...
67
- #
68
- # Any component path that hasn't been set will default to MerbAuth.root
69
- #
70
- # Or just call setup_default_structure! to setup a basic Merb MVC structure.
71
- MerbAuth.setup_default_structure!
72
- end
1
+ ### AUTOMATICALLY GENERATED. DO NOT EDIT!
2
+ require 'merb-auth-core'
3
+ require 'merb-auth-more'
4
+ require 'merb-auth-slice-password'
metadata CHANGED
@@ -1,75 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
- - Cuong Tran
7
+ - Daniel Neighman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-06-11 00:00:00 -05:00
12
+ date: 2008-10-14 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: merb-slices
16
+ name: merb-core
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
20
- - - ">="
21
+ - - ~>
21
22
  - !ruby/object:Gem::Version
22
- version: 0.9.4
23
+ version: 0.9.9
23
24
  version:
24
- description: Merb Slice that provides user authentication
25
- email: ctran@pragmaquest.com
25
+ - !ruby/object:Gem::Dependency
26
+ name: merb-auth-core
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.9
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: merb-auth-more
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.9
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: merb-auth-slice-password
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.9
54
+ version:
55
+ description: merb-auth. The official authentication plugin for merb. Setup for the default stack
56
+ email: has.sox@gmail.com
26
57
  executables: []
27
58
 
28
59
  extensions: []
29
60
 
30
- extra_rdoc_files:
31
- - README
32
- - LICENSE
61
+ extra_rdoc_files: []
62
+
33
63
  files:
34
64
  - LICENSE
35
- - README
65
+ - README.textile
36
66
  - Rakefile
37
- - lib/merb-auth
38
- - lib/merb-auth/adapter
39
- - lib/merb-auth/adapter/activerecord.rb
40
- - lib/merb-auth/adapter/datamapper.rb
41
- - lib/merb-auth/merbtasks.rb
42
- - lib/merb-auth/model.rb
43
- - lib/merb-auth/slicetasks.rb
67
+ - TODO
44
68
  - lib/merb-auth.rb
45
- - spec/controllers
46
- - spec/controllers/router_spec.rb
47
- - spec/controllers/session_spec.rb
48
- - spec/controllers/users_spec.rb
49
- - spec/controllers/view_helper_spec.rb
50
- - spec/merb-auth_spec.rb
51
- - spec/models
52
- - spec/models/ar_user_spec.rb
53
- - spec/models/dm_user_spec.rb
54
- - spec/models/shared_user_spec.rb
55
- - spec/spec_helper.rb
56
- - app/controllers
57
- - app/controllers/application.rb
58
- - app/controllers/controller_mixin.rb
59
- - app/controllers/users.rb
60
- - app/helpers
61
- - app/helpers/application_helper.rb
62
- - app/views
63
- - app/views/layout
64
- - app/views/layout/merb_auth.html.erb
65
- - app/views/users
66
- - app/views/users/login.html.erb
67
- - app/views/users/signup.html.erb
68
- - public/javascripts
69
- - public/stylesheets
70
- - public/stylesheets/master.css
71
- has_rdoc: true
72
- homepage: http://merb-slices.rubyforge.org/merb-auth/
69
+ has_rdoc: false
70
+ homepage: http://www.merbivore.com
73
71
  post_install_message:
74
72
  rdoc_options: []
75
73
 
@@ -89,10 +87,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
87
  version:
90
88
  requirements: []
91
89
 
92
- rubyforge_project:
93
- rubygems_version: 1.1.1
90
+ rubyforge_project: merb-auth
91
+ rubygems_version: 1.2.0
94
92
  signing_key:
95
93
  specification_version: 2
96
- summary: Merb Slice that provides user authentication
94
+ summary: merb-auth. The official authentication plugin for merb. Setup for the default stack
97
95
  test_files: []
98
96
 
data/README DELETED
@@ -1,64 +0,0 @@
1
- MerbAuth
2
- =========
3
-
4
- An user authentication slice for Merb, with support for ActiveRecord and DataMapper.
5
- See http://github.com/ctran/merb-skel for an example application that uses this slice
6
-
7
- == Installation:
8
-
9
- > gem install merb
10
- > gem install merb-slices
11
-
12
- To use activerecord adapter
13
- > gem install activerecord
14
- > gem merb_activerecord
15
-
16
- To use datamapper adapter
17
- > gem install datamapper
18
- > gem install merb_datamapper
19
-
20
- === config/init.rb
21
-
22
- # add the slice as a regular dependency
23
- dependency 'merb-auth'
24
-
25
- === config/router.rb
26
-
27
- # This will add the following routes /login, /logout and /signup
28
- r.slice(:MerbAuth)
29
-
30
- # This will add the following routes /merb-auth/login, /merb-auth/logout and /merb-auth/signup
31
- r.add_slice(:MerbAuth)
32
-
33
- # This will add the following routes /user/login, /user/logout and /user/signup
34
- r.add_slice(:MerbAuth, 'user') # same as :path => 'user'
35
-
36
- === Normally you should also run the following rake task:
37
- > rake slices:merb_auth:install
38
-
39
- == Customization/Overrides
40
-
41
- By default, the user model class MerbAuth::User is aliased to User.
42
-
43
- You can also put your application-level overrides in:
44
-
45
- host-app/slices/merb-auth/app - controllers, models, views ...
46
-
47
- Templates are located in this order:
48
-
49
- 1. host-app/slices/merb-auth/app/views/*
50
- 2. gems/merb-auth/app/views/*
51
- 3. host-app/app/views/*
52
-
53
- You can use the host application's layout by configuring the
54
- merb-auth slice in a before_app_loads block:
55
-
56
- Merb::Slices.config[:merb_auth] = { :layout => :application }
57
-
58
- By default :merb_auth is used. If you need to override
59
- stylesheets or javascripts, just specify your own files in your layout
60
- instead/in addition to the ones supplied (if any) in
61
- host-app/public/slices/merb-auth.
62
-
63
- In any case don't edit those files directly as they may be clobbered any time
64
- rake merb_auth:install is run.