sixarm_ruby_sign_in 1.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f659858417539c4678e22ecba4172b21bbd4a0a
4
+ data.tar.gz: bd618ffe352b1a7629ae0c668e56c2f5ee242d61
5
+ SHA512:
6
+ metadata.gz: 52cf29c31bf1418d9bf6e83eb8e483264d65cf1d3cc438477d3b8fbcb3bc0ea3e9e98cc71923d2a8911f06c4596fd618d2c72314cf3b1401d490b985232aa7b9
7
+ data.tar.gz: 96807e46ca5cdafd51bd7e40e9ac5efe8e47fee4530163d8ae5b78b3473f3ebeb57245a43345d08a0e92f629dbd3df6c22882a5b03ba0438cff2fba5c2effb17
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/.gemtest ADDED
File without changes
data/CHANGES.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changes
2
+
3
+ * 2015-07-07 1.1.6 Update gemspec to use file manifest
4
+ * 2012-03-14 1.1.5 Update docs, tests
5
+ * 2010-10-02 1.1.4 Update for Ruby 1.9
data/LICENSE.md ADDED
@@ -0,0 +1,28 @@
1
+ # License
2
+
3
+ You may choose any of these open source licenses:
4
+
5
+ * Apache License
6
+ * BSD License
7
+ * CreativeCommons License, Non-commercial Share Alike
8
+ * GNU Affero General Public License (AGPL)
9
+ * GNU General Public License Version (GPL)
10
+ * GNU Lesser General Public License (LGPL)
11
+ * MIT License
12
+ * Perl Artistic License
13
+ * Ruby License
14
+
15
+ The software is provided "as is", without warranty of any kind,
16
+ express or implied, including but not limited to the warranties of
17
+ merchantability, fitness for a particular purpose and noninfringement.
18
+
19
+ In no event shall the authors or copyright holders be liable for any
20
+ claim, damages or other liability, whether in an action of contract,
21
+ tort or otherwise, arising from, out of or in connection with the
22
+ software or the use or other dealings in the software.
23
+
24
+ This license is for the included software that is created by SixArm.
25
+ Some of the included software may have its own licenses, copyrights,
26
+ authors, etc. and these may take precedence over the SixArm license.
27
+
28
+ Copyright (c) Joel Parker Henderson
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # Ruby » <br> SignIn interface for typical Rails user sign in
2
+
3
+ * Doc: <http://sixarm.com/sixarm_ruby_sign_in/doc>
4
+ * Gem: <http://rubygems.org/gems/sixarm_ruby_sign_in>
5
+ * Repo: <http://github.com/sixarm/sixarm_ruby_sign_in>
6
+ * Email: Joel Parker Henderson, <joel@sixarm.com>
7
+
8
+
9
+ ## Introduction
10
+
11
+ Sign In simple abstract framework.
12
+
13
+ You can include this module in your application controller,
14
+ then your controller can define any of these concrete methods.
15
+
16
+ For docs go to <http://sixarm.com/sixarm_ruby_sign_in/doc>
17
+
18
+ Want to help? We're happy to get pull requests.
19
+
20
+
21
+ ## Install quickstart
22
+
23
+ Install:
24
+
25
+ gem install sixarm_ruby_sign_in
26
+
27
+ Bundler:
28
+
29
+ gem "sixarm_ruby_sign_in", "~>1.1.4"
30
+
31
+ Require:
32
+
33
+ require "sixarm_ruby_sign_in"
34
+
35
+
36
+ ## Install with security (optional)
37
+
38
+ To enable high security for all our gems:
39
+
40
+ wget http://sixarm.com/sixarm.pem
41
+ gem cert --add sixarm.pem
42
+ gem sources --add http://sixarm.com
43
+
44
+ To install with high security:
45
+
46
+ gem install sixarm_ruby_sign_in --trust-policy HighSecurity
47
+
48
+
49
+ ## Details
50
+
51
+ This provides one top-level method:
52
+
53
+ sign_in(options=nil) => true for success, false for failure
54
+
55
+ The top level method will call mid-level methods
56
+ that you will define in your own controller.
57
+
58
+ sign_in calls:
59
+
60
+ sign_in_attempt(options=nil), e.g. authenticate and set current user
61
+ sign_in_success(options=nil), e.g. redirect to a welcome page
62
+ sign_in_failure(options=nil), e.g. flash notice help messesage
63
+
64
+
65
+ ## AuthLogic Example
66
+
67
+ AuthLogic provides this example:
68
+
69
+ def create
70
+ # sign in attempt
71
+ @user_session = UserSession.new(params[:user_session])
72
+ if @user_session.save
73
+ # sign in success
74
+ redirect_to account_url
75
+ else
76
+ # sign in failure
77
+ render :action => :new
78
+ end
79
+ end
80
+
81
+ AuthLogic example refactored for improved security and structure:
82
+
83
+ def sign_in_attempt
84
+ @user_session = UserSession.new(params[:user_session])
85
+ @user_session.save
86
+ end
87
+
88
+ def sign_in_success
89
+ redirect_to account_url
90
+ end
91
+
92
+ def sign_in_failure
93
+ render :action => :new
94
+ end
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "rake"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'lib' << 'test'
7
+ t.pattern = 'test/*.rb'
8
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.4
@@ -0,0 +1,65 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin rdoc
3
+ Please see README
4
+ =end
5
+
6
+
7
+ module SignIn
8
+
9
+
10
+ # The sign_in method calls:
11
+ # - sign_in_attempt
12
+ # - sign_in_success (if sign_in_attempt returns true)
13
+ # - sign_in_failure (if sign_in_attempt returns false or raises a SecurityError)
14
+
15
+ def sign_in(options=nil)
16
+ begin
17
+ sign_in_attempt(options) or raise SecurityError
18
+ sign_in_success(options)
19
+ return true
20
+ rescue SecurityError
21
+ sign_in_failure(options)
22
+ return false
23
+ end
24
+ end
25
+
26
+
27
+ # The sign_in method calls this first.
28
+ #
29
+ # You override this method to e.g.:
30
+ # - get a username and password from params
31
+ # - find the user by username in the user model
32
+ # - authenticate the user by verifying the password
33
+ #
34
+ # If this method succeeds, then control goes to sign_in_success.
35
+ #
36
+ # If this method raises an error, then control goes to sign_in_failure.
37
+
38
+ def sign_in_attempt(options=nil)
39
+ end
40
+
41
+
42
+ # The sign_in method calls this second,
43
+ # iff sign_in_attempt succeeds.
44
+ #
45
+ # You override this method to e.g.:
46
+ # - show the user a flash notice message saying "Welcome..."
47
+ # - redirect to the user's home page
48
+ # - customize views based on the user's info
49
+
50
+ def sign_in_success(options=nil)
51
+ end
52
+
53
+
54
+ # The sign_in method calls this second,
55
+ # iff sign_in_attempt raises an exception.
56
+ #
57
+ # You override this method to e.g.:
58
+ # - show the user a flash warning message saying "Sorry..."
59
+ # - redirect to a help page
60
+ # - log the attempt and possibly see if it's a hacker
61
+
62
+ def sign_in_failure(options=nil)
63
+ end
64
+
65
+ end
@@ -0,0 +1,52 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "minitest/autorun"
3
+ require "simplecov"
4
+ SimpleCov.start
5
+ require "sixarm_ruby_sign_in"
6
+
7
+ class SignInTest < Test::Unit::TestCase
8
+
9
+ include SignIn
10
+
11
+ RIGHT=:foo
12
+ WRONG=:bar
13
+
14
+ def setup
15
+ @sign_in_attempt_seen=nil
16
+ @sign_in_success_seen=nil
17
+ @sign_in_failure_seen=nil
18
+ end
19
+
20
+ def test_sign_in_right
21
+ user=RIGHT
22
+ x=sign_in(user)
23
+ assert( @sign_in_attempt_seen,"sign_in_attempt_seen user:#{user}")
24
+ assert( @sign_in_success_seen,"sign_in_success_seen user:#{user}")
25
+ assert(!@sign_in_failure_seen,"sign_in_failure_seen user:#{user}")
26
+ assert_equal(true,x,"sign_in x:#{x}")
27
+ end
28
+
29
+ def test_sign_in_wrong
30
+ user=WRONG
31
+ x=sign_in(user)
32
+ assert( @sign_in_attempt_seen,"sign_in_attempt seen user:#{user}")
33
+ assert(!@sign_in_success_seen,"sign_in_success_seen user:#{user}")
34
+ assert( @sign_in_failure_seen,"sign_in_failure_seen user:#{user}")
35
+ assert_equal(false,x,"sign_in user:#{x}")
36
+ end
37
+
38
+ def sign_in_attempt(options=nil)
39
+ @sign_in_attempt_seen=true
40
+ if options==WRONG then raise SecurityError end
41
+ return options==RIGHT
42
+ end
43
+
44
+ def sign_in_success(options=nil)
45
+ @sign_in_success_seen=true
46
+ end
47
+
48
+ def sign_in_failure(options=nil)
49
+ @sign_in_failure_seen=true
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sixarm_ruby_sign_in
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.6
5
+ platform: ruby
6
+ authors:
7
+ - SixArm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIGCTCCA/GgAwIBAgIJAK3igyLv2hNNMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
14
+ BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
15
+ c2NvMQ8wDQYDVQQKEwZTaXhBcm0xEzARBgNVBAMTCnNpeGFybS5jb20wHhcNMTUw
16
+ MzE0MjA0MTE5WhcNMTcxMjA4MjA0MTE5WjBgMQswCQYDVQQGEwJVUzETMBEGA1UE
17
+ CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEPMA0GA1UEChMG
18
+ U2l4QXJtMRMwEQYDVQQDEwpzaXhhcm0uY29tMIICIjANBgkqhkiG9w0BAQEFAAOC
19
+ Ag8AMIICCgKCAgEA4et7SlePzuE46eK5BAVVGg+yWt6FkX7xcLt3Uun9RntKPSuR
20
+ TbS/+KBqbja5reZD64hdQ9npxpQPKafxUm+RlCd9F5KFxwi8G9usKzCTPOwUeDI2
21
+ TNEfC+1eRU19QuEW58ZC0pC/bx5Zmp6/DTD6VV+qxKEE9U1M5P85LNkwnxqmRIMR
22
+ AN8VKOG+GRGOMNDGZ8Kp4h5V3Wyu0N7anY8AUveIx1SyLrEbAhcWp1asLs+/H22q
23
+ 92YFgnwTtnDpZsAmNgZrVw9xY0v79BXqPoyKIl2psPfZi2mOIWi/N+cx6LGF1G+B
24
+ b+NZdAgwuLyFOoVknkTqsuYEsFhxz0dqDUgM/RvGrADxZk6yUD/1lBNTWnIDVKaN
25
+ Onu08gOb1lfn21Sbd5r/K32hngasiEuDvh61pJVwszBuFv3v++hVlvNzHw9oT7wc
26
+ W0z258Qw6fkPh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gYjiVGdSq+8wQv
42
+ Efa5jhe8QwG7R1rdpMMP5yBSAqWuFBczMveX5j4rp9Ifw5/XsZbgwcmdm26bjhzh
43
+ w2grAHIhvR9mztm6uXQlZhv1fu3P+RWHDSYhnZSCJSCdxPzQJ1mG5T5ahiL3HvCZ
44
+ 2AC9FOGkybW6DJEFSFFMlNk0IILsa/gNp8ufGuTVLWF9FUUdMNK+TMbghnifT8/1
45
+ n+ES/gQPOnvmVkLDGw==
46
+ -----END CERTIFICATE-----
47
+ date: 2015-07-08 00:00:00.000000000 Z
48
+ dependencies: []
49
+ description: Sign In abstraction for a typical web app user
50
+ email: sixarm@sixarm.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - ".gemtest"
56
+ - CHANGES.md
57
+ - LICENSE.md
58
+ - README.md
59
+ - Rakefile
60
+ - VERSION
61
+ - lib/sixarm_ruby_sign_in.rb
62
+ - test/sixarm_ruby_sign_in_test.rb
63
+ homepage: http://sixarm.com/
64
+ licenses:
65
+ - BSD
66
+ - GPL
67
+ - MIT
68
+ - PAL
69
+ - Various
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.8
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: SixArm.com » Ruby » Sign In
91
+ test_files:
92
+ - test/sixarm_ruby_sign_in_test.rb
metadata.gz.sig ADDED
Binary file