merging with head
This commit is contained in:
commit
6cc9deaa65
16 changed files with 112 additions and 62 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,3 +5,4 @@
|
||||||
db/*.sqlite3
|
db/*.sqlite3
|
||||||
log/*.log
|
log/*.log
|
||||||
tmp/**/*
|
tmp/**/*
|
||||||
|
gpg/diaspora*/*
|
||||||
|
|
|
||||||
1
Gemfile
1
Gemfile
|
|
@ -12,6 +12,7 @@ gem "bson_ext", "1.0.1"
|
||||||
gem "haml"
|
gem "haml"
|
||||||
gem 'roxml', :git => "git://github.com/Empact/roxml.git"
|
gem 'roxml', :git => "git://github.com/Empact/roxml.git"
|
||||||
|
|
||||||
|
gem 'gpgme'
|
||||||
|
|
||||||
#mai crazy async stuff
|
#mai crazy async stuff
|
||||||
#gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git', :require => 'em-synchrony/em-http'
|
#gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git', :require => 'em-synchrony/em-http'
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,10 @@ class DashboardsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive
|
def receive
|
||||||
store_objects_from_xml CGI::escape( params[:xml] )
|
|
||||||
|
puts "SOMEONE JUST SENT ME: #{params[:xml]}"
|
||||||
|
|
||||||
|
store_objects_from_xml params[:xml]
|
||||||
render :nothing => true
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,8 @@ class UsersController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@users = User.sort(:created_at.desc).all
|
@users = User.sort(:created_at.desc).all
|
||||||
end
|
end
|
||||||
|
def show
|
||||||
|
@user= Person.where(:id => params[:id]).first
|
||||||
|
@user_profile = @user.profile
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ class Person
|
||||||
key :email, String
|
key :email, String
|
||||||
key :url, String
|
key :url, String
|
||||||
key :active, Boolean, :default => false
|
key :active, Boolean, :default => false
|
||||||
|
key :key_fingerprint, String
|
||||||
|
|
||||||
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
||||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||||
|
|
||||||
|
|
@ -27,13 +28,20 @@ class Person
|
||||||
|
|
||||||
before_validation :clean_url
|
before_validation :clean_url
|
||||||
|
|
||||||
|
|
||||||
def real_name
|
def real_name
|
||||||
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
|
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def key
|
||||||
|
GPGME::Ctx.new.get_key key_fingerprint
|
||||||
|
end
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def url_unique?
|
def url_unique?
|
||||||
same_url = Person.first(:url => self.url)
|
same_url = Person.first(:url => self.url)
|
||||||
return same_url.nil? || same_url.id == self.id
|
return same_url.nil? || same_url.id == self.id
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ class User < Person
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
|
||||||
|
before_create :assign_key
|
||||||
validates_presence_of :profile
|
validates_presence_of :profile
|
||||||
|
|
||||||
before_validation :do_bad_things
|
before_validation :do_bad_things
|
||||||
|
|
@ -30,6 +31,11 @@ class User < Person
|
||||||
if p.save
|
if p.save
|
||||||
p.push_to_url friend_url
|
p.push_to_url friend_url
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def do_bad_things
|
||||||
|
self.password_confirmation = self.password
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_friend_request(friend_request_id)
|
def accept_friend_request(friend_request_id)
|
||||||
|
|
@ -54,10 +60,31 @@ class User < Person
|
||||||
self == post.person
|
self == post.person
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
protected
|
||||||
def do_bad_things
|
|
||||||
self.password_confirmation = self.password
|
def assign_key
|
||||||
|
keys = GPGME.list_keys(nil, true)
|
||||||
|
if keys.empty?
|
||||||
|
generate_key
|
||||||
|
end
|
||||||
|
self.key_fingerprint = GPGME.list_keys(nil, true).first.subkeys.first.fingerprint
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_key
|
||||||
|
puts "Generating key"
|
||||||
|
ctx = GPGME::Ctx.new
|
||||||
|
paramstring = "<GnupgKeyParms format=\"internal\">
|
||||||
|
Key-Type: DSA
|
||||||
|
Key-Length: 512
|
||||||
|
Subkey-Type: ELG-E
|
||||||
|
Subkey-Length: 512
|
||||||
|
Name-Real: #{self.real_name}
|
||||||
|
Name-Comment: #{self.url}
|
||||||
|
Name-Email: #{self.email}
|
||||||
|
Expire-Date: 0
|
||||||
|
Passphrase: #{self.password}
|
||||||
|
</GnupgKeyParms>"
|
||||||
|
ctx.genkey(paramstring, nil, nil)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1 +1,12 @@
|
||||||
%h1 user page!
|
%h1 user page!
|
||||||
|
.span-18.last
|
||||||
|
%h1= "#{@user.real_name}"
|
||||||
|
- if @user_profile
|
||||||
|
%p
|
||||||
|
%b url
|
||||||
|
%p
|
||||||
|
= @user.url
|
||||||
|
%p
|
||||||
|
%b Key Fingerprint
|
||||||
|
%p
|
||||||
|
= @user.key_fingerprint
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
# SQLite version 3.x
|
|
||||||
# gem install sqlite3-ruby (not necessary on OS X Leopard)
|
|
||||||
development:
|
|
||||||
adapter: sqlite3
|
|
||||||
database: db/development.sqlite3
|
|
||||||
pool: 5
|
|
||||||
timeout: 5000
|
|
||||||
|
|
||||||
# Warning: The database defined as "test" will be erased and
|
|
||||||
# re-generated from your development database when you run "rake".
|
|
||||||
# Do not set this db to the same as development or production.
|
|
||||||
test:
|
|
||||||
adapter: sqlite3
|
|
||||||
database: db/test.sqlite3
|
|
||||||
pool: 5
|
|
||||||
timeout: 5000
|
|
||||||
|
|
||||||
production:
|
|
||||||
adapter: sqlite3
|
|
||||||
database: db/production.sqlite3
|
|
||||||
pool: 5
|
|
||||||
timeout: 5000
|
|
||||||
|
|
@ -3,3 +3,6 @@ require File.expand_path('../application', __FILE__)
|
||||||
Haml::Template.options[:format] = :html5
|
Haml::Template.options[:format] = :html5
|
||||||
# Initialize the rails application
|
# Initialize the rails application
|
||||||
Diaspora::Application.initialize!
|
Diaspora::Application.initialize!
|
||||||
|
|
||||||
|
ENV['GNUPGHOME'] = File.expand_path("../../gpg/diaspora-#{Rails.env}/", __FILE__)
|
||||||
|
GPGME::check_version({})
|
||||||
|
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
defaults: &defaults
|
|
||||||
host: localhost
|
|
||||||
allow_dynamic_fields: false
|
|
||||||
parameterize_keys: true
|
|
||||||
persist_in_safe_mode: true
|
|
||||||
raise_not_found_error: false
|
|
||||||
reconnect_time: 3
|
|
||||||
use_object_ids: false
|
|
||||||
|
|
||||||
|
|
||||||
development:
|
|
||||||
<<: *defaults
|
|
||||||
database: diaspora_development
|
|
||||||
|
|
||||||
test:
|
|
||||||
<<: *defaults
|
|
||||||
database: diaspora_test
|
|
||||||
|
|
||||||
# set these environment variables on your prod server
|
|
||||||
production:
|
|
||||||
<<: *defaults
|
|
||||||
#host: <%= ENV['MONGOID_HOST'] %>
|
|
||||||
#port: <%= ENV['MONGOID_PORT'] %>
|
|
||||||
#username: <%= ENV['MONGOID_USERNAME'] %>
|
|
||||||
#password: <%= ENV['MONGOID_PASSWORD'] %>
|
|
||||||
#database: <%= ENV['MONGOID_DATABASE'] %>
|
|
||||||
|
|
@ -10,5 +10,5 @@ end
|
||||||
|
|
||||||
package :tools do
|
package :tools do
|
||||||
description 'Useful tools'
|
description 'Useful tools'
|
||||||
apt 'psmisc htop'
|
apt 'psmisc htop elinks'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ end
|
||||||
|
|
||||||
package :diaspora_dependencies do
|
package :diaspora_dependencies do
|
||||||
description 'random dependencies'
|
description 'random dependencies'
|
||||||
apt %w(libxslt1.1 libxslt1-dev libxml2)
|
apt %w(libxslt1.1 libxslt1-dev libxml2 libgpgme11-dev)
|
||||||
end
|
end
|
||||||
#package :diaspora do
|
#package :diaspora do
|
||||||
# description 'Diaspora'
|
# description 'Diaspora'
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ require "#{File.dirname(__FILE__)}/packages/ruby"
|
||||||
# If there's only one implementation of a virtual package, it's selected automatically, otherwise
|
# If there's only one implementation of a virtual package, it's selected automatically, otherwise
|
||||||
# the user is requested to select which one to use.
|
# the user is requested to select which one to use.
|
||||||
|
|
||||||
policy :diaspora, :roles => :tom, :backer do
|
policy :diaspora, :roles => [:tom, :backer] do
|
||||||
# requires :clean_dreamhost
|
# requires :clean_dreamhost
|
||||||
requires :tools
|
requires :tools
|
||||||
requires :rubygems
|
requires :rubygems
|
||||||
|
|
@ -43,7 +43,7 @@ policy :diaspora, :roles => :tom, :backer do
|
||||||
requires :webserver
|
requires :webserver
|
||||||
requires :scm
|
requires :scm
|
||||||
end
|
end
|
||||||
|
=begin
|
||||||
policy :ci, :roles => :ci do
|
policy :ci, :roles => :ci do
|
||||||
requires :tools
|
requires :tools
|
||||||
requires :rubygems
|
requires :rubygems
|
||||||
|
|
@ -54,7 +54,7 @@ policy :ci, :roles => :ci do
|
||||||
requires :scm
|
requires :scm
|
||||||
#add sqlite
|
#add sqlite
|
||||||
end
|
end
|
||||||
|
=end
|
||||||
# Deployment
|
# Deployment
|
||||||
#
|
#
|
||||||
# Defines script wide settings such as a delivery mechanism for executing commands on the target
|
# Defines script wide settings such as a delivery mechanism for executing commands on the target
|
||||||
|
|
|
||||||
8
lib/tasks/gpg.rake
Normal file
8
lib/tasks/gpg.rake
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace :gpg do
|
||||||
|
desc 'Clear the gpg keyrings'
|
||||||
|
task :clear do
|
||||||
|
ctx = GPGME::Ctx.new
|
||||||
|
keys = ctx.keys
|
||||||
|
keys.each{|k| ctx.delete_key(k, true)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -30,7 +30,6 @@ RSpec.configure do |config|
|
||||||
config.after(:each) do
|
config.after(:each) do
|
||||||
DatabaseCleaner.clean
|
DatabaseCleaner.clean
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
def stub_sockets_controller
|
def stub_sockets_controller
|
||||||
mock_sockets_controller = mock('sockets mock')
|
mock_sockets_controller = mock('sockets mock')
|
||||||
|
|
|
||||||
34
spec/user_encryption_spec.rb
Normal file
34
spec/user_encryption_spec.rb
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
require File.dirname(__FILE__) + '/spec_helper'
|
||||||
|
|
||||||
|
describe 'user encryption' do
|
||||||
|
before :all do
|
||||||
|
ctx = GPGME::Ctx.new
|
||||||
|
keys = ctx.keys
|
||||||
|
keys.each{|k| ctx.delete_key(k, true)}
|
||||||
|
@u = User.new
|
||||||
|
@u.email = "george@aol.com"
|
||||||
|
@u.password = "bluepin7"
|
||||||
|
@u.password_confirmation = "bluepin7"
|
||||||
|
@u.url = "www.example.com"
|
||||||
|
@u.profile = Profile.new( :first_name => "Bob", :last_name => "Smith" )
|
||||||
|
@u.profile.save
|
||||||
|
@u.save
|
||||||
|
end
|
||||||
|
|
||||||
|
# after :all do
|
||||||
|
#gpgdir = File.expand_path("../../db/gpg-#{Rails.env}", __FILE__)
|
||||||
|
#ctx = GPGME::Ctx.new
|
||||||
|
#keys = ctx.keys
|
||||||
|
#keys.each{|k| ctx.delete_key(k, true)}
|
||||||
|
#end
|
||||||
|
|
||||||
|
it 'should have a key fingerprint' do
|
||||||
|
@u.key_fingerprint.should_not be nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should retrieve a user key' do
|
||||||
|
@u.key.subkeys[0].fpr.should == @u.key_fingerprint
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue