invision_bridge 0.1.0
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/MIT-LICENSE +20 -0
- data/README.textile +7 -0
- data/Rakefile +40 -0
- data/VERSION +1 -0
- data/config/database.yml.example +20 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/invision_bridge.gemspec +61 -0
- data/lib/invision_bridge/crypto_provider.rb +49 -0
- data/lib/invision_bridge/invision_bridge.rb +27 -0
- data/lib/invision_bridge/rails.rb +3 -0
- data/lib/invision_bridge/user/base.rb +27 -0
- data/lib/invision_bridge.rb +2 -0
- data/rails/init.rb +1 -0
- data/spec/invision_bridge/crypto_provider_spec.rb +18 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +6 -0
- data/uninstall.rb +1 -0
- metadata +82 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 [name of plugin creator]
|
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.textile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/rdoctask'
|
3
|
+
|
4
|
+
gem 'rspec-rails', '>= 1.0.0'
|
5
|
+
require 'spec/rake/spectask'
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
desc 'Test the invision_bridge plugin.'
|
11
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
12
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
13
|
+
t.spec_opts = ["-c"]
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the invision_bridge plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'InvisionBridge'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'jeweler'
|
27
|
+
Jeweler::Tasks.new do |s|
|
28
|
+
s.name = "invision_bridge"
|
29
|
+
s.summary = "Uses Authlogic to allow your User model to use an IP.Board 3.x database."
|
30
|
+
s.email = "rspeicher@gmail.com"
|
31
|
+
s.homepage = "http://github.com/tsigo/invision_bridge"
|
32
|
+
s.description = "Uses Authlogic to allow your User model to use an IP.Board 3.x database."
|
33
|
+
s.authors = ["Robert Speicher"]
|
34
|
+
s.files = FileList["[A-Za-z]*", "{lib,rails,spec,config}/**/*"]
|
35
|
+
s.add_dependency 'authlogic'
|
36
|
+
end
|
37
|
+
Jeweler::GemcutterTasks.new
|
38
|
+
rescue LoadError
|
39
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
40
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
invision_bridge_development:
|
2
|
+
adapter: mysql
|
3
|
+
database: invision_forums_development
|
4
|
+
user: username
|
5
|
+
password: password
|
6
|
+
prefix: ibf_
|
7
|
+
|
8
|
+
invision_bridge_test:
|
9
|
+
adapter: mysql
|
10
|
+
database: invision_forums_test
|
11
|
+
user: username
|
12
|
+
password: password
|
13
|
+
prefix: ibf_
|
14
|
+
|
15
|
+
invision_bridge_production:
|
16
|
+
adapter: mysql
|
17
|
+
database: invision_forums
|
18
|
+
user: username
|
19
|
+
password: password
|
20
|
+
prefix: ibf_
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'invision_bridge'
|
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{invision_bridge}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Robert Speicher"]
|
12
|
+
s.date = %q{2010-01-29}
|
13
|
+
s.description = %q{Uses Authlogic to allow your User model to use an IP.Board 3.x database.}
|
14
|
+
s.email = %q{rspeicher@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.textile"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README.textile",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"config/database.yml.example",
|
24
|
+
"init.rb",
|
25
|
+
"install.rb",
|
26
|
+
"invision_bridge.gemspec",
|
27
|
+
"lib/invision_bridge.rb",
|
28
|
+
"lib/invision_bridge/crypto_provider.rb",
|
29
|
+
"lib/invision_bridge/invision_bridge.rb",
|
30
|
+
"lib/invision_bridge/rails.rb",
|
31
|
+
"lib/invision_bridge/user/base.rb",
|
32
|
+
"rails/init.rb",
|
33
|
+
"spec/invision_bridge/crypto_provider_spec.rb",
|
34
|
+
"spec/spec.opts",
|
35
|
+
"spec/spec_helper.rb",
|
36
|
+
"uninstall.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/tsigo/invision_bridge}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.5}
|
42
|
+
s.summary = %q{Uses Authlogic to allow your User model to use an IP.Board 3.x database.}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/invision_bridge/crypto_provider_spec.rb",
|
45
|
+
"spec/spec_helper.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<authlogic>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<authlogic>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<authlogic>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module Authlogic
|
4
|
+
module CryptoProviders
|
5
|
+
class InvisionPowerBoard
|
6
|
+
class << self
|
7
|
+
def encrypt(*tokens)
|
8
|
+
tokens = tokens.flatten
|
9
|
+
digest = tokens.shift
|
10
|
+
digest = filter_input(digest)
|
11
|
+
|
12
|
+
# Invision's hash: MD5(MD5(salt) + MD5(raw))
|
13
|
+
digest = Digest::MD5.hexdigest(Digest::MD5.hexdigest(tokens.join('')) + Digest::MD5.hexdigest(digest))
|
14
|
+
|
15
|
+
digest
|
16
|
+
end
|
17
|
+
|
18
|
+
# Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
|
19
|
+
def matches?(crypted, *tokens)
|
20
|
+
encrypt(*tokens) == crypted
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
def filter_input(input)
|
25
|
+
# Invision's input filtering replaces a bunch of characters before
|
26
|
+
# the password gets hashed, some of which may be used in a strong
|
27
|
+
# password. We have to apply the same changes so that the md5'd
|
28
|
+
# string ends up the same on our end
|
29
|
+
input.gsub!('&[^amp;]?', '&')
|
30
|
+
input.gsub!('<!--', '<!--')
|
31
|
+
input.gsub!('-->', '-->')
|
32
|
+
input.gsub!(/<script/i, '<script')
|
33
|
+
input.gsub!('>', '>')
|
34
|
+
input.gsub!('<', '<')
|
35
|
+
input.gsub!('"', '"')
|
36
|
+
input.gsub!("\\\$", '$')
|
37
|
+
input.gsub!('!', '!')
|
38
|
+
input.gsub!("'", ''')
|
39
|
+
|
40
|
+
# NOTE: Invision does these, but I doubt they'll show up in a real user's password
|
41
|
+
# input.gsub!("\n", '<br />')
|
42
|
+
# input.gsub!("\r", '')
|
43
|
+
|
44
|
+
input
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module InvisionBridge
|
2
|
+
module Base
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def establish_bridge()
|
9
|
+
if Rails
|
10
|
+
config = YAML::load(File.open(Rails.configuration.database_configuration_file))
|
11
|
+
config = config["invision_bridge_#{Rails.env}"]
|
12
|
+
else
|
13
|
+
config = YAML::load(File.open(File.join(File.dirname(__FILE__), '..', '..', 'config', 'database.yml')))
|
14
|
+
config = config["invision_bridge"]
|
15
|
+
end
|
16
|
+
|
17
|
+
config['prefix'] ||= 'ibf_'
|
18
|
+
|
19
|
+
establish_connection(config)
|
20
|
+
|
21
|
+
unloadable # http://www.dansketcher.com/2009/05/11/cant-dup-nilclass/
|
22
|
+
set_table_name "#{config['prefix']}members"
|
23
|
+
set_primary_key "member_id"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module InvisionBridge
|
2
|
+
module User
|
3
|
+
class Base < ActiveRecord::Base
|
4
|
+
self.abstract_class = true
|
5
|
+
|
6
|
+
include InvisionBridge::Base
|
7
|
+
establish_bridge
|
8
|
+
|
9
|
+
# Authlogic -----------------------------------------------------------------
|
10
|
+
attr_accessible :login, :password, :password_confirmation
|
11
|
+
acts_as_authentic do |c|
|
12
|
+
c.crypto_provider = Authlogic::CryptoProviders::InvisionPowerBoard
|
13
|
+
c.login_field = :name
|
14
|
+
c.crypted_password_field = :members_pass_hash
|
15
|
+
c.password_salt_field = :members_pass_salt
|
16
|
+
c.validate_password_field = false
|
17
|
+
end
|
18
|
+
|
19
|
+
# ---------------------------------------------------------------------------
|
20
|
+
# Override some AR methods; we don't want to mess with Invision's integrity
|
21
|
+
def destroy; end
|
22
|
+
def delete; end
|
23
|
+
def self.destroy_all; end
|
24
|
+
def self.delete_all; end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/rails/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'invision_bridge/rails'
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Authlogic::CryptoProviders::InvisionPowerBoard do
|
4
|
+
it "should encrypt" do
|
5
|
+
Authlogic::CryptoProviders::InvisionPowerBoard.encrypt("mypass").should be_true
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should match expected output" do
|
9
|
+
hash = Authlogic::CryptoProviders::InvisionPowerBoard.encrypt("mypass")
|
10
|
+
Authlogic::CryptoProviders::InvisionPowerBoard.matches?(hash, "mypass").should be_true
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should filter characters" do
|
14
|
+
pass = '?&!&><"!\''
|
15
|
+
hash = Authlogic::CryptoProviders::InvisionPowerBoard.encrypt(pass)
|
16
|
+
Authlogic::CryptoProviders::InvisionPowerBoard.matches?(hash, pass).should be_true
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: invision_bridge
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Robert Speicher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-29 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: authlogic
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Uses Authlogic to allow your User model to use an IP.Board 3.x database.
|
26
|
+
email: rspeicher@gmail.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.textile
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- README.textile
|
36
|
+
- Rakefile
|
37
|
+
- VERSION
|
38
|
+
- config/database.yml.example
|
39
|
+
- init.rb
|
40
|
+
- install.rb
|
41
|
+
- invision_bridge.gemspec
|
42
|
+
- lib/invision_bridge.rb
|
43
|
+
- lib/invision_bridge/crypto_provider.rb
|
44
|
+
- lib/invision_bridge/invision_bridge.rb
|
45
|
+
- lib/invision_bridge/rails.rb
|
46
|
+
- lib/invision_bridge/user/base.rb
|
47
|
+
- rails/init.rb
|
48
|
+
- spec/invision_bridge/crypto_provider_spec.rb
|
49
|
+
- spec/spec.opts
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
- uninstall.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/tsigo/invision_bridge
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --charset=UTF-8
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 1.3.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: Uses Authlogic to allow your User model to use an IP.Board 3.x database.
|
80
|
+
test_files:
|
81
|
+
- spec/invision_bridge/crypto_provider_spec.rb
|
82
|
+
- spec/spec_helper.rb
|