janus 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/README.rdoc +65 -29
  2. data/lib/janus.rb +1 -13
  3. data/lib/janus/config.rb +9 -5
  4. data/lib/janus/controllers/confirmations_controller.rb +2 -0
  5. data/lib/janus/controllers/helpers.rb +17 -0
  6. data/lib/janus/controllers/internal_helpers.rb +12 -0
  7. data/lib/janus/controllers/passwords_controller.rb +3 -0
  8. data/lib/janus/controllers/sessions_controller.rb +58 -21
  9. data/lib/janus/manager.rb +7 -2
  10. data/lib/janus/models/database_authenticatable.rb +22 -6
  11. data/lib/janus/rails.rb +17 -0
  12. data/lib/janus/routes.rb +1 -2
  13. data/lib/janus/sinatra.rb +51 -0
  14. metadata +63 -169
  15. data/test/functional/home_controller_test.rb +0 -8
  16. data/test/functional/janus/mailer_test.rb +0 -14
  17. data/test/functional/janus/manager_test.rb +0 -94
  18. data/test/functional/users/confirmations_controller_test.rb +0 -59
  19. data/test/functional/users/passwords_controller_test.rb +0 -101
  20. data/test/functional/users/registrations_controller_test.rb +0 -112
  21. data/test/functional/users/sessions_controller_test.rb +0 -100
  22. data/test/functional/users_controller_test.rb +0 -22
  23. data/test/integration/users/rememberable_test.rb +0 -32
  24. data/test/integration/users/remote_test.rb +0 -72
  25. data/test/integration/users/sessions_test.rb +0 -18
  26. data/test/integration/users/trackable_test.rb +0 -22
  27. data/test/rails_app/app/controllers/application_controller.rb +0 -9
  28. data/test/rails_app/app/controllers/blogs_controller.rb +0 -6
  29. data/test/rails_app/app/controllers/home_controller.rb +0 -4
  30. data/test/rails_app/app/controllers/users/confirmations_controller.rb +0 -3
  31. data/test/rails_app/app/controllers/users/passwords_controller.rb +0 -3
  32. data/test/rails_app/app/controllers/users/registrations_controller.rb +0 -7
  33. data/test/rails_app/app/controllers/users/sessions_controller.rb +0 -11
  34. data/test/rails_app/app/controllers/users_controller.rb +0 -9
  35. data/test/rails_app/app/helpers/application_helper.rb +0 -2
  36. data/test/rails_app/app/mailers/janus_mailer.rb +0 -2
  37. data/test/rails_app/app/models/remote_token.rb +0 -6
  38. data/test/rails_app/app/models/user.rb +0 -8
  39. data/test/rails_app/config/application.rb +0 -42
  40. data/test/rails_app/config/boot.rb +0 -6
  41. data/test/rails_app/config/environment.rb +0 -5
  42. data/test/rails_app/config/environments/development.rb +0 -26
  43. data/test/rails_app/config/environments/production.rb +0 -49
  44. data/test/rails_app/config/environments/test.rb +0 -36
  45. data/test/rails_app/config/initializers/janus.rb +0 -11
  46. data/test/rails_app/config/initializers/secret_token.rb +0 -7
  47. data/test/rails_app/config/initializers/session_store.rb +0 -8
  48. data/test/rails_app/config/routes.rb +0 -12
  49. data/test/rails_app/db/migrate/20110323153820_create_users.rb +0 -34
  50. data/test/rails_app/db/migrate/20110331153546_create_remote_tokens.rb +0 -15
  51. data/test/rails_app/db/schema.rb +0 -45
  52. data/test/rails_app/db/seeds.rb +0 -7
  53. data/test/test_helper.rb +0 -103
  54. data/test/unit/confirmable_test.rb +0 -36
  55. data/test/unit/janus_test.rb +0 -27
  56. data/test/unit/rememberable_test.rb +0 -50
  57. data/test/unit/remote_authenticatable_test.rb +0 -37
  58. data/test/unit/remote_token_test.rb +0 -9
  59. data/test/unit/reset_password_test.rb +0 -45
  60. data/test/unit/trackable_test.rb +0 -21
  61. data/test/unit/user_test.rb +0 -60
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Users::SessionsTest < ActionDispatch::IntegrationTest
4
- fixtures :all
5
-
6
- test "sign in and out" do
7
- visit new_user_session_path
8
- fill_in 'user_email', :with => users(:julien).email
9
- fill_in 'user_password', :with => 'secret'
10
- find('input[name=commit]').click
11
-
12
- assert_equal user_path, page.current_path
13
- find('h1').has_content?('Welcome ' + users(:julien).email)
14
-
15
- visit destroy_user_session_path
16
- assert_equal root_path, page.current_path
17
- end
18
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Users::TrackableTest < ActionDispatch::IntegrationTest
4
- fixtures :all
5
-
6
- test "should track user" do
7
- current_sign_in_at = users(:julien).reload.current_sign_in_at
8
- sign_in users(:julien)
9
- assert_not_equal current_sign_in_at, users(:julien).reload.current_sign_in_at
10
- end
11
-
12
- test "remote authentication should not track user" do
13
- sign_in users(:julien)
14
-
15
- current_sign_in_at = users(:julien).reload.current_sign_in_at
16
-
17
- visit root_url(:host => 'test.host')
18
- click_link 'sign_in'
19
-
20
- assert_equal current_sign_in_at, users(:julien).reload.current_sign_in_at
21
- end
22
- end
@@ -1,9 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
-
4
- helper_method :main_site_host
5
-
6
- def main_site_host
7
- 'www.example.com'
8
- end
9
- end
@@ -1,6 +0,0 @@
1
- class BlogsController < ApplicationController
2
- respond_to :html
3
-
4
- def show
5
- end
6
- end
@@ -1,4 +0,0 @@
1
- class HomeController < ApplicationController
2
- def index
3
- end
4
- end
@@ -1,3 +0,0 @@
1
- class Users::ConfirmationsController < Janus::ConfirmationsController
2
- respond_to :html
3
- end
@@ -1,3 +0,0 @@
1
- class Users::PasswordsController < Janus::PasswordsController
2
- respond_to :html
3
- end
@@ -1,7 +0,0 @@
1
- class Users::RegistrationsController < Janus::RegistrationsController
2
- respond_to :html
3
-
4
- def after_sign_up_url(user)
5
- user_url
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- class Users::SessionsController < Janus::SessionsController
2
- respond_to :html
3
-
4
- def after_sign_in_url(user)
5
- user_url
6
- end
7
-
8
- def valid_remote_host?(host)
9
- ['www.example.com', 'test.host'].include?(host)
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- class UsersController < ApplicationController
2
- before_filter :authenticate_user!
3
-
4
- respond_to :html, :xml
5
-
6
- def show
7
- respond_with(current_user)
8
- end
9
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,2 +0,0 @@
1
- class JanusMailer < Janus::Mailer
2
- end
@@ -1,6 +0,0 @@
1
- class RemoteToken < ActiveRecord::Base
2
- include Janus::Models::RemoteToken
3
-
4
- belongs_to :user
5
- validates_presence_of :user
6
- end
@@ -1,8 +0,0 @@
1
- class User < ActiveRecord::Base
2
- include Janus::Models::Base
3
- include Janus::Models::DatabaseAuthenticatable
4
- include Janus::Models::Confirmable
5
- include Janus::Models::Rememberable
6
- include Janus::Models::RemoteAuthenticatable
7
- include Janus::Models::Trackable
8
- end
@@ -1,42 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require "rails/all"
4
-
5
- # If you have a Gemfile, require the gems listed there, including any gems
6
- # you've limited to :test, :development, or :production.
7
- Bundler.require(:default, Rails.env) if defined?(Bundler)
8
-
9
- module RailsApp
10
- class Application < Rails::Application
11
- # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
14
-
15
- # Custom directories with classes and modules you want to be autoloadable.
16
- # config.autoload_paths += %W(#{config.root}/extras)
17
-
18
- # Only load the plugins named here, in the order given (default is alphabetical).
19
- # :all can be used as a placeholder for all plugins not explicitly named.
20
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
-
22
- # Activate observers that should always be running.
23
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
-
25
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
- # config.time_zone = 'Central Time (US & Canada)'
28
-
29
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
- # config.i18n.default_locale = :de
32
-
33
- # JavaScript files you want as :defaults (application.js is always included).
34
- # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
-
36
- # Configure the default encoding used in templates for Ruby 1.9.
37
- config.encoding = "utf-8"
38
-
39
- # Configure sensitive parameters which will be filtered from the log file.
40
- config.filter_parameters += [:password]
41
- end
42
- end
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
-
3
- # Set up gems listed in the Gemfile.
4
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
-
6
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- RailsApp::Application.initialize!
@@ -1,26 +0,0 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the webserver when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
15
- config.action_controller.perform_caching = false
16
-
17
- # Don't care if the mailer can't send
18
- config.action_mailer.raise_delivery_errors = false
19
-
20
- # Print deprecation notices to the Rails logger
21
- config.active_support.deprecation = :log
22
-
23
- # Only use best-standards-support built into browsers
24
- config.action_dispatch.best_standards_support = :builtin
25
- end
26
-
@@ -1,49 +0,0 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The production environment is meant for finished, "live" apps.
5
- # Code is not reloaded between requests
6
- config.cache_classes = true
7
-
8
- # Full error reports are disabled and caching is turned on
9
- config.consider_all_requests_local = false
10
- config.action_controller.perform_caching = true
11
-
12
- # Specifies the header that your server uses for sending files
13
- config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
-
15
- # For nginx:
16
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
-
18
- # If you have no front-end server that supports something like X-Sendfile,
19
- # just comment this out and Rails will serve the files
20
-
21
- # See everything in the log (default is :info)
22
- # config.log_level = :debug
23
-
24
- # Use a different logger for distributed setups
25
- # config.logger = SyslogLogger.new
26
-
27
- # Use a different cache store in production
28
- # config.cache_store = :mem_cache_store
29
-
30
- # Disable Rails's static asset server
31
- # In production, Apache or nginx will already do this
32
- config.serve_static_assets = false
33
-
34
- # Enable serving of images, stylesheets, and javascripts from an asset server
35
- # config.action_controller.asset_host = "http://assets.example.com"
36
-
37
- # Disable delivery errors, bad email addresses will be ignored
38
- # config.action_mailer.raise_delivery_errors = false
39
-
40
- # Enable threaded mode
41
- # config.threadsafe!
42
-
43
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
- # the I18n.default_locale when a translation can not be found)
45
- config.i18n.fallbacks = true
46
-
47
- # Send deprecation notices to registered listeners
48
- config.active_support.deprecation = :notify
49
- end
@@ -1,36 +0,0 @@
1
- RailsApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
12
-
13
- # Show full error reports and disable caching
14
- config.consider_all_requests_local = true
15
- config.action_controller.perform_caching = false
16
-
17
- # Raise exceptions instead of rendering exception templates
18
- config.action_dispatch.show_exceptions = false
19
-
20
- # Disable request forgery protection in test environment
21
- config.action_controller.allow_forgery_protection = false
22
-
23
- # Tell Action Mailer not to deliver emails to the real world.
24
- # The :test delivery method accumulates sent emails in the
25
- # ActionMailer::Base.deliveries array.
26
- config.action_mailer.delivery_method = :test
27
- config.action_mailer.default_url_options = { :host => 'www.example.com' }
28
-
29
- # Use SQL instead of Active Record's schema dumper when creating the test database.
30
- # This is necessary if your schema can't be completely dumped by the schema dumper,
31
- # like if you have constraints or database-specific column types
32
- # config.active_record.schema_format = :sql
33
-
34
- # Print deprecation notices to the stderr
35
- config.active_support.deprecation = :stderr
36
- end
@@ -1,11 +0,0 @@
1
- Janus.config do |config|
2
- config.contact_email = "contact@example.com"
3
-
4
- # DatabaseAuthenticatable
5
- config.authentication_keys = [:email]
6
- config.stretches = 10
7
- config.pepper = "db5ef161873f4b4cd966ff042c448282e8243a0a4e090347370360796ecc769f384d898badda1881bc7ed4483f20f6809b39a54f6671cc35cda18bfe554cd8e0"
8
-
9
- # RemoteAuthenticatable
10
- # ...
11
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- RailsApp::Application.config.secret_token = 'c6a67697877c66be70cdcc4680f37593045a721cf757de4110f9749877cb32f94fe4ddaa5e816af4555d91c4f6142a401972474d50fe620d41ede300d3143d4a'
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- RailsApp::Application.config.session_store :cookie_store, :key => '_rails_app_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # RailsApp::Application.config.session_store :active_record_store
@@ -1,12 +0,0 @@
1
- RailsApp::Application.routes.draw do
2
- janus :users,
3
- :session => true,
4
- :registration => true,
5
- :confirmation => true,
6
- :password => true
7
-
8
- resource :user, :only => :show
9
- resource :blog, :only => :show
10
-
11
- root :to => 'home#index'
12
- end
@@ -1,34 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def self.up
3
- create_table :users do |t|
4
- t.string :email
5
- t.string :encrypted_password
6
-
7
- t.string :reset_password_token
8
- t.datetime :reset_password_sent_at
9
-
10
- t.string :remember_token
11
- t.datetime :remember_created_at
12
-
13
- t.string :confirmation_token
14
- t.datetime :confirmation_sent_at
15
- t.datetime :confirmed_at
16
-
17
- t.string :session_token
18
-
19
- t.integer :sign_in_count, :default => 0
20
- t.string :last_sign_in_at
21
- t.string :last_sign_in_ip
22
- t.string :current_sign_in_at
23
- t.string :current_sign_in_ip
24
- end
25
-
26
- add_index :users, :email, :unique => true
27
- add_index :users, :remember_token, :unique => true
28
- add_index :users, :reset_password_token, :unique => true
29
- end
30
-
31
- def self.down
32
- drop_table :users
33
- end
34
- end
@@ -1,15 +0,0 @@
1
- class CreateRemoteTokens < ActiveRecord::Migration
2
- def self.up
3
- create_table :remote_tokens do |t|
4
- t.references :user
5
- t.string :token
6
- t.datetime :created_at
7
- end
8
-
9
- add_index :remote_tokens, :token, :unique => true
10
- end
11
-
12
- def self.down
13
- drop_table :remote_tokens
14
- end
15
- end
@@ -1,45 +0,0 @@
1
- # This file is auto-generated from the current state of the database. Instead
2
- # of editing this file, please use the migrations feature of Active Record to
3
- # incrementally modify your database, and then regenerate this schema definition.
4
- #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
10
- #
11
- # It's strongly recommended to check this file into your version control system.
12
-
13
- ActiveRecord::Schema.define(:version => 20110331153546) do
14
-
15
- create_table "remote_tokens", :force => true do |t|
16
- t.integer "user_id"
17
- t.string "token"
18
- t.datetime "created_at"
19
- end
20
-
21
- add_index "remote_tokens", ["token"], :name => "index_remote_tokens_on_token", :unique => true
22
-
23
- create_table "users", :force => true do |t|
24
- t.string "email"
25
- t.string "encrypted_password"
26
- t.string "reset_password_token"
27
- t.datetime "reset_password_sent_at"
28
- t.string "remember_token"
29
- t.datetime "remember_created_at"
30
- t.string "confirmation_token"
31
- t.datetime "confirmation_sent_at"
32
- t.datetime "confirmed_at"
33
- t.string "session_token"
34
- t.integer "sign_in_count", :default => 0
35
- t.string "last_sign_in_at"
36
- t.string "last_sign_in_ip"
37
- t.string "current_sign_in_at"
38
- t.string "current_sign_in_ip"
39
- end
40
-
41
- add_index "users", ["email"], :name => "index_users_on_email", :unique => true
42
- add_index "users", ["remember_token"], :name => "index_users_on_remember_token", :unique => true
43
- add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
44
-
45
- end