devise-neo4j 1.0.3 → 2.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +33 -0
- data/README.md +108 -0
- data/Rakefile +20 -8
- data/Vagrantfile +22 -0
- data/devise-neo4j.gemspec +8 -11
- data/lib/devise-neo4j.rb +0 -1
- data/lib/devise-neo4j/version.rb +1 -1
- data/lib/devise/orm/neo4j.rb +4 -8
- data/lib/devise/orm/neo4j/date_time.rb +8 -0
- data/lib/devise/orm/neo4j/hook.rb +7 -12
- data/lib/devise/orm/neo4j/nil_class_converter.rb +24 -0
- data/lib/generators/neo4j/devise_generator.rb +69 -6
- data/provisioning/roles/common/tasks/main.yml +13 -0
- data/provisioning/roles/java/README.md +30 -0
- data/provisioning/roles/java/files/.gitkeep +0 -0
- data/provisioning/roles/java/files/webupd8.key.asc +13 -0
- data/provisioning/roles/java/handlers/.gitkeep +0 -0
- data/provisioning/roles/java/tasks/.gitkeep +0 -0
- data/provisioning/roles/java/tasks/main.yml +6 -0
- data/provisioning/roles/java/tasks/openjdk.yml +6 -0
- data/provisioning/roles/java/tasks/oracle.yml +12 -0
- data/provisioning/roles/java/tasks/webupd8.yml +13 -0
- data/provisioning/roles/java/templates/.gitkeep +0 -0
- data/provisioning/roles/java/vars/.gitkeep +0 -0
- data/provisioning/roles/java/vars/main.yml +2 -0
- data/provisioning/roles/neo4j/files/neo4j-server.properties +20 -0
- data/provisioning/roles/neo4j/files/neo4j.conf +6 -0
- data/provisioning/roles/neo4j/tasks/main.yml +45 -0
- data/provisioning/roles/neo4j/vars/main.yml +1 -0
- data/provisioning/vagrant.yml +17 -0
- data/test/generators/neo4j/devise_generator_test.rb +1 -2
- data/test/orm/neo4j.rb +52 -7
- data/test/overrides/authenticatable_test.rb +14 -0
- data/test/overrides/database_authenticatable_test.rb +17 -0
- data/test/overrides/mapping_test.rb +11 -0
- data/test/rails_app/app/neo4j/admin.rb +36 -4
- data/test/rails_app/app/neo4j/user.rb +41 -5
- data/test/rails_app/app/neo4j/user_on_engine.rb +43 -0
- data/test/rails_app/app/neo4j/user_on_main_app.rb +43 -0
- data/test/rails_app/config/application.rb +11 -11
- data/test/support/i18n.rb +1 -1
- data/test/test_helper.rb +16 -23
- data/test/test_models.rb +33 -0
- metadata +174 -164
- data/Gemfile.lock +0 -156
- data/README.rdoc +0 -48
- data/lib/devise/orm/neo4j/schema.rb +0 -40
- data/test/overrides/models/recoverable_test.rb +0 -21
- data/test/rails_app/app/neo4j/shim.rb +0 -2
- data/test/support/fix_last.rb +0 -12
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 93c410a790b9472c524bc9e292719010f617ea86
|
4
|
+
data.tar.gz: 1172ed3e86426dccd08f27152c596eb743d0edf4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 202423db6a77e66e4b0d3d551e992feed871ffa2a5ab0cbd2ca26edbb470949e0599b5f6807293be199faa03c0fae6a19ded07f82d6a4de210f2e14484985306
|
7
|
+
data.tar.gz: df1ee93d673ecf0bc46b47edb1c6e522e728430eb94df9f48689cd686c315b4bd49e9b87cfa368ede5d6fcf3aeb77a88e0ab8106e388c3e2507c0018f480a263
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,3 +1,36 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
|
+
|
5
|
+
gem "rails", "~> 4.1.1"
|
6
|
+
gem "omniauth"
|
7
|
+
gem "omniauth-oauth2"
|
8
|
+
gem "rdoc"
|
9
|
+
gem 'neo4j', "~> 3.0.0.alpha.7"
|
10
|
+
gem "devise", git: 'https://github.com/plataformatec/devise.git'
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem "omniauth-facebook"
|
14
|
+
gem "omniauth-openid", "~> 1.0.1"
|
15
|
+
gem "webrat", "0.7.2", :require => false
|
16
|
+
gem "mocha", :require => false
|
17
|
+
|
18
|
+
platforms :mri_18 do
|
19
|
+
gem "ruby-debug", ">= 0.10.3"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
platforms :jruby do
|
24
|
+
gem "jruby-openssl"
|
25
|
+
gem "neo4j-community"
|
26
|
+
end
|
27
|
+
|
28
|
+
platforms :ruby do
|
29
|
+
gem "sqlite3"
|
30
|
+
|
31
|
+
group :mongoid do
|
32
|
+
gem "mongo"
|
33
|
+
gem "mongoid"
|
34
|
+
gem "bson_ext", "~> 1.3.0"
|
35
|
+
end
|
36
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# Devise-Neo4j [![Build Status](https://secure.travis-ci.org/andreasronge/devise-neo4j.png?branch=master)](http://travis-ci.org/andreasronge/devise-neo4j)
|
2
|
+
|
3
|
+
A gem for Neo4j integration with the Devise authentication framework.
|
4
|
+
|
5
|
+
Neo4j: https://github.com/andreasronge/neo4j Devise:
|
6
|
+
https://github.com/plataformatec/devise
|
7
|
+
|
8
|
+
## Usage
|
9
|
+
|
10
|
+
### Installation
|
11
|
+
|
12
|
+
Add the neo4j and devise-neo4j gems to your Gemfile:
|
13
|
+
|
14
|
+
gem "neo4j", "~> 3.0.0.alpha.7"
|
15
|
+
gem "devise-neo4j", "~> 2.0.0.alpha.1"
|
16
|
+
|
17
|
+
Run the bundle install command:
|
18
|
+
|
19
|
+
bundle install
|
20
|
+
|
21
|
+
Then run the devise install generator and optionally update or create a
|
22
|
+
devise-neo4j model:
|
23
|
+
|
24
|
+
rails g devise:install --orm=neo4j
|
25
|
+
rails g neo4j:devise MODEL
|
26
|
+
|
27
|
+
Now the model is setup like a default devise model, meaning you can do things
|
28
|
+
like adding a before_filter in a controller to restrict access to logged-in
|
29
|
+
users only:
|
30
|
+
|
31
|
+
before_filter :authenticate_<your model name>!
|
32
|
+
|
33
|
+
## Example App
|
34
|
+
|
35
|
+
You can see a very simple app that demonstrates Neo4j and devise here:
|
36
|
+
|
37
|
+
gem install rails
|
38
|
+
rails new myapp -m http://andreasronge.github.com/neo4j/neo4j.rb -O
|
39
|
+
cd myapp
|
40
|
+
add to your Gem File :
|
41
|
+
gem 'devise'
|
42
|
+
gem 'devise-neo4j', :git => 'git@github.com:cheerfulstoic/devise-neo4j.git'
|
43
|
+
bundle
|
44
|
+
rails generate devise:install --orm=neo4j
|
45
|
+
|
46
|
+
# install the database unless you already have a neo4j database, or use JRuby Embedded Neo4j db
|
47
|
+
rake neo4j:install[community-2.1.2] # check which one is the latest
|
48
|
+
rake neo4j:start
|
49
|
+
|
50
|
+
rails g neo4j:devise User
|
51
|
+
# add to your config/routes.rb:
|
52
|
+
devise_for :users
|
53
|
+
root :to => "secrets#show"
|
54
|
+
|
55
|
+
# generate a controller for the protected content
|
56
|
+
rails g controller secrets show
|
57
|
+
|
58
|
+
# in app/controllers/sercrets_controller.rb delete line get 'secrets/show' and add:
|
59
|
+
before_filter :authenticate_user!
|
60
|
+
|
61
|
+
# in app/views/secrets/show.html.erb: add:
|
62
|
+
<p>Shhhh... this page is only visible to logged-in users!</p>
|
63
|
+
|
64
|
+
<%= link_to "Log out", destroy_user_session_path, method: :delete %>
|
65
|
+
|
66
|
+
rails s
|
67
|
+
|
68
|
+
# go to http://localhost:3000/users/sign_up
|
69
|
+
|
70
|
+
## Developing
|
71
|
+
|
72
|
+
### For JRuby
|
73
|
+
|
74
|
+
JRUby neo4j has an embedded server as part of the gem, so nothing else is
|
75
|
+
needed to get set up and running.
|
76
|
+
|
77
|
+
### For Ruby
|
78
|
+
|
79
|
+
There is a Vagrant setup that installs neo4j so that you can easily get
|
80
|
+
started:
|
81
|
+
|
82
|
+
$ vagrant up
|
83
|
+
|
84
|
+
The neo4j web interface is forward to port 7474 on your local machine:
|
85
|
+
[http://localhost:7474](http://localhost:7474).
|
86
|
+
|
87
|
+
## Note on testing
|
88
|
+
|
89
|
+
To run all test, simply type `rake` If you want to run a specific Devise test
|
90
|
+
(see the devise github repository) set the DEVISE_TEST_PATH.
|
91
|
+
|
92
|
+
Example: ``` rake DEVISE_TEST_PATH=integration/confirmable_test.rb ```
|
93
|
+
|
94
|
+
## Note on Patches/Pull Requests
|
95
|
+
|
96
|
+
* Fork the project.
|
97
|
+
* Make your feature addition or bug fix.
|
98
|
+
* Add tests for it. This is important so I don't break it in a future
|
99
|
+
version unintentionally.
|
100
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to
|
101
|
+
have your own version, that is fine but bump version in a commit by itself
|
102
|
+
I can ignore when I pull)
|
103
|
+
* Send me a pull request. Bonus points for topic branches.
|
104
|
+
|
105
|
+
|
106
|
+
## Copyright
|
107
|
+
|
108
|
+
Copyright (c) 2011 Ben Jackson. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,22 +1,34 @@
|
|
1
|
-
|
1
|
+
# encoding: UTF-8
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'neo4j/tasks/neo4j_server'
|
3
6
|
|
7
|
+
|
8
|
+
task :default => [:test, :"neo4j:db:remove"]
|
9
|
+
|
10
|
+
ENV['DEVISE_ORM'] = 'neo4j'
|
11
|
+
devise_checked_out = File.join(File.dirname(__FILE__), '../devise')
|
12
|
+
ENV['DEVISE_PATH'] = File.exist?(devise_checked_out) ? devise_checked_out : `bundle show devise`.chomp
|
4
13
|
desc 'Run tests for devise-neo4j.'
|
5
14
|
Rake::TestTask.new(:test) do |test|
|
6
|
-
ENV['DEVISE_ORM'] = 'neo4j'
|
7
|
-
ENV['DEVISE_PATH'] = `bundle show devise`.chomp
|
8
15
|
unless File.exist?(ENV['DEVISE_PATH'])
|
9
|
-
puts "
|
16
|
+
puts "Specify the path to devise (e.g. rake DEVISE_PATH=/path/to/devise) or include it in your gem bundle. Not found at #{ENV['DEVISE_PATH']}"
|
10
17
|
exit
|
11
18
|
end
|
12
|
-
test.libs <<
|
19
|
+
test.libs << 'lib'
|
20
|
+
test.libs << 'test'
|
13
21
|
test.libs << "#{ENV['DEVISE_PATH']}/lib"
|
14
22
|
test.libs << "#{ENV['DEVISE_PATH']}/test"
|
15
|
-
|
23
|
+
|
24
|
+
if devise_test_path = ENV['DEVISE_TEST_PATH']
|
25
|
+
test.test_files = FileList["#{ENV['DEVISE_PATH']}/test/#{devise_test_path}"]
|
26
|
+
else
|
27
|
+
test.test_files = FileList["#{ENV['DEVISE_PATH']}/test/**/*_test.rb"] + FileList['test/**/*_test.rb']
|
28
|
+
end
|
16
29
|
test.verbose = true
|
17
30
|
end
|
18
31
|
|
19
|
-
task :default => [:test, :"neo4j:db:remove"]
|
20
32
|
|
21
33
|
namespace :neo4j do
|
22
34
|
namespace :db do
|
@@ -25,4 +37,4 @@ namespace :neo4j do
|
|
25
37
|
system "rm -fr #{File.join(File.dirname(__FILE__), "db", "*")}"
|
26
38
|
end
|
27
39
|
end
|
28
|
-
end
|
40
|
+
end
|
data/Vagrantfile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
5
|
+
VAGRANTFILE_API_VERSION = "2"
|
6
|
+
|
7
|
+
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
8
|
+
# Every Vagrant virtual environment requires a box to build off of.
|
9
|
+
config.vm.box = "precise64"
|
10
|
+
|
11
|
+
# The url from where the 'config.vm.box' box will be fetched if it
|
12
|
+
# doesn't already exist on the user's system.
|
13
|
+
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
14
|
+
|
15
|
+
config.vm.network :forwarded_port, host: 7474, guest: 80 # neo4j
|
16
|
+
config.vm.hostname = "devise-neo4j.develop"
|
17
|
+
|
18
|
+
config.vm.provision "ansible" do |ansible|
|
19
|
+
ansible.playbook = "provisioning/vagrant.yml"
|
20
|
+
# ansible.verbose = "vvvv"
|
21
|
+
end
|
22
|
+
end
|
data/devise-neo4j.gemspec
CHANGED
@@ -5,6 +5,7 @@ require "devise-neo4j/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "devise-neo4j"
|
7
7
|
s.version = Devise::Neo4j::VERSION
|
8
|
+
|
8
9
|
s.authors = ["Ben Jackson", "Bobby Calderwood"]
|
9
10
|
s.email = ["ben@lissomsolutions.com"]
|
10
11
|
s.homepage = "http://github.com/benjackson/devise-neo4j"
|
@@ -14,18 +15,14 @@ Gem::Specification.new do |s|
|
|
14
15
|
s.rubyforge_project = "devise-neo4j"
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files --
|
18
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
18
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
20
|
s.require_paths = ["lib"]
|
20
21
|
|
21
|
-
s.
|
22
|
-
s.
|
23
|
-
s.
|
24
|
-
s.
|
25
|
-
|
26
|
-
s.
|
27
|
-
s.add_development_dependency "rake"
|
28
|
-
s.add_development_dependency "webrat", "0.7.2"
|
29
|
-
s.add_development_dependency "mocha"
|
30
|
-
s.add_development_dependency "ruby-debug", ">= 0.10.3" if RUBY_VERSION < '1.9'
|
22
|
+
s.add_dependency("warden", "~> 1.2.1")
|
23
|
+
s.add_dependency("orm_adapter", "~> 0.5.0")
|
24
|
+
s.add_dependency("bcrypt-ruby", "~> 3.0")
|
25
|
+
s.add_dependency("railties", ">= 3.1")
|
26
|
+
s.add_dependency("neo4j", ">= 3.0.0.alpha.6")
|
27
|
+
s.add_dependency("devise", "~> 3.0")
|
31
28
|
end
|
data/lib/devise-neo4j.rb
CHANGED
data/lib/devise-neo4j/version.rb
CHANGED
data/lib/devise/orm/neo4j.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
require 'devise-neo4j'
|
2
|
+
require 'devise/orm/neo4j/date_time'
|
3
|
+
require 'devise/orm/neo4j/nil_class_converter'
|
4
|
+
|
5
|
+
Neo4j::ActiveNode::ClassMethods.send :include, Devise::Models
|
2
6
|
|
3
|
-
module Neo4j
|
4
|
-
module Rails
|
5
|
-
class Model
|
6
|
-
extend ::Devise::Models
|
7
|
-
extend ::Devise::Orm::Neo4j::Hook
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,23 +1,18 @@
|
|
1
|
+
require 'devise'
|
2
|
+
require 'devise/orm/neo4j/nil_class_converter'
|
3
|
+
|
1
4
|
module Devise
|
2
5
|
module Orm
|
3
6
|
module Neo4j
|
4
7
|
module Hook
|
8
|
+
|
5
9
|
def devise_modules_hook!
|
6
|
-
|
10
|
+
include Compatibility
|
7
11
|
yield
|
8
|
-
devise_modules.each { |m| send(m) if respond_to?(m, true) }
|
9
|
-
|
10
|
-
# ensure we have the created_at property
|
11
|
-
property :created_at, :type => Time
|
12
|
-
end
|
13
|
-
|
14
|
-
# Overwrite the devise method to control indexation dependent on the specified modules
|
15
|
-
def devise(*modules)
|
16
|
-
# hack to get around Neo4j's requirement to index before uniqueness validation
|
17
|
-
index :email, :type => :exact if modules.include?(:validatable)
|
18
|
-
super
|
19
12
|
end
|
13
|
+
|
20
14
|
end
|
21
15
|
end
|
22
16
|
end
|
23
17
|
end
|
18
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'neo4j'
|
2
|
+
class Neo4j::TypeConverters::NilClassConverter
|
3
|
+
class << self
|
4
|
+
def convert?(type)
|
5
|
+
type == NilClass || type == :nilclass
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_java(val)
|
9
|
+
return nil if val.nil?
|
10
|
+
return nil if val.empty?
|
11
|
+
val
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_ruby(val)
|
15
|
+
return nil if val.nil?
|
16
|
+
return nil if val.empty?
|
17
|
+
val
|
18
|
+
end
|
19
|
+
|
20
|
+
def index_as
|
21
|
+
String
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -4,17 +4,80 @@ module Neo4j
|
|
4
4
|
module Generators
|
5
5
|
class DeviseGenerator < ::Rails::Generators::NamedBase
|
6
6
|
include ::Devise::Generators::OrmHelpers
|
7
|
-
|
7
|
+
|
8
8
|
def generate_model
|
9
9
|
invoke "neo4j:model", [name] unless model_exists? && behavior == :invoke
|
10
10
|
end
|
11
|
+
|
12
|
+
|
13
|
+
def inject_field_types
|
14
|
+
inject_into_file model_path, model_contents , :after => /Neo4j::ActiveNode\n/ if model_exists?
|
15
|
+
end
|
11
16
|
|
12
17
|
def inject_devise_content
|
13
|
-
inject_into_file
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
inject_into_file model_path, migration_data , :after => /Neo4j::ActiveNode\n/ if model_exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def migration_data
|
23
|
+
<<RUBY
|
24
|
+
#
|
25
|
+
# Neo4j.rb needs to have property definitions before any validations. So, the property block needs to come before
|
26
|
+
# loading your devise modules.
|
27
|
+
#
|
28
|
+
# If you add another devise module (such as :lockable, :confirmable, or :token_authenticatable), be sure to
|
29
|
+
# uncomment the property definitions for those modules. Otherwise, the unused property definitions can be deleted.
|
30
|
+
#
|
31
|
+
|
32
|
+
property :username, :type => String
|
33
|
+
property :facebook_token, :type => String
|
34
|
+
index :facebook_token
|
35
|
+
|
36
|
+
property :created_at, :type => DateTime
|
37
|
+
property :updated_at, :type => DateTime
|
38
|
+
|
39
|
+
## Database authenticatable
|
40
|
+
property :email, :type => String, :null => false, :default => ""
|
41
|
+
index :email
|
42
|
+
|
43
|
+
property :encrypted_password
|
44
|
+
|
45
|
+
## If you include devise modules, uncomment the properties below.
|
46
|
+
|
47
|
+
## Rememberable
|
48
|
+
property :remember_created_at, :type => DateTime
|
49
|
+
index :remember_token
|
50
|
+
|
51
|
+
|
52
|
+
## Recoverable
|
53
|
+
property :reset_password_token
|
54
|
+
index :reset_password_token
|
55
|
+
property :reset_password_sent_at, :type => DateTime
|
56
|
+
|
57
|
+
## Trackable
|
58
|
+
property :sign_in_count, :type => Integer, :default => 0
|
59
|
+
property :current_sign_in_at, :type => DateTime
|
60
|
+
property :last_sign_in_at, :type => DateTime
|
61
|
+
property :current_sign_in_ip, :type => String
|
62
|
+
property :last_sign_in_ip, :type => String
|
63
|
+
|
64
|
+
## Confirmable
|
65
|
+
# property :confirmation_token
|
66
|
+
# index :confirmation_token
|
67
|
+
# property :confirmed_at, :type => DateTime
|
68
|
+
# property :confirmation_sent_at, :type => DateTime
|
69
|
+
|
70
|
+
## Lockable
|
71
|
+
# property :failed_attempts, :type => Integer, :default => 0
|
72
|
+
# property :locked_at, :type => DateTime
|
73
|
+
# property :unlock_token, :type => String,
|
74
|
+
# index :unlock_token
|
75
|
+
|
76
|
+
## Token authenticatable
|
77
|
+
# property :authentication_token, :type => String, :null => true, :index => :exact
|
78
|
+
|
79
|
+
RUBY
|
17
80
|
end
|
18
81
|
end
|
19
82
|
end
|
20
|
-
end
|
83
|
+
end
|