forked from wycats/merb-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of [email protected]:wycats/merb-plugins
- Loading branch information
Showing
161 changed files
with
6,616 additions
and
4,662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
$TESTING = true | ||
$:.push File.join(File.dirname(__FILE__), '..', 'lib') | ||
require 'merb-core' | ||
require 'merb_activerecord' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
log/* | ||
*.log | ||
db/ | ||
*.db | ||
.DStore | ||
.DS_Store | ||
pkg | ||
pkg/* | ||
:memory: | ||
examples/example_app/config/open_id | ||
merb-auth-core/coverage | ||
examples/example_app/tmp | ||
merb-auth-core/log | ||
merb-auth-more/log | ||
merb-auth-more/coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
h1. MerbAuth - Merb Authentication | ||
|
||
h2. An extensible architecture for authentication | ||
|
||
* Stupidly Simple | ||
* Speaks fluent HTTP, even the errors | ||
* Pluggable Architecture (so that you can use any authentication algorithms you like) | ||
* Cascading Authentication (if one method fails, another is attempted, then another. When no methods succeed, authentication fails) | ||
|
||
h2. Principles | ||
|
||
# Sessions are authenticated, not users. | ||
# 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. | ||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
require 'rubygems' | ||
Gem.clear_paths | ||
Gem.path.unshift(File.join(File.dirname(__FILE__), "gems")) | ||
|
||
require 'rake' | ||
require 'rake/rdoctask' | ||
require 'rake/testtask' | ||
require 'spec/rake/spectask' | ||
require 'fileutils' | ||
|
||
## | ||
# requires frozen merb-core (from /framework) | ||
# adds the other components to the load path | ||
def require_frozen_framework | ||
framework = File.join(File.dirname(__FILE__), "framework") | ||
if File.directory?(framework) | ||
puts "Running from frozen framework" | ||
core = File.join(framework,"merb-core") | ||
if File.directory?(core) | ||
puts "using merb-core from #{core}" | ||
$:.unshift File.join(core,"lib") | ||
require 'merb-core' | ||
end | ||
more = File.join(framework,"merb-more") | ||
if File.directory?(more) | ||
Dir.new(more).select {|d| d =~ /merb-/}.each do |d| | ||
$:.unshift File.join(more,d,'lib') | ||
end | ||
end | ||
plugins = File.join(framework,"merb-plugins") | ||
if File.directory?(plugins) | ||
Dir.new(plugins).select {|d| d =~ /merb_/}.each do |d| | ||
$:.unshift File.join(plugins,d,'lib') | ||
end | ||
end | ||
require "merb-core/core_ext/kernel" | ||
require "merb-core/core_ext/rubygems" | ||
else | ||
p "merb doesn't seem to be frozen in /framework" | ||
require 'merb-core' | ||
end | ||
end | ||
|
||
if ENV['FROZEN'] | ||
require_frozen_framework | ||
else | ||
require 'merb-core' | ||
end | ||
|
||
require 'merb-core/tasks/merb' | ||
include FileUtils | ||
|
||
# Load the basic runtime dependencies; this will include | ||
# any plugins and therefore plugin rake tasks. | ||
init_env = ENV['MERB_ENV'] || 'rake' | ||
Merb.load_dependencies(:environment => init_env) | ||
|
||
# Get Merb plugins and dependencies | ||
Merb::Plugins.rakefiles.each { |r| require r } | ||
|
||
# Load any app level custom rakefile extensions from lib/tasks | ||
tasks_path = File.join(File.dirname(__FILE__), "lib", "tasks") | ||
rake_files = Dir["#{tasks_path}/*.rake"] | ||
rake_files.each{|rake_file| load rake_file } | ||
|
||
|
||
desc "start runner environment" | ||
task :merb_env do | ||
Merb.start_environment(:environment => init_env, :adapter => 'runner') | ||
end | ||
|
||
############################################################################## | ||
# ADD YOUR CUSTOM TASKS IN /lib/tasks | ||
# NAME YOUR RAKE FILES file_name.rake | ||
############################################################################## |
2 changes: 2 additions & 0 deletions
2
merb_auth/examples/example_app/app/controllers/application.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Application < Merb::Controller | ||
end |
13 changes: 13 additions & 0 deletions
13
merb_auth/examples/example_app/app/controllers/exceptions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Exceptions < Application | ||
|
||
# handle NotFound exceptions (404) | ||
def not_found | ||
render :format => :html | ||
end | ||
|
||
# handle NotAcceptable exceptions (406) | ||
def not_acceptable | ||
render :format => :html | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Welcome < Application | ||
before :ensure_authenticated | ||
|
||
def index | ||
"We're In #{request.full_uri}" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Merb | ||
module GlobalHelpers | ||
# helpers defined here available to all views. | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
class User | ||
include DataMapper::Resource | ||
|
||
property :id, Serial | ||
property :login, String | ||
property :email, String | ||
property :crypted_password, String, :length => 150 | ||
property :salt, String, :length => 150 | ||
property :active, Boolean, :default => false | ||
property :identity_url, String | ||
|
||
validates_present :login, :email | ||
validates_is_unique :login, :email | ||
validates_format :email, :as => :email_address | ||
|
||
attr_accessor :password, :password_confirmation | ||
validates_is_confirmed :password | ||
|
||
before :save, :encrypt_password | ||
|
||
def active? | ||
!!self.active | ||
end | ||
|
||
def self.encrypt(salt, password = nil) | ||
Digest::SHA1.hexdigest("--#{salt}--#{password}--") | ||
end | ||
|
||
def self.authenticate(login, password) | ||
u = self.first(:login => login) | ||
return nil unless u | ||
u.crypted_password == encrypt(u.salt, password) ? u : nil | ||
end | ||
|
||
def encrypt_password | ||
self.salt ||= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") | ||
self.crypted_password ||= User.encrypt(salt, password) | ||
end | ||
|
||
end |
Oops, something went wrong.