dvyjones-authlogic-kerberos 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Henrik Hodne
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,9 @@
1
+ = authlogic-kerberos
2
+
3
+ This is still under development.
4
+
5
+ Should provide kerberos authentication with the AuthLogic framework.
6
+
7
+ == Copyright
8
+
9
+ Copyright (c) 2009 Henrik Hodne. See LICENSE for details.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 0
3
+ :patch: 0
4
+ :major: 0
@@ -0,0 +1,7 @@
1
+ require "krb5_auth"
2
+ require "authlogic_kerberos/version"
3
+ require "authlogic_kerberos/acts_as_authentic"
4
+ require "authlogic_kerberos/session"
5
+
6
+ ActiveRecord::Base.send(:include, AuthlogicKerberos::ActsAsAuthentic)
7
+ # Authlogic::Session::Base.send(:include, AuthlogicKerberos::Session)
@@ -0,0 +1,63 @@
1
+ require 'krb5_auth'
2
+
3
+ # This module is responsible for adding Kerberos functionality to Authlogic. Checkout the README for more info and please
4
+ # see the sub modules for detailed documentation.
5
+ module AuthlogicKerberos
6
+ # This module is responsible for adding in the Kerberos functionality to your models. It hooks itself into the
7
+ # acts_as_authentic method provided by Authlogic.
8
+ module ActsAsAuthentic
9
+ # Adds in the neccesary modules for acts_as_authentic to include
10
+ def self.included(klass)
11
+ klass.class_eval do
12
+ extend Config
13
+ add_acts_as_authentic_module(Methods, :prepend)
14
+ end
15
+ end
16
+
17
+ module Config
18
+ def authenticate_with_kerberos(value=nil)
19
+ config(:authenticate_with_kerberos, value, false)
20
+ end
21
+ alias_method :authenticate_with_kerberos=, :authenticate_with_kerberos
22
+
23
+ # Set to a path to enable caching. %u will be replaced with the username
24
+ def kerberos_cache_path(value=nil)
25
+ config(:kerberos_cache_path, value, false)
26
+ end
27
+ alias_method :kerberos_cache_path=, :kerberos_cache_path
28
+ end
29
+
30
+ module Methods
31
+ # This is where all of the magic happens. This is where we hook in and add all of the Kerberos sweetness.
32
+ def save(perform_validation = true, &block)
33
+ return false if perform_validation && block_given? && authenticate_with_kerberos? && !authenticate_with_openid
34
+ result = super
35
+ yield(result) if block_given?
36
+ result
37
+ end
38
+
39
+ private
40
+ def authenticate_with_kerberos
41
+ krb5 = Krb5Auth::Krb5.new
42
+
43
+ begin
44
+ krb5.get_init_creds_password(self.login, self.password)
45
+ rescue Krb5Auth::Krb5::Exception
46
+ return false
47
+ else
48
+ return true
49
+ ensure
50
+ krb5.close
51
+ end
52
+ end
53
+
54
+ def using_kerberos?
55
+ self.class.authenticate_with_kerberos
56
+ end
57
+
58
+ def authenticate_with_kerberos?
59
+ session_class.activated? && using_kerberos?
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,4 @@
1
+ module AuthlogicKerberos
2
+ module Session
3
+ end
4
+ end
@@ -0,0 +1,51 @@
1
+ module AuthlogicKerberos
2
+ # A class for describing the current version of a library. The version
3
+ # consists of three parts: the +major+ number, the +minor+ number, and the
4
+ # +tiny+ (or +patch+) number.
5
+ class Version
6
+ include Comparable
7
+
8
+ # A convenience method for instantiating a new Version instance with the
9
+ # given +major+, +minor+, and +tiny+ components.
10
+ def self.[](major, minor, tiny)
11
+ new(major, minor, tiny)
12
+ end
13
+
14
+ attr_reader :major, :minor, :tiny
15
+
16
+ # Create a new Version object with the given components.
17
+ def initialize(major, minor, tiny)
18
+ @major, @minor, @tiny = major, minor, tiny
19
+ end
20
+
21
+ # Compare this version to the given +version+ object.
22
+ def <=>(version)
23
+ to_i <=> version.to_i
24
+ end
25
+
26
+ # Converts this version object to a string, where each of the three
27
+ # version components are joined by the '.' character. E.g., 2.0.0.
28
+ def to_s
29
+ @to_s ||= [@major, @minor, @tiny].join(".")
30
+ end
31
+
32
+ # Converts this version to a canonical integer that may be compared
33
+ # against other version objects.
34
+ def to_i
35
+ @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny
36
+ end
37
+
38
+ def to_a
39
+ [@major, @minor, @tiny]
40
+ end
41
+
42
+ MAJOR = YAML.load_file(File.dirname(__FILE__)+"/../../VERSION.yml")[:major]
43
+ MINOR = YAML.load_file(File.dirname(__FILE__)+"/../../VERSION.yml")[:minor]
44
+ TINY = YAML.load_file(File.dirname(__FILE__)+"/../../VERSION.yml")[:patch]
45
+
46
+ # The current version as a Version instance
47
+ CURRENT = new(MAJOR, MINOR, TINY)
48
+ # The current version as a String
49
+ STRING = CURRENT.to_s
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class AuthlogicKerberosTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'authlogic_kerberos'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dvyjones-authlogic-kerberos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Henrik Hodne
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-08 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: henrik.hodne@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE
25
+ files:
26
+ - README.rdoc
27
+ - VERSION.yml
28
+ - lib/authlogic_kerberos.rb
29
+ - lib/authlogic_kerberos
30
+ - lib/authlogic_kerberos/acts_as_authentic.rb
31
+ - lib/authlogic_kerberos/session.rb
32
+ - lib/authlogic_kerberos/version.rb
33
+ - test/test_helper.rb
34
+ - test/authlogic_kerberos_test.rb
35
+ - LICENSE
36
+ has_rdoc: true
37
+ homepage: http://github.com/dvyjones/authlogic-kerberos
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --inline-source
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: Kerberos authentication for AuthLogic
63
+ test_files: []
64
+