magic_key_auth 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/magic_key_auth.rb +6 -0
- data/lib/magic_key_auth/SSL.rb +24 -0
- data/lib/magic_key_auth/message.rb +15 -0
- metadata +66 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
module MagicKeyAuth
|
2
|
+
class SSL
|
3
|
+
class << self
|
4
|
+
def key_location=(dir)
|
5
|
+
@key_location = dir
|
6
|
+
end
|
7
|
+
|
8
|
+
def key_location
|
9
|
+
@key_location || "keys"
|
10
|
+
end
|
11
|
+
|
12
|
+
def authenticate(opts = {})
|
13
|
+
opts = {:digest => "", :message => Time.now.to_i.to_s}.merge(opts)
|
14
|
+
raise MagicKeyAuth::InvalidKeyDir, "key directory doesn't exist!" unless File.exists?(key_location)
|
15
|
+
Dir.new(key_location).entries.each do |key|
|
16
|
+
next unless key =~ /\.pem/
|
17
|
+
return key.gsub(/\.pem/, '') if
|
18
|
+
(EzCrypto::Verifier.from_file(File.join(key_location, key)).verify(opts[:digest], opts[:message]) rescue false)
|
19
|
+
end
|
20
|
+
nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MagicKeyAuth
|
2
|
+
class Message
|
3
|
+
attr_accessor :keyfile, :message
|
4
|
+
|
5
|
+
def initialize(opts = {})
|
6
|
+
self.message = (opts[:message] || Time.now.to_i).to_s
|
7
|
+
self.keyfile = opts[:keyfile].to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
def digest
|
11
|
+
raise MagicKeyAuth::NoKeyFound unless File.exists?(self.keyfile)
|
12
|
+
EzCrypto::Signer.from_file(self.keyfile).sign(self.message)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magic_key_auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Terry Heath
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-18 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: ezcrypto
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.7.2
|
24
|
+
version:
|
25
|
+
description: authentication mechanism based on SSH keys
|
26
|
+
email: theath@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- lib/magic_key_auth.rb
|
35
|
+
- lib/magic_key_auth/message.rb
|
36
|
+
- lib/magic_key_auth/SSL.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://github.com/terrbear/magic_key_auth
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements:
|
59
|
+
- ezcrypto, 0.7.2 or later
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.3.5
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: authentication mechanism based on SSH keys
|
65
|
+
test_files: []
|
66
|
+
|