invision_bridge 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -5
- data/Rakefile +0 -12
- data/VERSION +1 -1
- data/invision_bridge.gemspec +5 -16
- data/lib/{invision_bridge/crypto_provider.rb → authlogic/crypto_providers/invision_power_board.rb} +5 -5
- data/lib/invision_bridge.rb +39 -1
- data/lib/invision_bridge/active_record.rb +23 -0
- data/rails/init.rb +1 -1
- metadata +9 -17
- data/install.rb +0 -1
- data/lib/invision_bridge/invision_bridge.rb +0 -34
- data/lib/invision_bridge/rails.rb +0 -3
- data/lib/invision_bridge/user/base.rb +0 -27
- data/spec/invision_bridge/crypto_provider_spec.rb +0 -18
- data/spec/spec.opts +0 -3
- data/spec/spec_helper.rb +0 -6
- data/uninstall.rb +0 -1
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# InvisionBridge
|
2
2
|
|
3
|
-
Allows your [Authlogic](http://github.com/binarylogic/authlogic)-based
|
3
|
+
Allows your [Authlogic](http://github.com/binarylogic/authlogic)-based user model to authenticate using an [IP.Board](http://www.invisionpower.com/) 3.x database.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -37,16 +37,19 @@ Modify your `config/database.yml` file to include your IP.Board database informa
|
|
37
37
|
|
38
38
|
### Model creation
|
39
39
|
|
40
|
-
Modify or create your User model to
|
40
|
+
Modify or create your User model to include `InvisionBridge`
|
41
41
|
|
42
|
-
class User <
|
42
|
+
class User < ActiveRecord::Base
|
43
|
+
include InvisionBridge
|
43
44
|
end
|
44
45
|
|
45
46
|
That's it. You can further customize your model as needed. For example, you may
|
46
47
|
have a group of administrators on your forum that you want to be administrators
|
47
48
|
in your Rails application.
|
48
49
|
|
49
|
-
class User <
|
50
|
+
class User < ActiveRecord::Base
|
51
|
+
include InvisionBridge
|
52
|
+
|
50
53
|
ADMIN_GROUP = 1
|
51
54
|
|
52
55
|
def is_admin?
|
@@ -54,6 +57,10 @@ in your Rails application.
|
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
60
|
+
### ORM Adapters
|
61
|
+
|
62
|
+
Currently InvisionBridge only works with ActiveRecord models. I'd love to add a DataMapper adapter if/when I need one.
|
63
|
+
|
57
64
|
## Known Issues
|
58
65
|
|
59
66
|
While using this in my own production application, I'd occasionally get "MySQL
|
@@ -63,4 +70,4 @@ but I was able to make the error stop appearing by adding `reconnect: true` to t
|
|
63
70
|
|
64
71
|
## Credits
|
65
72
|
|
66
|
-
Copyright (c) 2010 Robert Speicher, released under the MIT license
|
73
|
+
Copyright (c) 2010 Robert Speicher, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,18 +1,6 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/rdoctask'
|
3
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
4
|
desc 'Generate documentation for the invision_bridge plugin.'
|
17
5
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
6
|
rdoc.rdoc_dir = 'rdoc'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/invision_bridge.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{invision_bridge}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Robert Speicher"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-24}
|
13
13
|
s.description = %q{Allows your Authlogic-based User model to authenticate using an IP.Board 3.x database.}
|
14
14
|
s.email = %q{rspeicher@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -22,28 +22,17 @@ Gem::Specification.new do |s|
|
|
22
22
|
"VERSION",
|
23
23
|
"config/database.yml.example",
|
24
24
|
"init.rb",
|
25
|
-
"install.rb",
|
26
25
|
"invision_bridge.gemspec",
|
26
|
+
"lib/authlogic/crypto_providers/invision_power_board.rb",
|
27
27
|
"lib/invision_bridge.rb",
|
28
|
-
"lib/invision_bridge/
|
29
|
-
"
|
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"
|
28
|
+
"lib/invision_bridge/active_record.rb",
|
29
|
+
"rails/init.rb"
|
37
30
|
]
|
38
31
|
s.homepage = %q{http://github.com/tsigo/invision_bridge}
|
39
32
|
s.rdoc_options = ["--charset=UTF-8"]
|
40
33
|
s.require_paths = ["lib"]
|
41
34
|
s.rubygems_version = %q{1.3.7}
|
42
35
|
s.summary = %q{Allows your Authlogic-based User model to authenticate using 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
36
|
|
48
37
|
if s.respond_to? :specification_version then
|
49
38
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/lib/{invision_bridge/crypto_provider.rb → authlogic/crypto_providers/invision_power_board.rb}
RENAMED
@@ -8,18 +8,18 @@ module Authlogic
|
|
8
8
|
tokens = tokens.flatten
|
9
9
|
digest = tokens.shift
|
10
10
|
digest = filter_input(digest)
|
11
|
-
|
11
|
+
|
12
12
|
# Invision's hash: MD5(MD5(salt) + MD5(raw))
|
13
13
|
digest = Digest::MD5.hexdigest(Digest::MD5.hexdigest(tokens.join('')) + Digest::MD5.hexdigest(digest))
|
14
|
-
|
14
|
+
|
15
15
|
digest
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# Does the crypted password match the tokens? Uses the same tokens that were used to encrypt.
|
19
19
|
def matches?(crypted, *tokens)
|
20
20
|
encrypt(*tokens) == crypted
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
private
|
24
24
|
def filter_input(input)
|
25
25
|
# Invision's input filtering replaces a bunch of characters before
|
@@ -46,4 +46,4 @@ module Authlogic
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
data/lib/invision_bridge.rb
CHANGED
@@ -1,2 +1,40 @@
|
|
1
1
|
require 'authlogic'
|
2
|
-
require '
|
2
|
+
require 'authlogic/crypto_providers/invision_power_board'
|
3
|
+
|
4
|
+
module InvisionBridge
|
5
|
+
autoload :ActiveRecord, 'invision_bridge/active_record'
|
6
|
+
|
7
|
+
def self.config
|
8
|
+
if @config.nil?
|
9
|
+
if Rails
|
10
|
+
config_file = File.join(Rails.root, 'config', 'database.yml')
|
11
|
+
config_group = "invision_bridge_#{Rails.env}"
|
12
|
+
else
|
13
|
+
config_file = File.join(File.dirname(__FILE__), '..', '..', 'config', 'database.yml')
|
14
|
+
config_group = "invision_bridge"
|
15
|
+
end
|
16
|
+
|
17
|
+
config = YAML::load(File.open(config_file))
|
18
|
+
config = config[config_group]
|
19
|
+
|
20
|
+
if config.nil?
|
21
|
+
raise "** [InvisionBridge] Unable to read database configuration from #{config_file} -- Make sure an #{config_group} definition exists."
|
22
|
+
else
|
23
|
+
config['prefix'] ||= 'ibf_'
|
24
|
+
end
|
25
|
+
|
26
|
+
@config = config
|
27
|
+
end
|
28
|
+
|
29
|
+
@config
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.included(base)
|
33
|
+
if base.respond_to? :establish_connection
|
34
|
+
base.send(:include, InvisionBridge::ActiveRecord)
|
35
|
+
else
|
36
|
+
raise "** [InvisionBridge] Currently we only support ActiveRecord models. Sorry."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module InvisionBridge
|
2
|
+
module ActiveRecord
|
3
|
+
def self.included(base)
|
4
|
+
base.class_eval do
|
5
|
+
establish_connection(InvisionBridge.config)
|
6
|
+
|
7
|
+
# IP.Board database design, grumble grumble
|
8
|
+
set_table_name "#{InvisionBridge.config['prefix']}members"
|
9
|
+
set_primary_key "member_id"
|
10
|
+
|
11
|
+
# Configure Authlogic
|
12
|
+
attr_accessible :name, :login, :password, :password_confirmation
|
13
|
+
acts_as_authentic do |c|
|
14
|
+
c.crypto_provider = Authlogic::CryptoProviders::InvisionPowerBoard
|
15
|
+
c.login_field = :name
|
16
|
+
c.crypted_password_field = :members_pass_hash
|
17
|
+
c.password_salt_field = :members_pass_salt
|
18
|
+
c.validate_password_field = false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/rails/init.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'invision_bridge
|
1
|
+
require 'invision_bridge'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invision_bridge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robert Speicher
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-24 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -47,18 +47,11 @@ files:
|
|
47
47
|
- VERSION
|
48
48
|
- config/database.yml.example
|
49
49
|
- init.rb
|
50
|
-
- install.rb
|
51
50
|
- invision_bridge.gemspec
|
51
|
+
- lib/authlogic/crypto_providers/invision_power_board.rb
|
52
52
|
- lib/invision_bridge.rb
|
53
|
-
- lib/invision_bridge/
|
54
|
-
- lib/invision_bridge/invision_bridge.rb
|
55
|
-
- lib/invision_bridge/rails.rb
|
56
|
-
- lib/invision_bridge/user/base.rb
|
53
|
+
- lib/invision_bridge/active_record.rb
|
57
54
|
- rails/init.rb
|
58
|
-
- spec/invision_bridge/crypto_provider_spec.rb
|
59
|
-
- spec/spec.opts
|
60
|
-
- spec/spec_helper.rb
|
61
|
-
- uninstall.rb
|
62
55
|
has_rdoc: true
|
63
56
|
homepage: http://github.com/tsigo/invision_bridge
|
64
57
|
licenses: []
|
@@ -93,6 +86,5 @@ rubygems_version: 1.3.7
|
|
93
86
|
signing_key:
|
94
87
|
specification_version: 3
|
95
88
|
summary: Allows your Authlogic-based User model to authenticate using an IP.Board 3.x database.
|
96
|
-
test_files:
|
97
|
-
|
98
|
-
- spec/spec_helper.rb
|
89
|
+
test_files: []
|
90
|
+
|
data/install.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Install hook code here
|
@@ -1,34 +0,0 @@
|
|
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_file = Rails.configuration.database_configuration_file
|
11
|
-
config_group = "invision_bridge_#{Rails.env}"
|
12
|
-
else
|
13
|
-
config_file = File.join(File.dirname(__FILE__), '..', '..', 'config', 'database.yml')
|
14
|
-
config_group = "invision_bridge"
|
15
|
-
end
|
16
|
-
|
17
|
-
config = YAML::load(File.open(config_file))
|
18
|
-
config = config[config_group]
|
19
|
-
|
20
|
-
if config.nil?
|
21
|
-
raise "Unable to read database configuration from #{config_file} -- Make sure an #{config_group} definition exists."
|
22
|
-
else
|
23
|
-
config['prefix'] ||= 'ibf_'
|
24
|
-
end
|
25
|
-
|
26
|
-
establish_connection(config)
|
27
|
-
|
28
|
-
unloadable # http://www.dansketcher.com/2009/05/11/cant-dup-nilclass/
|
29
|
-
set_table_name "#{config['prefix']}members"
|
30
|
-
set_primary_key "member_id"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,27 +0,0 @@
|
|
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
|
@@ -1,18 +0,0 @@
|
|
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
DELETED
data/spec/spec_helper.rb
DELETED
data/uninstall.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Uninstall hook code here
|