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
|
||||
log/*.log
|
||||
tmp/**/*
|
||||
gpg/diaspora*/*
|
||||
|
|
|
|||
1
Gemfile
1
Gemfile
|
|
@ -12,6 +12,7 @@ gem "bson_ext", "1.0.1"
|
|||
gem "haml"
|
||||
gem 'roxml', :git => "git://github.com/Empact/roxml.git"
|
||||
|
||||
gem 'gpgme'
|
||||
|
||||
#mai crazy async stuff
|
||||
#gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git', :require => 'em-synchrony/em-http'
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ class DashboardsController < ApplicationController
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,8 @@ class UsersController < ApplicationController
|
|||
def index
|
||||
@users = User.sort(:created_at.desc).all
|
||||
end
|
||||
|
||||
def show
|
||||
@user= Person.where(:id => params[:id]).first
|
||||
@user_profile = @user.profile
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class Person
|
|||
key :email, String
|
||||
key :url, String
|
||||
key :active, Boolean, :default => false
|
||||
key :key_fingerprint, String
|
||||
|
||||
one :profile, :class_name => 'Profile', :foreign_key => :person_id
|
||||
many :posts, :class_name => 'Post', :foreign_key => :person_id
|
||||
|
|
@ -27,13 +28,20 @@ class Person
|
|||
|
||||
before_validation :clean_url
|
||||
|
||||
|
||||
def real_name
|
||||
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
|
||||
end
|
||||
|
||||
|
||||
|
||||
def key
|
||||
GPGME::Ctx.new.get_key key_fingerprint
|
||||
end
|
||||
protected
|
||||
|
||||
|
||||
|
||||
def url_unique?
|
||||
same_url = Person.first(:url => self.url)
|
||||
return same_url.nil? || same_url.id == self.id
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ class User < Person
|
|||
:recoverable, :rememberable, :trackable, :validatable
|
||||
|
||||
|
||||
before_create :assign_key
|
||||
validates_presence_of :profile
|
||||
|
||||
before_validation :do_bad_things
|
||||
|
|
@ -32,6 +33,11 @@ class User < Person
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def do_bad_things
|
||||
self.password_confirmation = self.password
|
||||
end
|
||||
|
||||
def accept_friend_request(friend_request_id)
|
||||
request = Request.where(:id => friend_request_id).first
|
||||
request.activate_friend
|
||||
|
|
@ -54,10 +60,31 @@ class User < Person
|
|||
self == post.person
|
||||
end
|
||||
|
||||
private
|
||||
def do_bad_things
|
||||
self.password_confirmation = self.password
|
||||
protected
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1 +1,12 @@
|
|||
%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
|
||||
# Initialize the rails application
|
||||
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
|
||||
description 'Useful tools'
|
||||
apt 'psmisc htop'
|
||||
apt 'psmisc htop elinks'
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ end
|
|||
|
||||
package :diaspora_dependencies do
|
||||
description 'random dependencies'
|
||||
apt %w(libxslt1.1 libxslt1-dev libxml2)
|
||||
apt %w(libxslt1.1 libxslt1-dev libxml2 libgpgme11-dev)
|
||||
end
|
||||
#package :diaspora do
|
||||
# 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
|
||||
# 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 :tools
|
||||
requires :rubygems
|
||||
|
|
@ -43,7 +43,7 @@ policy :diaspora, :roles => :tom, :backer do
|
|||
requires :webserver
|
||||
requires :scm
|
||||
end
|
||||
|
||||
=begin
|
||||
policy :ci, :roles => :ci do
|
||||
requires :tools
|
||||
requires :rubygems
|
||||
|
|
@ -54,7 +54,7 @@ policy :ci, :roles => :ci do
|
|||
requires :scm
|
||||
#add sqlite
|
||||
end
|
||||
|
||||
=end
|
||||
# Deployment
|
||||
#
|
||||
# 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
|
||||
DatabaseCleaner.clean
|
||||
end
|
||||
|
||||
end
|
||||
def stub_sockets_controller
|
||||
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