static_auth 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +42 -0
- data/README.rdoc +13 -7
- data/Rakefile +3 -29
- data/lib/static_auth/railtie.rb +1 -1
- data/lib/static_auth/session.rb +6 -8
- data/lib/static_auth/version.rb +3 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/{simple-auth/simple-auth_spec.rb → static_auth/static_auth_spec.rb} +1 -1
- data/static_auth.gemspec +23 -0
- metadata +49 -25
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
static_auth (0.0.4)
|
5
|
+
activerecord (~> 3.0.0)
|
6
|
+
activesupport (~> 3.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (3.0.5)
|
12
|
+
activesupport (= 3.0.5)
|
13
|
+
builder (~> 2.1.2)
|
14
|
+
i18n (~> 0.4)
|
15
|
+
activerecord (3.0.5)
|
16
|
+
activemodel (= 3.0.5)
|
17
|
+
activesupport (= 3.0.5)
|
18
|
+
arel (~> 2.0.2)
|
19
|
+
tzinfo (~> 0.3.23)
|
20
|
+
activesupport (3.0.5)
|
21
|
+
arel (2.0.8)
|
22
|
+
builder (2.1.2)
|
23
|
+
diff-lcs (1.1.2)
|
24
|
+
i18n (0.5.0)
|
25
|
+
rspec (2.1.0)
|
26
|
+
rspec-core (~> 2.1.0)
|
27
|
+
rspec-expectations (~> 2.1.0)
|
28
|
+
rspec-mocks (~> 2.1.0)
|
29
|
+
rspec-core (2.1.0)
|
30
|
+
rspec-expectations (2.1.0)
|
31
|
+
diff-lcs (~> 1.1.2)
|
32
|
+
rspec-mocks (2.1.0)
|
33
|
+
sqlite3 (1.3.3)
|
34
|
+
tzinfo (0.3.24)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
rspec
|
41
|
+
sqlite3
|
42
|
+
static_auth!
|
data/README.rdoc
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
=
|
1
|
+
= Static Auth
|
2
2
|
|
3
3
|
Static authentication && authorization in rails
|
4
4
|
|
5
|
+
= Installation
|
6
|
+
|
7
|
+
Rails3 only Add the following line to your Gemfile:
|
8
|
+
|
9
|
+
gem 'static_auth'
|
10
|
+
|
5
11
|
= Example
|
6
12
|
|
7
13
|
models/admin_session.rb
|
8
14
|
|
9
|
-
class AdminSession <
|
15
|
+
class AdminSession < StaticAuth::Session
|
10
16
|
roles :admin, :manager
|
11
17
|
password_for :admin, "123456"
|
12
|
-
password_for :manager, proc {
|
18
|
+
password_for :manager, proc { "123456".reverse }
|
13
19
|
set_encryption_method :md5
|
14
20
|
end
|
15
21
|
|
@@ -45,18 +51,18 @@ Static authentication && authorization in rails
|
|
45
51
|
|
46
52
|
= Setting encryption method
|
47
53
|
|
48
|
-
class AdminSession <
|
54
|
+
class AdminSession < StaticAuth::Session
|
49
55
|
roles :admin, :manager
|
50
56
|
password_for :admin, "123456"
|
51
|
-
password_for :manager, proc {
|
57
|
+
password_for :manager, proc { "123456".reverse }
|
52
58
|
|
53
59
|
# It always receives a string
|
54
60
|
encryption_methods[:custom] = proc { |value| MD5::md5(value + "secret salt") }
|
55
61
|
|
56
|
-
set_encryption_method :custom # Default methods: :plain, :md5, :sha1
|
62
|
+
set_encryption_method :custom # Default methods: :plain, :md5, :sha1
|
57
63
|
end
|
58
64
|
|
59
65
|
= Todo
|
60
66
|
|
61
67
|
1. Salting
|
62
|
-
2.
|
68
|
+
2. BCrypt
|
data/Rakefile
CHANGED
@@ -2,35 +2,9 @@ require 'rake'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'rspec/core'
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'bundler'
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
5
8
|
|
6
9
|
RSpec::Core::RakeTask.new(:spec)
|
7
10
|
task :default => :spec
|
8
|
-
|
9
|
-
begin
|
10
|
-
include_files = ["README*", "LICENSE", "Rakefile", "init.rb", "{lib,spec}/**/*"].map do |glob|
|
11
|
-
Dir[glob]
|
12
|
-
end.flatten
|
13
|
-
|
14
|
-
require "jeweler"
|
15
|
-
Jeweler::Tasks.new do |s|
|
16
|
-
s.name = "static_auth"
|
17
|
-
s.version = "0.0.3"
|
18
|
-
s.author = "Victor Sokolov"
|
19
|
-
s.email = "gzigzigzeo@gmail.com"
|
20
|
-
s.homepage = "http://github.com/gzigzigzeo/simple-auth"
|
21
|
-
s.description = "Static authentication && authorization in rails"
|
22
|
-
s.summary = "Static authentication && authorization in rails. Supports roles and static passwords."
|
23
|
-
s.platform = Gem::Platform::RUBY
|
24
|
-
s.files = include_files
|
25
|
-
s.require_path = "lib"
|
26
|
-
s.has_rdoc = false
|
27
|
-
|
28
|
-
s.add_dependency 'activemodel', '> 3'
|
29
|
-
s.add_dependency 'activesupport', '> 3'
|
30
|
-
s.add_dependency 'bcrypt-ruby'
|
31
|
-
end
|
32
|
-
|
33
|
-
Jeweler::GemcutterTasks.new
|
34
|
-
rescue LoadError
|
35
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
36
|
-
end
|
data/lib/static_auth/railtie.rb
CHANGED
data/lib/static_auth/session.rb
CHANGED
@@ -4,11 +4,10 @@ require 'active_support/core_ext/class/inheritable_attributes'
|
|
4
4
|
require 'active_model/conversion'
|
5
5
|
require 'active_model/naming'
|
6
6
|
require 'active_model/attribute_methods'
|
7
|
-
require 'sha1'
|
8
|
-
require 'md5'
|
9
|
-
require 'bcrypt'
|
7
|
+
require 'digest/sha1'
|
8
|
+
require 'digest/md5'
|
10
9
|
|
11
|
-
module
|
10
|
+
module StaticAuth
|
12
11
|
class Session
|
13
12
|
include ActiveModel::Conversion
|
14
13
|
include ActiveModel::AttributeMethods
|
@@ -19,9 +18,8 @@ module SimpleAuth
|
|
19
18
|
class_inheritable_accessor :encryption_methods
|
20
19
|
self.encryption_methods = {
|
21
20
|
:plain => proc { |value| value.reverse },
|
22
|
-
:sha1 => proc { |value| SHA1
|
23
|
-
:md5 => proc { |value| MD5
|
24
|
-
:bcrypt => proc { |value| BCrypt::Password.new(value, :cost => 10).to_s }
|
21
|
+
:sha1 => proc { |value| Digest::SHA1.hexdigest(value).to_s },
|
22
|
+
:md5 => proc { |value| Digest::MD5.hexdigest(value).to_s }
|
25
23
|
}
|
26
24
|
|
27
25
|
attr_accessor :role, :password
|
@@ -113,7 +111,7 @@ module SimpleAuth
|
|
113
111
|
self.defined_passwords = {}
|
114
112
|
|
115
113
|
class_inheritable_accessor :session_key
|
116
|
-
self.session_key = "
|
114
|
+
self.session_key = "STATIC_AUTH"
|
117
115
|
|
118
116
|
class_inheritable_accessor :encryption_method
|
119
117
|
self.encryption_method = :plain
|
data/spec/spec_helper.rb
CHANGED
@@ -12,7 +12,7 @@ Bundler.require
|
|
12
12
|
|
13
13
|
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
14
14
|
|
15
|
-
class AdminSession <
|
15
|
+
class AdminSession < StaticAuth::Session
|
16
16
|
roles :admin, :manager
|
17
17
|
password_for :admin, "123456"
|
18
18
|
password_for :manager, proc { encrypt("123456") }
|
data/static_auth.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "lib/static_auth/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "static_auth"
|
5
|
+
s.version = StaticAuth::VERSION
|
6
|
+
s.author = "Victor Sokolov"
|
7
|
+
s.email = "gzigzigzeo@gmail.com"
|
8
|
+
s.homepage = "http://github.com/gzigzigzeo/static_auth"
|
9
|
+
s.description = "Static authentication && authorization in rails."
|
10
|
+
s.summary = "Static authentication && authorization in rails."
|
11
|
+
|
12
|
+
s.rubyforge_project = "static_auth"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency 'activerecord', '~> 3.0.0'
|
20
|
+
s.add_dependency 'activesupport', '~> 3.0.0'
|
21
|
+
s.add_development_dependency 'sqlite3'
|
22
|
+
s.add_development_dependency 'rspec'
|
23
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Victor Sokolov
|
@@ -15,21 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-03-02 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: activerecord
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 7
|
30
30
|
segments:
|
31
31
|
- 3
|
32
|
-
|
32
|
+
- 0
|
33
|
+
- 0
|
34
|
+
version: 3.0.0
|
33
35
|
type: :runtime
|
34
36
|
version_requirements: *id001
|
35
37
|
- !ruby/object:Gem::Dependency
|
@@ -38,16 +40,18 @@ dependencies:
|
|
38
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
41
|
none: false
|
40
42
|
requirements:
|
41
|
-
- -
|
43
|
+
- - ~>
|
42
44
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
45
|
+
hash: 7
|
44
46
|
segments:
|
45
47
|
- 3
|
46
|
-
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
version: 3.0.0
|
47
51
|
type: :runtime
|
48
52
|
version_requirements: *id002
|
49
53
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
54
|
+
name: sqlite3
|
51
55
|
prerelease: false
|
52
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
53
57
|
none: false
|
@@ -58,31 +62,51 @@ dependencies:
|
|
58
62
|
segments:
|
59
63
|
- 0
|
60
64
|
version: "0"
|
61
|
-
type: :
|
65
|
+
type: :development
|
62
66
|
version_requirements: *id003
|
63
|
-
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
type: :development
|
80
|
+
version_requirements: *id004
|
81
|
+
description: Static authentication && authorization in rails.
|
64
82
|
email: gzigzigzeo@gmail.com
|
65
83
|
executables: []
|
66
84
|
|
67
85
|
extensions: []
|
68
86
|
|
69
|
-
extra_rdoc_files:
|
70
|
-
|
87
|
+
extra_rdoc_files: []
|
88
|
+
|
71
89
|
files:
|
90
|
+
- .gitignore
|
91
|
+
- .rspec
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
72
94
|
- README.rdoc
|
73
95
|
- Rakefile
|
74
96
|
- lib/static_auth.rb
|
75
97
|
- lib/static_auth/railtie.rb
|
76
98
|
- lib/static_auth/session.rb
|
77
|
-
-
|
99
|
+
- lib/static_auth/version.rb
|
78
100
|
- spec/spec_helper.rb
|
101
|
+
- spec/static_auth/static_auth_spec.rb
|
102
|
+
- static_auth.gemspec
|
79
103
|
has_rdoc: true
|
80
|
-
homepage: http://github.com/gzigzigzeo/
|
104
|
+
homepage: http://github.com/gzigzigzeo/static_auth
|
81
105
|
licenses: []
|
82
106
|
|
83
107
|
post_install_message:
|
84
|
-
rdoc_options:
|
85
|
-
|
108
|
+
rdoc_options: []
|
109
|
+
|
86
110
|
require_paths:
|
87
111
|
- lib
|
88
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -105,11 +129,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
129
|
version: "0"
|
106
130
|
requirements: []
|
107
131
|
|
108
|
-
rubyforge_project:
|
109
|
-
rubygems_version: 1.
|
132
|
+
rubyforge_project: static_auth
|
133
|
+
rubygems_version: 1.6.0
|
110
134
|
signing_key:
|
111
135
|
specification_version: 3
|
112
|
-
summary: Static authentication && authorization in rails.
|
136
|
+
summary: Static authentication && authorization in rails.
|
113
137
|
test_files:
|
114
|
-
- spec/simple-auth/simple-auth_spec.rb
|
115
138
|
- spec/spec_helper.rb
|
139
|
+
- spec/static_auth/static_auth_spec.rb
|