From b802db9194cd0edec983bf3e2ea69c932804385f Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 9 Jul 2010 17:41:01 -0400 Subject: [PATCH 01/49] writing signing --- app/models/post.rb | 7 +++++-- gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes spec/user_encryption_spec.rb | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index a0b69e08b..ca6e1ee83 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -9,7 +9,8 @@ class Post xml_accessor :person, :as => Person key :person_id, ObjectId - + key :owner_signature, String + many :comments, :class_name => 'Comment', :foreign_key => :post_id belongs_to :person, :class_name => 'Person' @@ -42,7 +43,9 @@ class Post self.newest(Person.first(:email => email)) end - + def verify_signature + GPGME.verify(owner + end protected def destroy_comments comments.each{|c| c.destroy} diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 303e6b5ce0e5946e93040d73e9c0a3fa0e467480..506a7c40031f6d9ed4e2126782dd16058d0c54ca 100644 GIT binary patch literal 600 zcmV-e0;m0FWcFY%lza+p6ZedPRfHU;TXAFCEd z?>r$nSBSGsoHCIRx#c$aW6L;1^(h_}g~`^Rm3dQYBb~qI^PzzH8t55_hX+=Bzoq&{ z4*FtIyaw$9|74e^!x0}1EKO-rI&d<*skN;+Z+ z-*BWJ#$%LJKC_#yB!2Q@_!`LCoWV0NRR$2~PyjD%(V0ukhjW13sFN{z0zywL~OUj~uY7J5V3BYV~=Y mUQl&@tiPaFlu=GwdJ-+-uA6}c4nume-Y6}FFQTV`ob(p!6()!P literal 600 zcmV-e0;m1?w;kglkgbB|hOAY28mQE%5#+7r6^8mZpm$a8Rdb6>i%fO|^xzX+^+`)GnB3 zqWKya@yF29_d_{Btl@C}@w*{-~5VN?3Is%$14GeEuh19LUQ&W-_6~AEx%BZ^-Zc@kId$p0sEvKKg2oZ}m{yh$c zKii))Kq{^m_fhtEXuD22Lp09h#}1z<%fKSNAPY(LEm1$BL=5>YN=aZ`jSf;SWTLMP z^3c-!r`UC25F_Ay`H|EvOE|wL$>Kl3KE*J{Q^kq=hbPv*&q!DQnX8fSMGnNPFP2*L zk%`hW89ooDnPp>(Od_zb;r&)D{J=_X;em(?t0Bfot-MT!RW0;87+u7n$dRR530)8# m^m#|3T(k;KY|jeB&#!9|zkp*zUUzEzOMQ9I$rvpks-0tbXfbX8 diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 6e9fb8960..02baba68a 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -30,5 +30,8 @@ describe 'user encryption' do @u.key.subkeys[0].fpr.should == @u.key_fingerprint end - + it 'should sign a message' do + message = Factory.create(:status_message, :user => @u) + message.verify_signature.should == true + end end From 8c45dd47022afdbc1a9369b244e9499e1f06ea69 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 9 Jul 2010 18:15:17 -0400 Subject: [PATCH 02/49] testing signing --- app/models/post.rb | 21 +++++++++++++++++++-- gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes spec/user_encryption_spec.rb | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index ca6e1ee83..425c6c199 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -9,7 +9,6 @@ class Post xml_accessor :person, :as => Person key :person_id, ObjectId - key :owner_signature, String many :comments, :class_name => 'Comment', :foreign_key => :post_id belongs_to :person, :class_name => 'Person' @@ -43,10 +42,28 @@ class Post self.newest(Person.first(:email => email)) end +#ENCRYPTION + before_save :sign_if_mine + key :owner_signature, String def verify_signature - GPGME.verify(owner + validity = true + signed_text = GPGME.verify(){ |signature| + if signature.validity == GPGME::VALIDITY_FULL + validity = validity && true + else + validity = validity && false + end + } + validity = validity && (signed_text == to_xml.to_s) + validity end protected + def sign_if_mine + if self.person == User.first + self.owner_signature = GPGME::sign(to_xml.to_s,nil,{:armor=> true}) + end + end + def destroy_comments comments.each{|c| c.destroy} end diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 506a7c40031f6d9ed4e2126782dd16058d0c54ca..bf240de5179db612deaa37991110b80cc901d49b 100644 GIT binary patch literal 600 zcmV-e0;m08U3uPed_I(wQQ(|D>j5UY8i5X$mV11NU2RpTo~Aq(5H=`ZdmkxV3O@qc z5(jtBHY8h%Gs`N6ZYPtcXB6$I+8=|4Luvoz-wlk%UBtSH7j}Uz)I23$xPE@dOonb! zC<^nd6^W^^3|rv1l`Mw45i|Xo8iN}Z@ZW0t7Z%NA0a}AZab1iZ=ja&n5WntU#7Cu{ zl*n+iQ85F%5nY-?M64yNsi+Z?_XH;}@*XXQ03i zU@}MSF=PAnhTpsfg~TOxLM?)<4>;OooAr<8*>8S!13CPQB%1>={O4#dkrCCLWS3Lq zNmbra6sL^U&maQQ8^1lDtUUMIS=Kmr*fbxvqwqiT?=giKp)y*yVExZ>hDh_4nxqUb z9`8CFc4lZ59fHy-MHayLQzF(b0jD!%QTe0Dj)TN_;~tt(u7*1YmSN?zO)zAw)j6&w msfPJ)JW5l1<1i5re3lGzU@PD+5E!zf*I2A4j0t4>3h7Stc^dox literal 600 zcmV-e0;m0FWcFY%lza+p6ZedPRfHU;TXAFCEd z?>r$nSBSGsoHCIRx#c$aW6L;1^(h_}g~`^Rm3dQYBb~qI^PzzH8t55_hX+=Bzoq&{ z4*FtIyaw$9|74e^!x0}1EKO-rI&d<*skN;+Z+ z-*BWJ#$%LJKC_#yB!2Q@_!`LCoWV0NRR$2~PyjD%(V0ukhjW13sFN{z0zywL~OUj~uY7J5V3BYV~=Y mUQl&@tiPaFlu=GwdJ-+-uA6}c4nume-Y6}FFQTV`ob(p!6()!P diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 02baba68a..d23705946 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -31,7 +31,7 @@ describe 'user encryption' do end it 'should sign a message' do - message = Factory.create(:status_message, :user => @u) + message = Factory.create(:status_message, :person => @u) message.verify_signature.should == true end end From 2f5ec3d7c48672db184ce115d5f0e10b64292a4a Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 9 Jul 2010 19:17:07 -0400 Subject: [PATCH 03/49] added a bunch of public keys to test ring --- app/models/post.rb | 14 +++++--------- gpg/diaspora-test/pubring.gpg | Bin 608 -> 37206 bytes gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes gpg/diaspora-test/trustdb.gpg | Bin 1360 -> 1360 bytes spec/user_encryption_spec.rb | 34 ++++++++++++++++++++++------------ 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 425c6c199..ae6d11af3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -46,16 +46,12 @@ class Post before_save :sign_if_mine key :owner_signature, String def verify_signature - validity = true - signed_text = GPGME.verify(){ |signature| - if signature.validity == GPGME::VALIDITY_FULL - validity = validity && true - else - validity = validity && false - end + return false unless owner_signature && person.key_fingerprint + GPGME.verify(owner_signature){ |signature| + return signature.validity == GPGME::VALIDITY_FULL + #validity = validity && person.key_fingerprint == signature.fpr } - validity = validity && (signed_text == to_xml.to_s) - validity + #validity = validity && (signed_text == to_xml.to_s) end protected def sign_if_mine diff --git a/gpg/diaspora-test/pubring.gpg b/gpg/diaspora-test/pubring.gpg index 33ce2b7d97c572c0cda9d3d5af95e178ec1ea429..da64a4ec3f9cf91f82d9b3fcf051ac2b773926ca 100644 GIT binary patch literal 37206 zcmbrlWmsLywkz4y>#g_d)hlHkT$UEE z$^n%snojKWasw2|aIGSC^V~V7fS`7-(59EqV<0aE%Ng^0U~wUR0^mHQaE`=lwC*hu z>2J`gP1beOTCJJv5Y3DxgnQ>ArL)yR9^tgOeqWC@b2NpQa)b%_Cf;xFc;Lvd-Q?;W zYbl5qfAa0_T{7ZNJDUH3#n>Jgs{euGfMUjmB0&06)DrJ)$Xqpxpq(L+l8uG4IT4k) zv$H+thYxOUZuBPZ1~&HACi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X zrDSlo>p_jCr)a&23s$LK658x)G7s%rY-sU%g;2+%FU(`DlyPX&mk-k zh^;frER|1xE1RvxVQboc83V=jtF?me8@dkX<5ZkNZFfWPw8{r%X}`x$Jn+^Kj6q2Q zEwVNQ7|J1=KWj3J5R72D=G0i%=%#p-3T=_6gxyCp>M4+%sIk!y+|<%P9#m{)*2Y{`yHo<&>t6$A`!6_=46~dm!UvF zw^y8^HSzoy+sFGr-J7mP7JPENud9`DjSoKJly798eK2-Jr6{cbN-cDQTWo0cB+TSx z+(z_6$YuITa300zQgvOAMXRY84w8$e01qrRoV z`)~Yi`hb%EKl)tw0!n3}fT+Mh-nZ3%nzO&(_`G`{?nKB9kxDcD=U%`-{yg$ZS=u1% zuMTWIe!7ev7NUE;^A3r(P$(EOC(6l=KyT7Qg_I_or?-cFSHlWg9;xeA0XhbEr%;0| zEpkG<2_wHv0wC!3K0kn+F9CK;m3AuVTpi;y0ujFL4!$Wo2TIllk|-5q73*3i%6jc9 z+^z`x5W`FTp`&F1VkyeM~Pb-dV$%t_f= z?zHn`txbUzFK>izat@L+++}&^VE!aTGRPiO#VRzEn*y$`$}1eYP}LW5YZSpMtUTX} z!2DIG$cnX$R6fSCB~(D7DxgsS2)IPNoDCQkrXR^R0M@0Qfi-6({AzKI#=w<37=@qs z?RQP=VHc)@@5eXGO@wMS&j)c0VK*oy*JzY1C@WVh<}3bl@1svksbzK5SiA5nd+;dxqu&M z+T(Rjk9M}Gm??(Pc>QA?Fwl1l+UzJu`_1^q2VsW{{f-Gj7|nhCqY9sri~-6tMg4d1 F{T~5T*gyaP delta 8 Pcmcb%i0J{#h6E-65_AJ` diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index bf240de5179db612deaa37991110b80cc901d49b..6239b704b74d098aa5ee333cbec250c905e1d2ac 100644 GIT binary patch literal 600 zcmV-e0;l~=O)A8ID6ATxtAmSS(_%KU(o)!VP11!2RE;^lAS*yT8Uq!##KPK2+ zs)203)C1-3NXjv0chJmOZwT zwNgi~xziUD#{nl%Ag#HSiGo-y`(klt%W1YVHnuBGe?x7-pcMF;vzYZENw|a}PDTt7 z!C)@UWbEX9<(_$_@+88IYBs`M5(Ufa6+_ZTQN-_-cDkymuB{29^m0Wv7rFKIHByXJ$)`(CVccChJYQC-g zZWkPAyr5$)MT`0!MlV2us-y+QETej5UY8i5X$mV11NU2RpTo~Aq(5H=`ZdmkxV3O@qc z5(jtBHY8h%Gs`N6ZYPtcXB6$I+8=|4Luvoz-wlk%UBtSH7j}Uz)I23$xPE@dOonb! zC<^nd6^W^^3|rv1l`Mw45i|Xo8iN}Z@ZW0t7Z%NA0a}AZab1iZ=ja&n5WntU#7Cu{ zl*n+iQ85F%5nY-?M64yNsi+Z?_XH;}@*XXQ03i zU@}MSF=PAnhTpsfg~TOxLM?)<4>;OooAr<8*>8S!13CPQB%1>={O4#dkrCCLWS3Lq zNmbra6sL^U&maQQ8^1lDtUUMIS=Kmr*fbxvqwqiT?=giKp)y*yVExZ>hDh_4nxqUb z9`8CFc4lZ59fHy-MHayLQzF(b0jD!%QTe0Dj)TN_;~tt(u7*1YmSN?zO)zAw)j6&w msfPJ)JW5l1<1i5re3lGzU@PD+5E!zf*I2A4j0t4>3h7Stc^dox diff --git a/gpg/diaspora-test/trustdb.gpg b/gpg/diaspora-test/trustdb.gpg index 5a8d5b32514d9f23108ec7a185b4da49de21cef0..f52c08a1d1246168f675f3b46571116dc1be3da8 100644 GIT binary patch delta 28 jcmcb>b%9HOF})z2nVFH5k%581$9(yb%9HOF})z2nVFH5k%581$EYA(oV%Y|q diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 4298cb785..ad841d22b 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -5,17 +5,13 @@ describe 'user encryption' 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 + + end + before do + @u = Factory.create(:user) @u.send(:assign_key) @u.save end - # after :all do #gpgdir = File.expand_path("../../db/gpg-#{Rails.env}", __FILE__) #ctx = GPGME::Ctx.new @@ -30,9 +26,23 @@ describe 'user encryption' do it 'should retrieve a user key' do @u.key.subkeys[0].fpr.should == @u.key_fingerprint end - - it 'should sign a message' do - message = Factory.create(:status_message, :person => @u) - message.verify_signature.should == true + describe 'signing and verifying' do + + it 'should sign a message on create' do + message = Factory.create(:status_message, :person => @u) + message.verify_signature.should be true + end + + it 'should not be able to verify a message from a person without a key' do + person = Factory.create(:person) + message = Factory.create(:status_message, :person => person) + message.verify_signature.should be false + end + + it 'should know if the signature is from the wrong person' do + pending + my_message = Factory.create( + end + end end From eec66395c1f26b9f1d40cb1db553acef63b7a1b2 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 9 Jul 2010 20:22:01 -0400 Subject: [PATCH 04/49] Removed key password --- app/models/user.rb | 3 +-- gpg/diaspora-test/pubring.gpg | Bin 37206 -> 37204 bytes gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes gpg/diaspora-test/secring.gpg | Bin 738 -> 659 bytes gpg/diaspora-test/trustdb.gpg | Bin 1360 -> 1440 bytes spec/user_encryption_spec.rb | 6 +++++- 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index a7bdcd294..aa1cbb296 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -77,7 +77,7 @@ class User < Person def assign_key keys = GPGME.list_keys(nil, true) if keys.empty? - #generate_key + generate_key end self.key_fingerprint = GPGME.list_keys(nil, true).first.subkeys.first.fingerprint end @@ -94,7 +94,6 @@ Name-Real: #{self.real_name} Name-Comment: #{self.url} Name-Email: #{self.email} Expire-Date: 0 -Passphrase: #{self.password} " ctx.genkey(paramstring, nil, nil) diff --git a/gpg/diaspora-test/pubring.gpg b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xf0j`(f- AXaE2J diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 6239b704b74d098aa5ee333cbec250c905e1d2ac..43eed01099182d4478a216fa9e71643377647dd7 100644 GIT binary patch literal 600 zcmV-e0;l~-hoy&JA7X33*D36Glz+V3xbXO4N%oXIbo9>5k{*2;*uG9X08_+qofZG= zycWIfP_vcdMW!X_09k>a@pIH`UgB5bcmtTOwpuuF<9Ayt#+cdU;I-1q8|x_K zr|B6VWdyxVGnj@n)>r$2U~J6s*>%PO>?KqYo`!U$#OU@rrI}N?M^4~NQA9lNj{%ZX zv@V?&(dCZTQ&Z{?Z9--vgSm6EM}ffDty#g*iKX^!A5<{B!M5qPT!v{n38v2>hCdCx zfU|`H=?x#(6R(Y+k{Z}x++ul8ZM(bIF5DA0V6y54X?nb|XkSjRiXMOAPv8N*t46s{ zG}H&4hodnF1b1d7pztn54ugcTC%LKde+!bUS31z>&+p+VZJiAS6lxD{RN)y#{D3l@ zE)TnCte<1qz3~!x`5J%o(eHoAtJdc_e6o|9|5Sh%R2h!TFL_b049dn8|M=m}E-tO9 z>uYHCRZpX}96AUhg;%Os*ssUoNeH!rkWy#14vZ45?r4dkx4b^Q1a0EO9k8dO@4M2F zXa=mhe$H^n>nwX`N_tprPY>0M;4^2~4KvCC-?Y%qw--2Z{otW8aXrM1|F=vkL7!)% zw9@;k>e2g!1BE$()I8?2jni72!}als|b>oUeGckiS*Qs-j>&4A> z1f&#==qwBkCJehSDU+P3PfQ2Dtx*BxB0|QqyN*1QPjiG0j+sU_od(Co44X=LO;r0C m0{fRQ?&6twInoX$edqg^80K_#9~BTs<#It7IsoB_8RBTBQZPCI literal 600 zcmV-e0;l~=O)A8ID6ATxtAmSS(_%KU(o)!VP11!2RE;^lAS*yT8Uq!##KPK2+ zs)203)C1-3NXjv0chJmOZwT zwNgi~xziUD#{nl%Ag#HSiGo-y`(klt%W1YVHnuBGe?x7-pcMF;vzYZENw|a}PDTt7 z!C)@UWbEX9<(_$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gpg/diaspora-test/trustdb.gpg index f52c08a1d1246168f675f3b46571116dc1be3da8..400230545039aa9ec79a0aec691c329305ff42f7 100644 GIT binary patch delta 141 zcmcb>wSZfIF})z2nVFH5k%581$9#{~L__h3>U@k!6Ah&{1{`ByWSA_@s-6UtL<2kw zOercV)2?i7)vW$xw(tG3d;3h-SFu4Y|U&x6o`i&>+#bp~`sLa>eW^)Xx I4xx+z0Gq%c1poj5 delta 59 zcmZ3$eSu4WF})z2nVFH5k%581$9(y Date: Sat, 10 Jul 2010 02:25:48 -0400 Subject: [PATCH 05/49] RS IZ Friday night, key_fingerprint serialization weirdness --- app/models/person.rb | 4 ++++ app/models/request.rb | 8 +++++--- app/models/user.rb | 9 +++++---- gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes lib/common.rb | 4 ++++ spec/factories.rb | 4 +++- spec/models/request_spec.rb | 2 +- spec/user_encryption_spec.rb | 24 +++++++++++++++++++++++- 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 48999c664..fc0943614 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -6,6 +6,7 @@ class Person xml_accessor :url xml_accessor :profile, :as => Profile xml_accessor :_id + xml_accessor :key_fingerprint key :email, String key :url, String @@ -37,6 +38,9 @@ class Person GPGME::Ctx.new.get_key key_fingerprint end + def export_key + GPGME::export(key_fingerprint, :armor => true) + end protected diff --git a/app/models/request.rb b/app/models/request.rb index 95623d9a8..9740373de 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -8,12 +8,14 @@ class Request xml_accessor :person, :as => Person xml_accessor :destination_url xml_accessor :callback_url + xml_accessor :exported_key key :destination_url, String key :callback_url, String - key :person_id, ObjectId + key :person, Person#_id, ObjectId + key :exported_key, String - belongs_to :person + #belongs_to :person validates_presence_of :destination_url, :callback_url @@ -22,7 +24,7 @@ class Request def self.instantiate(options ={}) person = options[:from] - self.new(:destination_url => options[:to], :callback_url => person.url, :person => person) + self.new(:destination_url => options[:to], :callback_url => person.url, :person => person, :exported_key => person.export_key) end def activate_friend diff --git a/app/models/user.rb b/app/models/user.rb index aa1cbb296..83fd24888 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,10 +28,10 @@ class User < Person ######### Friend Requesting def send_friend_request_to(friend_url) unless Person.where(:url => friend_url).first - p = Request.instantiate(:to => friend_url, :from => self) - if p.save - p.push_to_url friend_url - p + request = Request.instantiate(:to => friend_url, :from => self) + if request.save + request.push_to_url friend_url + request end end end @@ -41,6 +41,7 @@ class User < Person request.activate_friend request.person = self request.destination_url = request.callback_url + request.exported_key = self.export_key request.push_to_url(request.callback_url) request.destroy end diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 43eed01099182d4478a216fa9e71643377647dd7..b7077ad63746b9d872bd00e3de10f8ed9c31f551 100644 GIT binary patch literal 600 zcmV-e0;m1?U}L4itnsTAbzhz6ewf&qBl#pfqDGcR%z1UcrWLGQ$1EPH*83=ZR|3ZH zK&^dE>0(a(xa0x&Ve@wELg9!&rjE2gzoWrkh{z47WR^mC5YbMUGcdCyJ!RyB*0rjIG!GDUyDk+JFcW)fM zjIov{ASZiJVE^4#M0GsFwB9u=3sk3d;XF7CWiNQa>L?u}a7~B{f!-LqI@d@lMA?1p zIjDKt`_D^lX%`JndA+Rtj1UCGpf*HK@J<%Yr-4~STICuIS=(BCeOwE`KW7w@=Rn4! zl<3Nd!zxjp8R%|?u;I1M2|W1i9bTzM&^l#K`YlL2MCxgqKW{r4om!ufgsWWV;CEZ^ z((<7ypP_vakJTi?fsR;FQi^}kt3VgyS@%!2ByWps?fL5n7t( literal 600 zcmV-e0;l~-hoy&JA7X33*D36Glz+V3xbXO4N%oXIbo9>5k{*2;*uG9X08_+qofZG= zycWIfP_vcdMW!X_09k>a@pIH`UgB5bcmtTOwpuuF<9Ayt#+cdU;I-1q8|x_K zr|B6VWdyxVGnj@n)>r$2U~J6s*>%PO>?KqYo`!U$#OU@rrI}N?M^4~NQA9lNj{%ZX zv@V?&(dCZTQ&Z{?Z9--vgSm6EM}ffDty#g*iKX^!A5<{B!M5qPT!v{n38v2>hCdCx zfU|`H=?x#(6R(Y+k{Z}x++ul8ZM(bIF5DA0V6y54X?nb|XkSjRiXMOAPv8N*t46s{ zG}H&4hodnF1b1d7pztn54ugcTC%LKde+!bUS31z>&+p+VZJiAS6lxD{RN)y#{D3l@ zE)TnCte<1qz3~!x`5J%o(eHoAtJdc_e6o|9|5Sh%R2h!TFL_b049dn8|M=m}E-tO9 z>uYHCRZpX}96AUhg;%Os*ssUoNeH!rkWy#14vZ45?r4dkx4b^Q1a0EO9k8dO@4M2F zXa=mhe$H^n>nwX`N_tprPY>0M;4^2~4KvCC-?Y%qw--2Z{otW8aXrM1|F=vkL7!)% zw9@;k>e2g!1BE$()I8?2jni72!}als|b>oUeGckiS*Qs-j>&4A> z1f&#==qwBkCJehSDU+P3PfQ2Dtx*BxB0|QqyN*1QPjiG0j+sU_od(Co44X=LO;r0C m0{fRQ?&6twInoX$edqg^80K_#9~BTs<#It7IsoB_8RBTBQZPCI diff --git a/lib/common.rb b/lib/common.rb index c0fd6947f..3f1b76994 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -17,7 +17,11 @@ module Diaspora body = parse_body_contents_from_xml(xml) body.children.each do |post| begin + puts "people: #{Person.count}" + puts "requests: #{Request.count}" object = post.name.camelize.constantize.from_xml post.to_s + puts "people: #{Person.count}" + puts "requests: #{Request.count}" object.person = parse_owner_from_xml post.to_s if object.respond_to? :person objects << object rescue diff --git a/spec/factories.rb b/spec/factories.rb index 5467a6b39..90eddd3ba 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -10,8 +10,9 @@ Factory.define :profile do |p| end Factory.define :person do |p| - p.email "bob@aol.com" + p.email "bob-person@aol.com" p.sequence(:url) {|n|"http://google-#{n}.com/"} + p.key_fingerprint GPGME::list_keys("Aditi").first.subkeys.first.fingerprint p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) end @@ -20,6 +21,7 @@ Factory.define :user do |u| u.password "bluepin7" u.password_confirmation "bluepin7" u.url "www.example.com/" + u.key_fingerprint GPGME.list_keys(nil, true).first.subkeys.first.fingerprint u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" ) end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index f3357fc73..a6289c4be 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -11,7 +11,7 @@ describe Request do end it 'should generate xml for the User as a Person' do - user = User.create(:email => "rob@bob.com") + user = Factory.build(:user, :email => "rob@bob.com") user.profile = Factory.create(:profile) diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index b07fb39d1..b3737feae 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/spec_helper' +include ApplicationHelper describe 'user encryption' do before :all do @@ -28,7 +29,28 @@ describe 'user encryption' do end describe 'key exchange on friending' do - + it 'should send over a public key' do + Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request) + request = @u.send_friend_request_to("http://example.com/") + Request.build_xml_for([request]).include?( @u.export_key).should be true + end + + it 'should receive and marshal a public key from a request' do + puts "THIS IS FUCKED UP" + person = Factory.build(:person ) + original_key = person.export_key + person.save + + request = Request.instantiate(:to =>"http://www.google.com/", :from => person) + + xml = Request.build_xml_for [request] + person.destroy + + store_objects_from_xml(xml) + + new_person = Person.first(:url => request.callback_url) + new_person.export_key.should == original_key + end end describe 'signing and verifying' do From 7eba033c0d9f095b9a630921f505fe6abfb9ddbc Mon Sep 17 00:00:00 2001 From: ilya Date: Sat, 10 Jul 2010 05:29:57 -0400 Subject: [PATCH 06/49] Revert "RS IZ Friday night, key_fingerprint serialization weirdness" This reverts commit c6e16835df9c5d46d0ec5e0f1860da1ef4c0986a. --- app/models/person.rb | 4 ---- app/models/request.rb | 8 +++----- app/models/user.rb | 9 ++++----- gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes lib/common.rb | 4 ---- spec/factories.rb | 4 +--- spec/models/request_spec.rb | 2 +- spec/user_encryption_spec.rb | 24 +----------------------- 8 files changed, 10 insertions(+), 45 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index fc0943614..48999c664 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -6,7 +6,6 @@ class Person xml_accessor :url xml_accessor :profile, :as => Profile xml_accessor :_id - xml_accessor :key_fingerprint key :email, String key :url, String @@ -38,9 +37,6 @@ class Person GPGME::Ctx.new.get_key key_fingerprint end - def export_key - GPGME::export(key_fingerprint, :armor => true) - end protected diff --git a/app/models/request.rb b/app/models/request.rb index 9740373de..95623d9a8 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -8,14 +8,12 @@ class Request xml_accessor :person, :as => Person xml_accessor :destination_url xml_accessor :callback_url - xml_accessor :exported_key key :destination_url, String key :callback_url, String - key :person, Person#_id, ObjectId - key :exported_key, String + key :person_id, ObjectId - #belongs_to :person + belongs_to :person validates_presence_of :destination_url, :callback_url @@ -24,7 +22,7 @@ class Request def self.instantiate(options ={}) person = options[:from] - self.new(:destination_url => options[:to], :callback_url => person.url, :person => person, :exported_key => person.export_key) + self.new(:destination_url => options[:to], :callback_url => person.url, :person => person) end def activate_friend diff --git a/app/models/user.rb b/app/models/user.rb index 83fd24888..aa1cbb296 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -28,10 +28,10 @@ class User < Person ######### Friend Requesting def send_friend_request_to(friend_url) unless Person.where(:url => friend_url).first - request = Request.instantiate(:to => friend_url, :from => self) - if request.save - request.push_to_url friend_url - request + p = Request.instantiate(:to => friend_url, :from => self) + if p.save + p.push_to_url friend_url + p end end end @@ -41,7 +41,6 @@ class User < Person request.activate_friend request.person = self request.destination_url = request.callback_url - request.exported_key = self.export_key request.push_to_url(request.callback_url) request.destroy end diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index b7077ad63746b9d872bd00e3de10f8ed9c31f551..43eed01099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Yr-4~STICuIS=(BCeOwE`KW7w@=Rn4! zl<3Nd!zxjp8R%|?u;I1M2|W1i9bTzM&^l#K`YlL2MCxgqKW{r4om!ufgsWWV;CEZ^ z((<7ypP_vakJTi?fsR;FQi^}kt3VgyS@%!2ByWps?fL5n7t( diff --git a/lib/common.rb b/lib/common.rb index 3f1b76994..c0fd6947f 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -17,11 +17,7 @@ module Diaspora body = parse_body_contents_from_xml(xml) body.children.each do |post| begin - puts "people: #{Person.count}" - puts "requests: #{Request.count}" object = post.name.camelize.constantize.from_xml post.to_s - puts "people: #{Person.count}" - puts "requests: #{Request.count}" object.person = parse_owner_from_xml post.to_s if object.respond_to? :person objects << object rescue diff --git a/spec/factories.rb b/spec/factories.rb index 90eddd3ba..5467a6b39 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -10,9 +10,8 @@ Factory.define :profile do |p| end Factory.define :person do |p| - p.email "bob-person@aol.com" + p.email "bob@aol.com" p.sequence(:url) {|n|"http://google-#{n}.com/"} - p.key_fingerprint GPGME::list_keys("Aditi").first.subkeys.first.fingerprint p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) end @@ -21,7 +20,6 @@ Factory.define :user do |u| u.password "bluepin7" u.password_confirmation "bluepin7" u.url "www.example.com/" - u.key_fingerprint GPGME.list_keys(nil, true).first.subkeys.first.fingerprint u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" ) end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index a6289c4be..f3357fc73 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -11,7 +11,7 @@ describe Request do end it 'should generate xml for the User as a Person' do - user = Factory.build(:user, :email => "rob@bob.com") + user = User.create(:email => "rob@bob.com") user.profile = Factory.create(:profile) diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index b3737feae..b07fb39d1 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -1,5 +1,4 @@ require File.dirname(__FILE__) + '/spec_helper' -include ApplicationHelper describe 'user encryption' do before :all do @@ -29,28 +28,7 @@ describe 'user encryption' do end describe 'key exchange on friending' do - it 'should send over a public key' do - Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request) - request = @u.send_friend_request_to("http://example.com/") - Request.build_xml_for([request]).include?( @u.export_key).should be true - end - - it 'should receive and marshal a public key from a request' do - puts "THIS IS FUCKED UP" - person = Factory.build(:person ) - original_key = person.export_key - person.save - - request = Request.instantiate(:to =>"http://www.google.com/", :from => person) - - xml = Request.build_xml_for [request] - person.destroy - - store_objects_from_xml(xml) - - new_person = Person.first(:url => request.callback_url) - new_person.export_key.should == original_key - end + end describe 'signing and verifying' do From 1bed575b907d06ef1300cab0e58461b15f3df83a Mon Sep 17 00:00:00 2001 From: ilya Date: Sat, 10 Jul 2010 06:09:53 -0400 Subject: [PATCH 07/49] Added the Key Fingerprint validation to the person model(defaults to empty string) --- app/models/person.rb | 10 +++++++--- app/models/request.rb | 4 +++- app/models/user.rb | 1 + gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes spec/factories.rb | 4 +++- spec/models/request_spec.rb | 2 +- spec/user_encryption_spec.rb | 23 ++++++++++++++++++++++- 7 files changed, 37 insertions(+), 7 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 48999c664..8a06ca688 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -6,11 +6,12 @@ class Person xml_accessor :url xml_accessor :profile, :as => Profile xml_accessor :_id + xml_accessor :key_fingerprint key :email, String key :url, String key :active, Boolean, :default => false - key :key_fingerprint, String + key :key_fingerprint, String, :default => "" one :profile, :class_name => 'Profile', :foreign_key => :person_id many :posts, :class_name => 'Post', :foreign_key => :person_id @@ -18,7 +19,7 @@ class Person timestamps! before_validation :clean_url - validates_presence_of :email, :url + validates_presence_of :email, :url, :key_fingerprint validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix @@ -36,7 +37,10 @@ class Person def key GPGME::Ctx.new.get_key key_fingerprint end - + + def export_key + GPGME::export(key_fingerprint, :armor => true) + end protected diff --git a/app/models/request.rb b/app/models/request.rb index 95623d9a8..ef935ac03 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -8,10 +8,12 @@ class Request xml_accessor :person, :as => Person xml_accessor :destination_url xml_accessor :callback_url + xml_accessor :exported_key, :cdata => true key :destination_url, String key :callback_url, String key :person_id, ObjectId + key :exported_key, String belongs_to :person @@ -22,7 +24,7 @@ class Request def self.instantiate(options ={}) person = options[:from] - self.new(:destination_url => options[:to], :callback_url => person.url, :person => person) + self.new(:destination_url => options[:to], :callback_url => person.url, :person => person, :exported_key => person.export_key) end def activate_friend diff --git a/app/models/user.rb b/app/models/user.rb index aa1cbb296..9c7393ecd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -57,6 +57,7 @@ class User < Person friend_request.activate_friend friend_request.destroy else + friend_request.person.save friend_request.save end end diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 43eed01099182d4478a216fa9e71643377647dd7..3662498f087ad7b8c9e7148f3cbd05527aa1322a 100644 GIT binary patch literal 600 zcmV-e0;l~)hAhB1g_<%i~YBl>bey+a6{KbYx*!ym0_v-A0=-__a zD4VpV9J6DiHr!0hujp#g9cE#R59Do!h+G$&u$_oc4%n9tntZ%#Zv>>WNaf>|9w>Iw zbovO9nv$p0tB4};pqzC8Kt82~#IHo)$`?s;Z|?j&)RCe_8f_2ApCi!H_D4GVDWb`$ z_}FMt^j>>oU(T6EjMC$GnU-ErWl(s$$RtDA|5tnGowpfu5>%I-kx1DKBM47zE_$0v zSIR^!ru42gw)X9Z51g;Rrqp68_OJg!orB~rr(QB3BcTPsjOU{+DCoMkd7DaGJVSFB zfW-XgN-+s303=X#&Yshfp#Xul4FPRe@TRUl@brBa^(jHbb8`ejyGWrdr!u1t=^|1J za0L>zSZ{b4leLBI`kmSg70l$61_J@kMMcQgh3m_1m2^I#SF^S(HEa%XxWRwE(MB2b z0tbX2YJ95k+UC~5k{*2;*uG9X08_+qofZG= zycWIfP_vcdMW!X_09k>a@pIH`UgB5bcmtTOwpuuF<9Ayt#+cdU;I-1q8|x_K zr|B6VWdyxVGnj@n)>r$2U~J6s*>%PO>?KqYo`!U$#OU@rrI}N?M^4~NQA9lNj{%ZX zv@V?&(dCZTQ&Z{?Z9--vgSm6EM}ffDty#g*iKX^!A5<{B!M5qPT!v{n38v2>hCdCx zfU|`H=?x#(6R(Y+k{Z}x++ul8ZM(bIF5DA0V6y54X?nb|XkSjRiXMOAPv8N*t46s{ zG}H&4hodnF1b1d7pztn54ugcTC%LKde+!bUS31z>&+p+VZJiAS6lxD{RN)y#{D3l@ zE)TnCte<1qz3~!x`5J%o(eHoAtJdc_e6o|9|5Sh%R2h!TFL_b049dn8|M=m}E-tO9 z>uYHCRZpX}96AUhg;%Os*ssUoNeH!rkWy#14vZ45?r4dkx4b^Q1a0EO9k8dO@4M2F zXa=mhe$H^n>nwX`N_tprPY>0M;4^2~4KvCC-?Y%qw--2Z{otW8aXrM1|F=vkL7!)% zw9@;k>e2g!1BE$()I8?2jni72!}als|b>oUeGckiS*Qs-j>&4A> z1f&#==qwBkCJehSDU+P3PfQ2Dtx*BxB0|QqyN*1QPjiG0j+sU_od(Co44X=LO;r0C m0{fRQ?&6twInoX$edqg^80K_#9~BTs<#It7IsoB_8RBTBQZPCI diff --git a/spec/factories.rb b/spec/factories.rb index 5467a6b39..90eddd3ba 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -10,8 +10,9 @@ Factory.define :profile do |p| end Factory.define :person do |p| - p.email "bob@aol.com" + p.email "bob-person@aol.com" p.sequence(:url) {|n|"http://google-#{n}.com/"} + p.key_fingerprint GPGME::list_keys("Aditi").first.subkeys.first.fingerprint p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) end @@ -20,6 +21,7 @@ Factory.define :user do |u| u.password "bluepin7" u.password_confirmation "bluepin7" u.url "www.example.com/" + u.key_fingerprint GPGME.list_keys(nil, true).first.subkeys.first.fingerprint u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" ) end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index f3357fc73..a6289c4be 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -11,7 +11,7 @@ describe Request do end it 'should generate xml for the User as a Person' do - user = User.create(:email => "rob@bob.com") + user = Factory.build(:user, :email => "rob@bob.com") user.profile = Factory.create(:profile) diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index b07fb39d1..3d0a26685 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -1,4 +1,5 @@ require File.dirname(__FILE__) + '/spec_helper' +include ApplicationHelper describe 'user encryption' do before :all do @@ -28,7 +29,27 @@ describe 'user encryption' do end describe 'key exchange on friending' do - + it 'should send over a public key' do + Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request) + request = @u.send_friend_request_to("http://example.com/") + Request.build_xml_for([request]).include?( @u.export_key).should be true + end + + it 'should receive and marshal a public key from a request' do + person = Factory.build(:person, :url => "http://test.url/" ) + original_key = person.export_key + + request = Request.instantiate(:to =>"http://www.google.com/", :from => person) + + xml = Request.build_xml_for [request] + puts xml + + person.destroy + store_objects_from_xml(xml) + + new_person = Person.first(:url => "http://test.url/") + new_person.export_key.should == original_key + end end describe 'signing and verifying' do From 72e751453530be04aab0376b1ceffe6fd5c4ff94 Mon Sep 17 00:00:00 2001 From: ilya Date: Sat, 10 Jul 2010 23:30:24 -0400 Subject: [PATCH 08/49] MS fixed your key fingerprint bug. ROML sux. all things which are marshalled as a class need to be after the other fields, because those fields were ignored. also, ids were no long being marshalled correctlyw --- app/models/person.rb | 5 +++-- gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes spec/user_encryption_spec.rb | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 8a06ca688..7ace2308d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -4,14 +4,15 @@ class Person xml_accessor :email xml_accessor :url - xml_accessor :profile, :as => Profile xml_accessor :_id xml_accessor :key_fingerprint + xml_accessor :profile, :as => Profile + key :email, String key :url, String key :active, Boolean, :default => false - key :key_fingerprint, String, :default => "" + key :key_fingerprint, String one :profile, :class_name => 'Profile', :foreign_key => :person_id many :posts, :class_name => 'Post', :foreign_key => :person_id diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 3662498f087ad7b8c9e7148f3cbd05527aa1322a..493229c8d4e6a7f7c601cc1effdbcbb6d4de23c1 100644 GIT binary patch literal 600 zcmV-e0;m0J9H_HDTHkKTQ`0A7BpI(Xdhdasrve>APjT2e<1{JZPUQYgMNBzQa?V%J z))x)^>9p#FS>RxP9ssz(AXk5H1k>?Sm1B$0+M9HZf z+$D90tn^wXe*=!Vv;NPOKJ{W^h{6nE4Yk3axk(YZWZMo#z_!>@sn(T+b> zbvA;_;e{u2-h;b@1qFOpZzygIjC$Lp7$h}9F=3%tv9LZy8S{;9Vug@WyeFQ}%J0G^ z_FJeTlR~wiDc@mtRScCMCk}QLL3qgtquKO%<5M`O=OeWx8UMK`%p7?LLRSanLz54| zDA!W$NKZu~EWAn?0AZSj-+|Z8+Ey?tuw%IOj4jPqtH2xC!{c?;16al+Ye0?;IbZ9% z_;=CCyb8~#KZni+qC@J2rRVvzt&7X{VU-UT4w59fLIu4YXZ{QWp+;edNov0DnvJ9| zrYR;ALi$$C;YOQR&y`Y+J-XultQvVA!$1i z2>{{{)V%54MS;(P7BCA#Pcx6!rVGy{R2r=q)LKD9`ofBEDo36{`JcvvF&gmInT!Db m#Cqxa9~ivQkZhA>Tt2%^(G9TdR0Bk-?Kk7CI{#JZsca=4bR*&b literal 600 zcmV-e0;l~)hAhB1g_<%i~YBl>bey+a6{KbYx*!ym0_v-A0=-__a zD4VpV9J6DiHr!0hujp#g9cE#R59Do!h+G$&u$_oc4%n9tntZ%#Zv>>WNaf>|9w>Iw zbovO9nv$p0tB4};pqzC8Kt82~#IHo)$`?s;Z|?j&)RCe_8f_2ApCi!H_D4GVDWb`$ z_}FMt^j>>oU(T6EjMC$GnU-ErWl(s$$RtDA|5tnGowpfu5>%I-kx1DKBM47zE_$0v zSIR^!ru42gw)X9Z51g;Rrqp68_OJg!orB~rr(QB3BcTPsjOU{+DCoMkd7DaGJVSFB zfW-XgN-+s303=X#&Yshfp#Xul4FPRe@TRUl@brBa^(jHbb8`ejyGWrdr!u1t=^|1J za0L>zSZ{b4leLBI`kmSg70l$61_J@kMMcQgh3m_1m2^I#SF^S(HEa%XxWRwE(MB2b z0tbX2YJ95k+UC~ "http://test.url/" ) + person.key_fingerprint.nil?.should== false + #should move this to friend request, but i found it here + f = person.key_fingerprint + id = person.id original_key = person.export_key request = Request.instantiate(:to =>"http://www.google.com/", :from => person) xml = Request.build_xml_for [request] - puts xml - person.destroy store_objects_from_xml(xml) - + Person.all.count.should == 2 new_person = Person.first(:url => "http://test.url/") + new_person.key_fingerprint.nil?.should == false + new_person.id.should == id + new_person.key_fingerprint.should == f new_person.export_key.should == original_key end end From 603fc151201dc68c4c35427b70649bb71a401d4d Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 10 Jul 2010 23:54:25 -0700 Subject: [PATCH 09/49] MS IZ added the env setting line to factories --- config/environments/test.rb | 3 ++- gpg/diaspora-test/random_seed | Bin 600 -> 600 bytes spec/factories.rb | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 7f40c884b..2611a12fa 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -26,7 +26,8 @@ Diaspora::Application.configure do config.action_mailer.delivery_method = :test config.threadsafe! - + ENV['GNUPGHOME'] = File.expand_path("../../gpg/diaspora-#{Rails.env}/", __FILE__) + GPGME::check_version({}) # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types diff --git a/gpg/diaspora-test/random_seed b/gpg/diaspora-test/random_seed index 3662498f087ad7b8c9e7148f3cbd05527aa1322a..ea68b1833981eaceb24bbce9dcf30c074fe5ca53 100644 GIT binary patch literal 600 zcmV-e0;m0e)=SNAHlz}hz==YZ3g(Sg;2=#tutCdQt73!Hla-x1wECdJ!lRJ6br%Al zn^c&Y`%Vk-wI=a;J(8T(7cAk?^3<|8<*rj|e3$GJa3yMg#URKSEsigA6jIgBNys)D zs%MGGhZum{9>F zzG6k+bQhv@CL6dyyh1)End~^Y(u7qi?(<)!>stm$YZke%VxfCSq##mN6mE2 z^hI5dunNNP{D*}Eh>@MbWk}dtq`1g0VirC_({KeZzsKCr#(#H?@eh!HQ{+;IQGU8m zCwrT2V55^nnT~^qH)q8`j}}<4FZrk%pxVcUjf?G8R~kQ~*c^|R%(*Ara8o1~`maY6 z6HN37+p>pkf*Qb^_nqkO-9%9cFsDl59KLP_8l=^j@K2mlJjDKgnK`92iI>Xhr&OFF zc}2!D;e~7By}B#7oVwzmGlb^GFN(?^JJAfQ4-bi5!nK=Fg{lJwdTI^FN8!s*WIl$O1x5b m4BZ9AmT#z|7~vrosXH72rWFSO0}94}Ix6o4iNLz_<%i~YBl>bey+a6{KbYx*!ym0_v-A0=-__a zD4VpV9J6DiHr!0hujp#g9cE#R59Do!h+G$&u$_oc4%n9tntZ%#Zv>>WNaf>|9w>Iw zbovO9nv$p0tB4};pqzC8Kt82~#IHo)$`?s;Z|?j&)RCe_8f_2ApCi!H_D4GVDWb`$ z_}FMt^j>>oU(T6EjMC$GnU-ErWl(s$$RtDA|5tnGowpfu5>%I-kx1DKBM47zE_$0v zSIR^!ru42gw)X9Z51g;Rrqp68_OJg!orB~rr(QB3BcTPsjOU{+DCoMkd7DaGJVSFB zfW-XgN-+s303=X#&Yshfp#Xul4FPRe@TRUl@brBa^(jHbb8`ejyGWrdr!u1t=^|1J za0L>zSZ{b4leLBI`kmSg70l$61_J@kMMcQgh3m_1m2^I#SF^S(HEa%XxWRwE(MB2b z0tbX2YJ95k+UC~ "Bob", :last_name => "Smith" ) end From 4562de3525f0f5065f6c3a4bfeda6105c6628246 Mon Sep 17 00:00:00 2001 From: ilya Date: Sun, 11 Jul 2010 00:25:08 -0400 Subject: [PATCH 10/49] MS IZ merged master into encryption --- Gemfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 7be06ae84..4436fb08d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'http://rubygems.org' source 'http://gemcutter.org' gem 'rails', :git =>'http://github.com/rails/rails.git' -gem 'bundler' +gem 'bundler', '1.0.0.beta.4' gem 'mongo_mapper', :git => "http://github.com/BadMinus/mongomapper.git" gem 'devise', :git => "http://github.com/BadMinus/devise.git" gem 'jnunemaker-validatable', :git => "http://github.com/BadMinus/validatable.git" @@ -26,8 +26,8 @@ gem 'will_paginate', '3.0.pre' group :test do gem 'rspec', '>= 2.0.0.beta.12' - gem 'rspec-rails', ">= 2.0.0.beta.8" - gem "mocha" + gem 'rspec-rails' + gem "mocha" gem 'webrat' gem 'redgreen' gem 'autotest' From bb146820bfe3733d4247f40482b4888f24148d65 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 12 Jul 2010 11:43:16 -0700 Subject: [PATCH 11/49] IZ RS, new Gemfile, ignoring the random_seed --- .gitignore | 1 + Gemfile | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 91e987e1c..40116a515 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ tmp/**/* Gemfile.lock gpg/diaspora-development/*.gpg gpg/diaspora-production/*.gpg +gpg/*/random_seed diff --git a/Gemfile b/Gemfile index a5df7bd95..e244b25a4 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'http://rubygems.org' source 'http://gemcutter.org' gem 'rails', '3.0.0.beta4' -gem 'bundler' +gem 'bundler', '0.9.26' gem 'mongo_mapper', :git => "http://github.com/BadMinus/mongomapper.git" gem 'devise', :git => "http://github.com/BadMinus/devise.git" gem 'jnunemaker-validatable', :git => "http://github.com/BadMinus/validatable.git" @@ -25,8 +25,8 @@ gem 'will_paginate', '3.0.pre' group :test do - gem 'rspec', '>= 2.0.0.beta.12' - gem 'rspec-rails' + gem 'rspec', '>= 2.0.0.beta.17' + gem 'rspec-rails', '2.0.0.beta.17' gem "mocha" gem 'webrat' gem 'redgreen' From 406c00aeb600ce6bd7293278f2655d60ccc733d6 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 12 Jul 2010 18:31:20 -0700 Subject: [PATCH 12/49] RS IZ; using detached signatures and verification things --- app/models/person.rb | 7 ++++-- app/models/post.rb | 10 +++++--- app/models/user.rb | 1 + gpg/diaspora-test/pubring.gpg | Bin 37204 -> 37204 bytes gpg/diaspora-test/trustdb.gpg | Bin 1440 -> 1440 bytes spec/fixtures/msg.xml.clear.asc | 24 ++++++++++++++++++ spec/fixtures/msg.xml.detached.asc | 7 ++++++ spec/fixtures/msg.xml.normal.asc | 13 ++++++++++ spec/user_encryption_spec.rb | 38 ++++++++++++++++++++++++++--- 9 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 spec/fixtures/msg.xml.clear.asc create mode 100644 spec/fixtures/msg.xml.detached.asc create mode 100644 spec/fixtures/msg.xml.normal.asc diff --git a/app/models/person.rb b/app/models/person.rb index d299b35fc..82e7e4f9b 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -26,7 +26,7 @@ class Person validates_true_for :url, :logic => lambda { self.url_unique?} - after_destroy :remove_all_traces + after_destroy :remove_all_traces, :remove_key scope :friends, where(:_type => "Person", :active => true) @@ -66,6 +66,9 @@ class Person Comment.delete_all(:person_id => self.id) end - + def remove_key + ctx = GPGME::Ctx.new + ctx.delete_key(key) + end end diff --git a/app/models/post.rb b/app/models/post.rb index c29c9510b..c6ce1fb5f 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -47,8 +47,11 @@ class Post key :owner_signature, String def verify_signature return false unless owner_signature && person.key_fingerprint - GPGME.verify(owner_signature){ |signature| - return signature.validity == GPGME::VALIDITY_FULL + + GPGME::verify(owner_signature, {:always_trust => true}){ |signature| + return signature.status == GPGME::GPG_ERR_NO_ERROR && + #signature.to_s.include?("Good signature from ") && + signature.fpr == person.key_fingerprint #validity = validity && person.key_fingerprint == signature.fpr } #validity = validity && (signed_text == to_xml.to_s) @@ -56,7 +59,8 @@ class Post protected def sign_if_mine if self.person == User.first - self.owner_signature = GPGME::sign(to_xml.to_s,nil,{:armor=> true}) + self.owner_signature = GPGME::sign(to_xml.to_s,nil,{ + :armor=> true, :mode => GPGME::SIG_MODE_DETACH}) end end diff --git a/app/models/user.rb b/app/models/user.rb index 1e7aa4bd7..0c1f2c599 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -60,6 +60,7 @@ class User < Person friend_request.activate_friend friend_request.destroy else + GPGME.import(friend_request.exported_key) friend_request.person.save friend_request.save end diff --git a/gpg/diaspora-test/pubring.gpg b/gpg/diaspora-test/pubring.gpg index 721861b75a5e99eca960124fa3cff36f86ab78d0..58a5cbaac94eb4c07d5297e2851cf94413bbd804 100644 GIT binary patch delta 19 bcmcbzi0R5ArVX1tH{bOwciz0-Q;P)vWD*Gt delta 19 bcmcbzi0R5ArVX1tH|zDPv20%NS?vq}T^k6V diff --git a/gpg/diaspora-test/trustdb.gpg b/gpg/diaspora-test/trustdb.gpg index 400230545039aa9ec79a0aec691c329305ff42f7..b0d16300fd81ce54692f296bff0e563cdaa96a44 100644 GIT binary patch delta 28 jcmZ3$y?|SQF})z2nVFH5k%581$2zTJVxag&^-5L%Sd0dD delta 28 jcmZ3$y?|SQF})z2nVFH5k%581$9#{~#6aXobjSo#Kg diff --git a/spec/fixtures/msg.xml.clear.asc b/spec/fixtures/msg.xml.clear.asc new file mode 100644 index 000000000..e80a6a26f --- /dev/null +++ b/spec/fixtures/msg.xml.clear.asc @@ -0,0 +1,24 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + + jimmy's 1 whales + <_id>4c3b7cf9312f91367f000004 + + bob1@aol.com + http://www.example.com/ + <_id>4c3b7c64312f913664000005 + 0264242496D4B585297BF236BEEFE6DEBE3407AA + + Bob + Smith + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.10 (GNU/Linux) + +iEYEARECAAYFAkw7qBYACgkQ5hWCpTN+yRI3uwCgj4RhakQQP9K3Lu7fkHYydcEB +J30AnjQZjwY7e1VBkYp6NmL3z2039s5R +=ifDI +-----END PGP SIGNATURE----- diff --git a/spec/fixtures/msg.xml.detached.asc b/spec/fixtures/msg.xml.detached.asc new file mode 100644 index 000000000..1f3dbcc21 --- /dev/null +++ b/spec/fixtures/msg.xml.detached.asc @@ -0,0 +1,7 @@ +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.10 (GNU/Linux) + +iEYEABECAAYFAkw7p+YACgkQ5hWCpTN+yRIrHgCghpIwNtqODBwaEjL6duFNcTKv ++XYAoKWvcAz76dmAvD71QkTue5F67cq8 +=jIOx +-----END PGP SIGNATURE----- diff --git a/spec/fixtures/msg.xml.normal.asc b/spec/fixtures/msg.xml.normal.asc new file mode 100644 index 000000000..90949d2ff --- /dev/null +++ b/spec/fixtures/msg.xml.normal.asc @@ -0,0 +1,13 @@ +-----BEGIN PGP MESSAGE----- +Version: GnuPG v1.4.10 (GNU/Linux) + +owGbwMvMwCT4TLRpqXHdSSHGtYxbkthzi9P1KnJzfKyXH7cpLkksKS2Oz00tLk5M +T7XjUlCwgbGzMnNzK9WLFQwVyjMSc1KLbfSRVcVnptiZJBsnmSenWRobGqVZGhqb +macZgICJjT5IFqSqILWoOD8PxARyUnMTM3PskvKTDB0S83P0kvNzbfQhYhD50qIc +u4ySkgIrff3y8nK91IrE3IKcVJA6fRt9kCREGcJmMxOYzWYmYJtN4TYD1WWnVsan +ZealpxYVFGXmldgZGJmZGAGhpZmLiZOphamRpbmTm5GxmZOrq5urmYurk6uxiYG5 +o6ONPrpOiHkFRflpmTmpEB6Qn5ZZVFwSn5eYm2rnlJ9ko4/EhynJSYSJBOdmlmTY +6CMEIGbqIxkK5EBDy0YfLVo63FgYBJkY2FiZQJHGwMUpAIvRzhkMC04tX8j8bv3T +QpXm+waPDzQ0HT38p45hntLiCTerfep5uNpMLHWWW75e9vqqAwA= +=k+0d +-----END PGP MESSAGE----- diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 574a78592..75630ee32 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -13,6 +13,7 @@ describe 'user encryption' do @u.send(:assign_key) @u.save end + # after :all do #gpgdir = File.expand_path("../../db/gpg-#{Rails.env}", __FILE__) #ctx = GPGME::Ctx.new @@ -20,6 +21,17 @@ describe 'user encryption' do #keys.each{|k| ctx.delete_key(k, true)} #end + it 'should remove the key from the keyring on person destroy' do + person = Factory.create :person + keyid = person.key_fingerprint + original_key = person.export_key + GPGME.list_keys(keyid).count.should be 1 + person.destroy + GPGME.list_keys(keyid).count.should be 0 + GPGME.import(original_key) + GPGME.list_keys(keyid).count.should be 1 + end + it 'should have a key fingerprint' do @u.key_fingerprint.should_not be nil end @@ -65,14 +77,34 @@ describe 'user encryption' do end it 'should not be able to verify a message from a person without a key' do - person = Factory.create(:person) + person = Factory.create(:person, :key_fingerprint => "123") message = Factory.create(:status_message, :person => person) message.verify_signature.should be false end - it 'should know if the signature is from the wrong person' do - pending + it 'should verify a remote signature' do + person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) + message = Factory.create(:status_message, :person => person, + :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) + # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) + # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) + + message.verify_signature.should be true end + it 'should know if the signature is from the wrong person' do + person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) + message = Factory.create(:status_message, :person => person, + :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) + # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) + # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) + + message.person = @u + message.verify_signature.should be false + end + + it 'should know if the signature is for the wrong text' do + pending + end end end From b9146cbb41543294696e19a82a41ef597a5d7587 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 12 Jul 2010 20:42:22 -0700 Subject: [PATCH 13/49] RS IZ; now signatures work like in real life --- app/models/post.rb | 9 ++++++--- spec/fixtures/msg.xml | 14 ++++++++++++++ spec/fixtures/msg.xml.detached.asc | 6 +++--- spec/user_encryption_spec.rb | 10 +++++++--- 4 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 spec/fixtures/msg.xml diff --git a/app/models/post.rb b/app/models/post.rb index c6ce1fb5f..872c3942e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -47,8 +47,11 @@ class Post key :owner_signature, String def verify_signature return false unless owner_signature && person.key_fingerprint - - GPGME::verify(owner_signature, {:always_trust => true}){ |signature| + puts to_xml.to_s + puts owner_signature + GPGME::verify(owner_signature, nil, {:armor => true, :always_trust => true}){ |signature| + puts signature + puts signature.inspect return signature.status == GPGME::GPG_ERR_NO_ERROR && #signature.to_s.include?("Good signature from ") && signature.fpr == person.key_fingerprint @@ -60,7 +63,7 @@ class Post def sign_if_mine if self.person == User.first self.owner_signature = GPGME::sign(to_xml.to_s,nil,{ - :armor=> true, :mode => GPGME::SIG_MODE_DETACH}) + :armor=> true}) end end diff --git a/spec/fixtures/msg.xml b/spec/fixtures/msg.xml new file mode 100644 index 000000000..aa1fbf054 --- /dev/null +++ b/spec/fixtures/msg.xml @@ -0,0 +1,14 @@ + + jimmy's 1 whales + <_id>4c3b7cf9312f91367f000004 + + bob1@aol.com + http://www.example.com/ + <_id>4c3b7c64312f913664000005 + 0264242496D4B585297BF236BEEFE6DEBE3407AA + + Bob + Smith + + + \ No newline at end of file diff --git a/spec/fixtures/msg.xml.detached.asc b/spec/fixtures/msg.xml.detached.asc index 1f3dbcc21..66012caef 100644 --- a/spec/fixtures/msg.xml.detached.asc +++ b/spec/fixtures/msg.xml.detached.asc @@ -1,7 +1,7 @@ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) -iEYEABECAAYFAkw7p+YACgkQ5hWCpTN+yRIrHgCghpIwNtqODBwaEjL6duFNcTKv -+XYAoKWvcAz76dmAvD71QkTue5F67cq8 -=jIOx +iEYEABECAAYFAkw72oUACgkQ5hWCpTN+yRLSuwCgwphc3LWMM0LOZ5wreKjNeaja +BCsAoIzYO9AG3fgV0KbtIFAtuwlNiFxt +=W2K4 -----END PGP SIGNATURE----- diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 75630ee32..784866b6a 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -85,7 +85,7 @@ describe 'user encryption' do it 'should verify a remote signature' do person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) message = Factory.create(:status_message, :person => person, - :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) + :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) @@ -95,7 +95,7 @@ describe 'user encryption' do it 'should know if the signature is from the wrong person' do person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) message = Factory.create(:status_message, :person => person, - :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) + :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) @@ -104,7 +104,11 @@ describe 'user encryption' do end it 'should know if the signature is for the wrong text' do - pending + person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) + message = Factory.create(:status_message, :message => 'I love VENISON', :person => person, + :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) + message.verify_signature.should be false + end end end From 6d431e9459a3cafa1ee03d3921b68ed81f884d52 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 11:01:11 -0700 Subject: [PATCH 14/49] signing tests sort of almost done --- app/models/post.rb | 10 ++++++---- app/models/user.rb | 4 ++-- gpg/diaspora-test/pubring.gpg | Bin 37204 -> 37824 bytes gpg/diaspora-test/secring.gpg | Bin 659 -> 1332 bytes gpg/diaspora-test/trustdb.gpg | Bin 1440 -> 1520 bytes spec/user_encryption_spec.rb | 16 +++++++++++----- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 872c3942e..2ca631ad5 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -47,16 +47,18 @@ class Post key :owner_signature, String def verify_signature return false unless owner_signature && person.key_fingerprint - puts to_xml.to_s - puts owner_signature - GPGME::verify(owner_signature, nil, {:armor => true, :always_trust => true}){ |signature| + validity = nil + message = GPGME::verify(owner_signature, nil, {:armor => true, :always_trust => true}){ |signature| puts signature puts signature.inspect - return signature.status == GPGME::GPG_ERR_NO_ERROR && + validity = signature.status == GPGME::GPG_ERR_NO_ERROR && #signature.to_s.include?("Good signature from ") && signature.fpr == person.key_fingerprint #validity = validity && person.key_fingerprint == signature.fpr } + puts message + puts to_xml.to_s + return validity && message == to_xml.to_s #validity = validity && (signed_text == to_xml.to_s) end protected diff --git a/app/models/user.rb b/app/models/user.rb index 0c1f2c599..79172b595 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -91,11 +91,11 @@ class User < Person protected def assign_key - keys = GPGME.list_keys(nil, true) + keys = GPGME.list_keys(real_name, true) if keys.empty? generate_key end - self.key_fingerprint = GPGME.list_keys(nil, true).first.subkeys.first.fingerprint + self.key_fingerprint = GPGME.list_keys(real_name, true).first.subkeys.first.fingerprint end def generate_key diff --git a/gpg/diaspora-test/pubring.gpg b/gpg/diaspora-test/pubring.gpg index 58a5cbaac94eb4c07d5297e2851cf94413bbd804..46e8a37d1e84b145278442b92bfe4314e1562434 100644 GIT binary patch delta 608 zcmV-m0-ycVq5{CD0((ei~sg|LpnAhP#V2Tx@2_hqWX%t$C+G&%hjuBf9t^g!oJv5DMj5D zwWG=;t7e`bGZOAqYTvD=D77*0*TGe30sIJc?MUh?ai|j@I%eeDxlQ(jpy4A<_SHnR zT|hIeQ;;fNXdp*UJ^xKx&WY%9!;4? uH9f#xn3Nr00$W$=L*8Z<0HB<-PKJ6tWVOk$hoE#2uFdT+X*RPajV=T`ND%q} delta 14 WcmX@GoaxFUrVU!Xo2T__u>b%xa|TZU diff --git a/gpg/diaspora-test/secring.gpg b/gpg/diaspora-test/secring.gpg index eccac99054ce371cce695651ca7c87822f54f8e0..81164ee0e2175f201621b3d36808fc614a4e2428 100644 GIT binary patch delta 658 zcmV;D0&V@11+)sVlLCK~`vgoprn?aW0LIe_oFYf8lpGumRU4joRb1*X<$Y5c-!BFDa$&Jx2ayhJA*!PYv;D*&Lco){d*+OK!gZY?2A z8O+C2HWGOO`v;5v_Ig7)HX=|Oy-K=dbnK$~in+&`T!hQjt7w1g!2QC$*i|V--4?Z@ z$|S31o*y$3?p12vt*0opG4R*HRcQhI2zBj9>ML=m6CgTfy) zM*y7}%kRRBrz_hI#K~#8w>yn2@um`goQTqmH>xKx&WYz@^hX4 sSdo}fpip0AEv=uYF|@M*6$61PgaVPg3>~t6oAe$U{x37%?=|Vk!kg}Ht@==P2xSZajM5$w delta 41 xcmeysy?|SQF})z2nVFH5k%581$2zTJVxag&^)|+d3EZ0>Fcvay)?_Yc0s!4-3n~Br diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 784866b6a..f56a3dba7 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -83,12 +83,18 @@ describe 'user encryption' do end it 'should verify a remote signature' do - person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) - message = Factory.create(:status_message, :person => person, - :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) - # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) + person = Factory.create(:person, + :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, + :profile => Profile.create(:first_name => 'Remote', + :last_name => 'Friend'), + :email => 'somewhere@else.com', + :url => 'http://distant-example.com/', + :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') + puts person.inspect + message = Factory.create(:status_message, :person => person) + message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, {:armor => true, :signers => [person.key]}) + message.save # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) - message.verify_signature.should be true end From a219801c2dbd7b27c538582a194bab9b5225e79b Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 11:10:04 -0700 Subject: [PATCH 15/49] Now using detached signatures --- app/models/post.rb | 10 ++++---- spec/user_encryption_spec.rb | 44 +++++++++++++++++------------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 2ca631ad5..d648c1af5 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -48,7 +48,7 @@ class Post def verify_signature return false unless owner_signature && person.key_fingerprint validity = nil - message = GPGME::verify(owner_signature, nil, {:armor => true, :always_trust => true}){ |signature| + GPGME::verify(owner_signature, to_xml.to_s, {:armor => true, :always_trust => true}){ |signature| puts signature puts signature.inspect validity = signature.status == GPGME::GPG_ERR_NO_ERROR && @@ -56,16 +56,16 @@ class Post signature.fpr == person.key_fingerprint #validity = validity && person.key_fingerprint == signature.fpr } - puts message + #puts message puts to_xml.to_s - return validity && message == to_xml.to_s + return validity# && message == to_xml.to_s #validity = validity && (signed_text == to_xml.to_s) end protected def sign_if_mine if self.person == User.first - self.owner_signature = GPGME::sign(to_xml.to_s,nil,{ - :armor=> true}) + self.owner_signature = GPGME::sign(to_xml.to_s,nil, + {:armor=> true, :mode => GPGME::SIG_MODE_DETACH}) end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index f56a3dba7..41842af3d 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -70,7 +70,15 @@ describe 'user encryption' do end describe 'signing and verifying' do - + before do + @person = Factory.create(:person, + :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, + :profile => Profile.create(:first_name => 'Remote', + :last_name => 'Friend'), + :email => 'somewhere@else.com', + :url => 'http://distant-example.com/', + :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') + end it 'should sign a message on create' do message = Factory.create(:status_message, :person => @u) message.verify_signature.should be true @@ -83,38 +91,28 @@ describe 'user encryption' do end it 'should verify a remote signature' do - person = Factory.create(:person, - :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, - :profile => Profile.create(:first_name => 'Remote', - :last_name => 'Friend'), - :email => 'somewhere@else.com', - :url => 'http://distant-example.com/', - :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') - puts person.inspect - message = Factory.create(:status_message, :person => person) - message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, {:armor => true, :signers => [person.key]}) - message.save # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) - # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) + message = Factory.create(:status_message, :person => @person) + message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) + message.save message.verify_signature.should be true end it 'should know if the signature is from the wrong person' do - person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) - message = Factory.create(:status_message, :person => person, - :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) - # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.detached.asc").read) - # :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.clear.asc").read) - + message = Factory.create(:status_message, :person => @person) + message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.person = @u message.verify_signature.should be false end it 'should know if the signature is for the wrong text' do - person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Ilya").first.subkeys.first.fpr) - message = Factory.create(:status_message, :message => 'I love VENISON', :person => person, - :owner_signature => File.open(File.dirname(__FILE__) + "/fixtures/msg.xml.normal.asc").read) + message = Factory.create(:status_message, :person => @person) + message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) + message.message = 'I love VENISON' + message.save message.verify_signature.should be false - end end end From 25940cf5676f9dd2ae04265133408526faa9cd1f Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 11:12:49 -0700 Subject: [PATCH 16/49] Removed stray puts --- app/models/post.rb | 9 +-------- app/models/user.rb | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index d648c1af5..fe271c76b 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -49,17 +49,10 @@ class Post return false unless owner_signature && person.key_fingerprint validity = nil GPGME::verify(owner_signature, to_xml.to_s, {:armor => true, :always_trust => true}){ |signature| - puts signature - puts signature.inspect validity = signature.status == GPGME::GPG_ERR_NO_ERROR && - #signature.to_s.include?("Good signature from ") && signature.fpr == person.key_fingerprint - #validity = validity && person.key_fingerprint == signature.fpr } - #puts message - puts to_xml.to_s - return validity# && message == to_xml.to_s - #validity = validity && (signed_text == to_xml.to_s) + return validity end protected def sign_if_mine diff --git a/app/models/user.rb b/app/models/user.rb index 79172b595..757a6471a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -31,7 +31,6 @@ class User < Person def send_friend_request_to(friend_url) unless Person.where(:url => friend_url).first p = Request.instantiate(:to => friend_url, :from => self) - puts p.inspect if p.save p.push_to_url friend_url end From 7952385cdbddd29c66667f722bc8d2ac556f7aaf Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 11:24:57 -0700 Subject: [PATCH 17/49] added newlines to post --- app/models/post.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index fe271c76b..d2d69895d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -44,7 +44,9 @@ class Post #ENCRYPTION before_save :sign_if_mine + key :owner_signature, String + def verify_signature return false unless owner_signature && person.key_fingerprint validity = nil @@ -54,6 +56,7 @@ class Post } return validity end + protected def sign_if_mine if self.person == User.first From 8d525f2d4f63c56d82520f83fe442fd5d16ce160 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 11:27:05 -0700 Subject: [PATCH 18/49] fixed warzombie --- config/routes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 08b1f6f55..3a4cb4393 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ Diaspora::Application.routes.draw do |map| resources :comments resources :requests - match 'warzombie', :to => "dashboard#warzombie" + match 'warzombie', :to => "dashboards#warzombie" #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file From add9961ca422802ec231a524a9911f3d97e61002 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 11:41:57 -0700 Subject: [PATCH 19/49] Now signing only xml accessors other than person --- app/models/post.rb | 16 ++++++++++++++-- spec/user_encryption_spec.rb | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index d2d69895d..23ed10167 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -47,10 +47,22 @@ class Post key :owner_signature, String + def signable_accessors + accessors = self.class.roxml_attrs.collect{|definition| + definition.accessor} + accessors.delete 'person' + accessors + end + + def signable_string + signable_accessors.collect{|accessor| + (self.send accessor.to_sym).to_s}.join ';' + end + def verify_signature return false unless owner_signature && person.key_fingerprint validity = nil - GPGME::verify(owner_signature, to_xml.to_s, {:armor => true, :always_trust => true}){ |signature| + GPGME::verify(owner_signature, signable_string, {:armor => true, :always_trust => true}){ |signature| validity = signature.status == GPGME::GPG_ERR_NO_ERROR && signature.fpr == person.key_fingerprint } @@ -60,7 +72,7 @@ class Post protected def sign_if_mine if self.person == User.first - self.owner_signature = GPGME::sign(to_xml.to_s,nil, + self.owner_signature = GPGME::sign(signable_string,nil, {:armor=> true, :mode => GPGME::SIG_MODE_DETACH}) end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 41842af3d..bb02e29b0 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -92,7 +92,7 @@ describe 'user encryption' do it 'should verify a remote signature' do message = Factory.create(:status_message, :person => @person) - message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, + message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.save message.verify_signature.should be true @@ -100,7 +100,7 @@ describe 'user encryption' do it 'should know if the signature is from the wrong person' do message = Factory.create(:status_message, :person => @person) - message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, + message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.person = @u message.verify_signature.should be false @@ -108,7 +108,7 @@ describe 'user encryption' do it 'should know if the signature is for the wrong text' do message = Factory.create(:status_message, :person => @person) - message.owner_signature = GPGME.sign(message.to_xml.to_s, nil, + message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.message = 'I love VENISON' message.save From 964ee65b110393b7770d5a8e1294e0f21c013e09 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 12:20:00 -0700 Subject: [PATCH 20/49] rs iz ; the signature of the signable_accessors are now in the xml --- app/models/post.rb | 13 +++++++++---- spec/factories.rb | 2 +- spec/user_encryption_spec.rb | 9 +++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 23ed10167..5a576e9bc 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -6,6 +6,7 @@ class Post include Diaspora::Webhooks xml_accessor :_id + xml_accessor :owner_signature xml_accessor :person, :as => Person key :person_id, ObjectId @@ -51,6 +52,7 @@ class Post accessors = self.class.roxml_attrs.collect{|definition| definition.accessor} accessors.delete 'person' + accessors.delete 'owner_signature' accessors end @@ -62,16 +64,19 @@ class Post def verify_signature return false unless owner_signature && person.key_fingerprint validity = nil - GPGME::verify(owner_signature, signable_string, {:armor => true, :always_trust => true}){ |signature| - validity = signature.status == GPGME::GPG_ERR_NO_ERROR && - signature.fpr == person.key_fingerprint + GPGME::verify(owner_signature, signable_string, + {:armor => true, :always_trust => true}){ |signature| + puts signature + validity = signature.status == GPGME::GPG_ERR_NO_ERROR && + signature.fpr == person.key_fingerprint + puts validity } return validity end protected def sign_if_mine - if self.person == User.first + if self.person == User.owner self.owner_signature = GPGME::sign(signable_string,nil, {:armor=> true, :mode => GPGME::SIG_MODE_DETACH}) end diff --git a/spec/factories.rb b/spec/factories.rb index 240dfb017..9780f2b09 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -24,7 +24,7 @@ Factory.define :user do |u| u.password "bluepin7" u.password_confirmation "bluepin7" u.url "www.example.com/" - u.key_fingerprint GPGME.list_keys(nil, true).first.subkeys.first.fingerprint + u.key_fingerprint GPGME.list_keys("Smith", true).first.subkeys.first.fingerprint u.profile Profile.new( :first_name => "Bob", :last_name => "Smith" ) end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index bb02e29b0..670c37328 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -81,6 +81,7 @@ describe 'user encryption' do end it 'should sign a message on create' do message = Factory.create(:status_message, :person => @u) + puts message.owner_signature message.verify_signature.should be true end @@ -115,4 +116,12 @@ describe 'user encryption' do message.verify_signature.should be false end end + + describe 'sending and recieving signatures' do + it 'should contain the signature in the xml' do + message = Factory.create(:status_message, :person => @u) + xml = message.to_xml.to_s + xml.include?(message.owner_signature).should be true + end + end end From d4d1aa0fd5f8cf2f03262cacc837d1d73029a816 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 14:34:30 -0700 Subject: [PATCH 21/49] RS IZ validations of signature are now called on craeeton of a post --- app/models/post.rb | 5 ++-- spec/user_encryption_spec.rb | 46 +++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 5a576e9bc..e555ea426 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -44,7 +44,8 @@ class Post end #ENCRYPTION - before_save :sign_if_mine + before_validation :sign_if_mine + validates_true_for :owner_signature, :logic => lambda {self.verify_signature} key :owner_signature, String @@ -66,10 +67,8 @@ class Post validity = nil GPGME::verify(owner_signature, signable_string, {:armor => true, :always_trust => true}){ |signature| - puts signature validity = signature.status == GPGME::GPG_ERR_NO_ERROR && signature.fpr == person.key_fingerprint - puts validity } return validity end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 670c37328..7c2ca2f34 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -12,6 +12,14 @@ describe 'user encryption' do @u = Factory.create(:user) @u.send(:assign_key) @u.save + @person = Factory.create(:person, + :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, + :profile => Profile.create(:first_name => 'Remote', + :last_name => 'Friend'), + :email => 'somewhere@else.com', + :url => 'http://distant-example.com/', + :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') + end # after :all do @@ -60,7 +68,7 @@ describe 'user encryption' do xml = Request.build_xml_for [request] person.destroy store_objects_from_xml(xml) - Person.all.count.should == 2 + Person.all.count.should == 3 new_person = Person.first(:url => "http://test.url/") new_person.key_fingerprint.nil?.should == false new_person.id.should == id @@ -70,15 +78,6 @@ describe 'user encryption' do end describe 'signing and verifying' do - before do - @person = Factory.create(:person, - :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, - :profile => Profile.create(:first_name => 'Remote', - :last_name => 'Friend'), - :email => 'somewhere@else.com', - :url => 'http://distant-example.com/', - :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') - end it 'should sign a message on create' do message = Factory.create(:status_message, :person => @u) puts message.owner_signature @@ -87,20 +86,22 @@ describe 'user encryption' do it 'should not be able to verify a message from a person without a key' do person = Factory.create(:person, :key_fingerprint => "123") - message = Factory.create(:status_message, :person => person) + message = Factory.build(:status_message, :person => person) + message.save(:validate => false) message.verify_signature.should be false end it 'should verify a remote signature' do - message = Factory.create(:status_message, :person => @person) + message = Factory.build(:status_message, :person => @person) message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) - message.save + message.save(:validate => false) message.verify_signature.should be true end it 'should know if the signature is from the wrong person' do - message = Factory.create(:status_message, :person => @person) + message = Factory.build(:status_message, :person => @person) + message.save(:validate => false) message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.person = @u @@ -108,11 +109,11 @@ describe 'user encryption' do end it 'should know if the signature is for the wrong text' do - message = Factory.create(:status_message, :person => @person) + message = Factory.build(:status_message, :person => @person) message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.message = 'I love VENISON' - message.save + message.save(:validate => false) message.verify_signature.should be false end end @@ -123,5 +124,18 @@ describe 'user encryption' do xml = message.to_xml.to_s xml.include?(message.owner_signature).should be true end + it 'the signature should be verified on marshaling' do + + message = Factory.build(:status_message, :person => @person) + message.owner_signature = GPGME.sign(message.signable_string, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@u.key]}) + message.save + xml = Post.build_xml_for([message]) + message.destroy + Post.count.should be 0 + store_objects_from_xml(xml) + Post.count.should be 0 + end + end end From 4a53d29939b85efabf64731c16f8c57b0015b55c Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 14:40:10 -0700 Subject: [PATCH 22/49] assign key --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 757a6471a..997254ed3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < Person :recoverable, :rememberable, :trackable, :validatable - #before_create :assign_key + before_create :assign_key validates_presence_of :profile before_validation :do_bad_things From 0df76daab5c494c2454108c72fff7a4b554bf3cf Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 14:44:30 -0700 Subject: [PATCH 23/49] assign key --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 997254ed3..40fa10d25 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < Person :recoverable, :rememberable, :trackable, :validatable - before_create :assign_key + before_validation :assign_key validates_presence_of :profile before_validation :do_bad_things From 6614285644000b76ba7e8554e0d34dd6694b43bc Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 15:08:14 -0700 Subject: [PATCH 24/49] params string now a method --- app/models/user.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 40fa10d25..07aafeddf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -100,7 +100,12 @@ class User < Person def generate_key puts "Generating key" ctx = GPGME::Ctx.new - paramstring = " + ctx.genkey(paramstring, nil, nil) + + end + + def paramstring +" Key-Type: DSA Key-Length: 512 Subkey-Type: ELG-E @@ -110,7 +115,6 @@ Name-Comment: #{self.url} Name-Email: #{self.email} Expire-Date: 0 " - ctx.genkey(paramstring, nil, nil) - + end end From 2862925e2ddc293e889484b1cfb3fb8a72db5432 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 15:19:25 -0700 Subject: [PATCH 25/49] before validations on create --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 07aafeddf..b61717adf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < Person :recoverable, :rememberable, :trackable, :validatable - before_validation :assign_key + before_validation_on_create :assign_key validates_presence_of :profile before_validation :do_bad_things From 4a0bd5fc0c8c9b74046533c5b1aa8745bbe423f1 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 13 Jul 2010 17:36:18 -0700 Subject: [PATCH 26/49] RS IZ; removed validations on marshaling and removed key deletion on person destroyw --- app/models/person.rb | 2 +- app/models/post.rb | 3 ++- app/models/user.rb | 3 ++- spec/helpers/application_helper_spec.rb | 2 +- spec/lib/xml_spec.rb | 2 +- spec/models/request_spec.rb | 5 +---- spec/user_encryption_spec.rb | 2 ++ 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index d9774413f..70e8c7dee 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -26,7 +26,7 @@ class Person validates_true_for :url, :logic => lambda { self.url_unique?} - after_destroy :remove_all_traces, :remove_key + after_destroy :remove_all_traces#, :remove_key scope :friends, where(:_type => "Person", :active => true) diff --git a/app/models/post.rb b/app/models/post.rb index e555ea426..ee004ce45 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -44,8 +44,9 @@ class Post end #ENCRYPTION + before_validation :sign_if_mine - validates_true_for :owner_signature, :logic => lambda {self.verify_signature} + #validates_true_for :owner_signature, :logic => lambda {self.verify_signature} key :owner_signature, String diff --git a/app/models/user.rb b/app/models/user.rb index b61717adf..a00c5ed16 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < Person :recoverable, :rememberable, :trackable, :validatable - before_validation_on_create :assign_key + before_create :assign_key validates_presence_of :profile before_validation :do_bad_things @@ -99,6 +99,7 @@ class User < Person def generate_key puts "Generating key" + puts paramstring ctx = GPGME::Ctx.new ctx.genkey(paramstring, nil, nil) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 20261308f..f47856265 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -4,7 +4,7 @@ include ApplicationHelper describe ApplicationHelper do before do - @user = Factory.create(:user, :email => "robert@grimm.com") + @user = Factory.create(:user) @person = Factory.create(:person) end diff --git a/spec/lib/xml_spec.rb b/spec/lib/xml_spec.rb index 5c1714d73..42b26d01c 100644 --- a/spec/lib/xml_spec.rb +++ b/spec/lib/xml_spec.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper' describe Diaspora::XML do before do - @user = Factory.create(:user, :profile => { :first_name => "robert", :last_name => "grimm" } ) + @user = Factory.create(:user) Diaspora::XML::OWNER = @user end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index a6289c4be..00fac8580 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -11,11 +11,8 @@ describe Request do end it 'should generate xml for the User as a Person' do - user = Factory.build(:user, :email => "rob@bob.com") + user = Factory.create(:user) - user.profile = Factory.create(:profile) - - user.save(:validate => false) user.profile.save request = Request.instantiate(:to => "http://www.google.com/", :from => user) diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 7c2ca2f34..65d772fff 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -30,6 +30,7 @@ describe 'user encryption' do #end it 'should remove the key from the keyring on person destroy' do + pending "We can implement deleting from the keyring later, its annoying to test b/c no stub any instance of" person = Factory.create :person keyid = person.key_fingerprint original_key = person.export_key @@ -125,6 +126,7 @@ describe 'user encryption' do xml.include?(message.owner_signature).should be true end it 'the signature should be verified on marshaling' do + pending "We're going to work on embeded profile" message = Factory.build(:status_message, :person => @person) message.owner_signature = GPGME.sign(message.signable_string, nil, From f680c4b71ea2c6b4d6e6b60a1e535ced7eca2288 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 11:01:21 -0700 Subject: [PATCH 27/49] RS, IZ; Signature Verification now stubbed out outside of encryption specs, green --- app/models/post.rb | 2 +- spec/spec_helper.rb | 17 +++++++++++++++-- spec/user_encryption_spec.rb | 10 +++++----- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index ee004ce45..a4d710f19 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -46,7 +46,7 @@ class Post #ENCRYPTION before_validation :sign_if_mine - #validates_true_for :owner_signature, :logic => lambda {self.verify_signature} + validates_true_for :owner_signature, :logic => lambda {self.verify_signature} key :owner_signature, String diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cf8bb59d7..7273c0d28 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,7 +12,7 @@ include Devise::TestHelpers Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| - + config.mock_with :mocha config.mock_with :rspec DatabaseCleaner.strategy = :truncation @@ -20,11 +20,12 @@ RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.clean_with(:truncation) + stub_signature_verification end config.before(:each) do DatabaseCleaner.start - stub_sockets_controller + stub_sockets_controller end config.after(:each) do @@ -39,3 +40,15 @@ end mock_sockets_controller.stub!(:delete_subscriber).and_return(true) SocketsController.stub!(:new).and_return(mock_sockets_controller) end + + def stub_signature_verification + Post.any_instance.stubs(:verify_signature).returns(true) + StatusMessage.any_instance.stubs(:verify_signature).returns(true) + Blog.any_instance.stubs(:verify_signature).returns(true) + Bookmark.any_instance.stubs(:verify_signature).returns(true) + end + + def unstub_mocha_stubs + Mocha::Mockery.instance.stubba.unstub_all + + end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 65d772fff..905324c40 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -9,6 +9,7 @@ describe 'user encryption' do end before do + unstub_mocha_stubs @u = Factory.create(:user) @u.send(:assign_key) @u.save @@ -22,12 +23,13 @@ describe 'user encryption' do end -# after :all do + after do + stub_signature_verification #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 + end it 'should remove the key from the keyring on person destroy' do pending "We can implement deleting from the keyring later, its annoying to test b/c no stub any instance of" @@ -79,9 +81,9 @@ describe 'user encryption' do end describe 'signing and verifying' do + it 'should sign a message on create' do message = Factory.create(:status_message, :person => @u) - puts message.owner_signature message.verify_signature.should be true end @@ -126,8 +128,6 @@ describe 'user encryption' do xml.include?(message.owner_signature).should be true end it 'the signature should be verified on marshaling' do - pending "We're going to work on embeded profile" - message = Factory.build(:status_message, :person => @person) message.owner_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@u.key]}) From 335f202e2bd0fa6c7d9c5c9404788c231d93e480 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 11:22:44 -0700 Subject: [PATCH 28/49] RS, IZ; Profiles are now embedded --- app/models/person.rb | 2 +- app/models/profile.rb | 8 ++------ db/seeds.rb | 4 ++-- db/seeds/backer.rb | 6 +++--- db/seeds/dev.rb | 4 ++-- db/seeds/tom.rb | 4 ++-- spec/controllers/dashboards_controller_spec.rb | 2 +- spec/factories.rb | 1 - spec/models/profile_spec.rb | 10 ++-------- spec/user_encryption_spec.rb | 4 ++-- 10 files changed, 17 insertions(+), 28 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 70e8c7dee..b2d54787d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -14,7 +14,7 @@ class Person key :active, Boolean, :default => false key :key_fingerprint, String - one :profile, :class_name => 'Profile', :foreign_key => :person_id + one :profile, :class_name => 'Profile' many :posts, :class_name => 'Post', :foreign_key => :person_id timestamps! diff --git a/app/models/profile.rb b/app/models/profile.rb index 13febaaf3..165d6a18f 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -1,5 +1,5 @@ class Profile - include MongoMapper::Document + include MongoMapper::EmbeddedDocument include ROXML xml_accessor :first_name @@ -8,10 +8,6 @@ class Profile key :first_name, String key :last_name, String - key :person_id, ObjectId - - belongs_to :person - - validates_presence_of :first_name, :last_name, :person_id + validates_presence_of :first_name, :last_name end diff --git a/db/seeds.rb b/db/seeds.rb index 654131687..499f3a30a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -9,7 +9,7 @@ require 'config/environment' # Create seed user -user = User.create( :email => "tom@joindiaspora.com", :password => "aaaaaa", :profile => Profile.create( :first_name => "Diaspora", :last_name => "Tom" )) +user = User.create( :email => "tom@joindiaspora.com", :password => "aaaaaa", :profile => Profile.new( :first_name => "Diaspora", :last_name => "Tom" )) names = [ ["George", "Washington"], ["John", "Adams"], @@ -31,7 +31,7 @@ names = [ ["George", "Washington"], # Make people (1..10).each { |n| - People.create( :email => "b#{n}@joindiaspora.com", :url => "http://b#{n}.joindiaspora.com/", :profile => Profile.create(:first_name => names[n-1][0], :last_name => names[n-1][1])) + People.create( :email => "b#{n}@joindiaspora.com", :url => "http://b#{n}.joindiaspora.com/", :profile => Profile.new(:first_name => names[n-1][0], :last_name => names[n-1][1])) } # Populate feed diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 13be3e6be..c8d6bdf79 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -54,11 +54,11 @@ def create(backer_number, password) email = backer_info[backer_number][2].gsub(/ /,'').downcase user = User.create( :email => "#{email}@joindiaspora.com", :password => "#{email+backer_info[backer_number][0].to_s}", - :profile => Profile.create( :first_name => backer_info[backer_number][1], :last_name => backer_info[backer_number][2] ), + :profile => Profile.new( :first_name => backer_info[backer_number][1], :last_name => backer_info[backer_number][2] ), :url=> "#{email}.joindiaspora.com") # Make connection with Diaspora Tom - Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.create(:first_name => "Alexander", :last_name => "Hamiltom")) + Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => "Alexander", :last_name => "Hamiltom")) # Make people (0..10).each { |n| @@ -66,7 +66,7 @@ def create(backer_number, password) Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, - :profile => Profile.create(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number + :profile => Profile.new(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number } end diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index d5a71b3c7..dae6ae374 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -9,7 +9,7 @@ require 'config/environment' # Create seed user -user = User.create( :email => "robert@joindiaspora.com", :password => "monkey", :profile => Profile.create( :first_name => "bobert", :last_name => "brin" )) +user = User.create( :email => "robert@joindiaspora.com", :password => "monkey", :profile => Profile.new( :first_name => "bobert", :last_name => "brin" )) names = [ ["George", "Washington"], ["John", "Adams"], @@ -52,7 +52,7 @@ names = [ ["George", "Washington"], # Make people (0..10).each { |n| email = names[n][1].gsub(/ /,'').downcase - Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.create(:first_name => names[n][0], :last_name => names[n][1])) + Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) } diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 85170c013..4ce85ff1d 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -9,7 +9,7 @@ require 'config/environment' # Create seed user -user = User.create( :email => "tom@joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.create( :first_name => "Alexander", :last_name => "Hamiltom" )) +user = User.create( :email => "tom@joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) names = [ ["George", "Washington"], ["John", "Adams"], @@ -52,7 +52,7 @@ names = [ ["George", "Washington"], # Make people (0..10).each { |n| email = names[n][1].gsub(/ /,'').downcase - Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.create(:first_name => names[n][0], :last_name => names[n][1])) + Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) } diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb index 6b48d9a63..d0b72d22c 100644 --- a/spec/controllers/dashboards_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -5,7 +5,7 @@ describe DashboardsController do before do request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user) - @user = Factory.create(:user, :profile => Profile.create( :first_name => "bob", :last_name => "smith")) + @user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith")) end it "on index sets a variable containing all a user's friends when a user is signed in" do diff --git a/spec/factories.rb b/spec/factories.rb index 9780f2b09..1fdd262bf 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -8,7 +8,6 @@ GPGME::check_version({}) Factory.define :profile do |p| p.first_name "Robert" p.last_name "Grimm" - p.person Person.new( :email => "bob@aol.com" ) end Factory.define :person do |p| diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb index 5cb57b270..6099793b0 100644 --- a/spec/models/profile_spec.rb +++ b/spec/models/profile_spec.rb @@ -7,25 +7,19 @@ describe Profile do describe 'requirements' do it "should include a first name" do - @person.profile = Factory.build(:profile, :person => @person, :first_name => nil) + @person.profile = Factory.build(:profile,:first_name => nil) @person.profile.valid?.should be false @person.profile.first_name = "Bob" @person.profile.valid?.should be true end it "should include a last name" do - @person.profile = Factory.build(:profile, :person => @person, :last_name => nil) + @person.profile = Factory.build(:profile, :last_name => nil) @person.profile.valid?.should be false @person.profile.last_name = "Smith" @person.profile.valid?.should be true end - it "should include a person" do - profile = Factory.build(:profile, :person => nil) - profile.valid?.should be false - profile.person = @person - profile.valid?.should be true - end end end diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 905324c40..af4fcfc4e 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -15,8 +15,8 @@ describe 'user encryption' do @u.save @person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, - :profile => Profile.create(:first_name => 'Remote', - :last_name => 'Friend'), + :profile => Profile.new(:first_name => 'Remote', + :last_name => 'Friend'), :email => 'somewhere@else.com', :url => 'http://distant-example.com/', :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') From a7ba1d8920ef5499e82ef908a00e0fdcf7236aa2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 11:25:34 -0700 Subject: [PATCH 29/49] Assign key before validation --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index a00c5ed16..ad4dece87 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,7 +4,7 @@ class User < Person :recoverable, :rememberable, :trackable, :validatable - before_create :assign_key + before_validation :assign_key validates_presence_of :profile before_validation :do_bad_things From 0f7006dfead9ae13331ac4b2f5a846fd79cb52be Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 11:32:33 -0700 Subject: [PATCH 30/49] Profiles do not need to be deleted --- lib/tasks/db.rake | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 6d61abd4a..c984a2155 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -28,7 +28,6 @@ namespace :db do Post.delete_all Person.delete_all User.delete_all - Profile.delete_all Request.delete_all end From 2e0e904cdb877e289451c37887d39ada2a6a2468 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 11:47:36 -0700 Subject: [PATCH 31/49] Sending key in friend request response --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index ad4dece87..9bdf1b5aa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -42,6 +42,7 @@ class User < Person request = Request.where(:id => friend_request_id).first request.activate_friend request.person = self + request.exported_key = self.export_key request.destination_url = request.callback_url request.push_to_url(request.callback_url) request.destroy From d7d1af805868bcb164367d010dfc5c409a4a8664 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 11:55:15 -0700 Subject: [PATCH 32/49] always import the key --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9bdf1b5aa..a9cdf0cd8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -56,11 +56,11 @@ class User < Person end def receive_friend_request(friend_request) + GPGME.import(friend_request.exported_key) if Request.where(:callback_url => friend_request.callback_url).first friend_request.activate_friend friend_request.destroy else - GPGME.import(friend_request.exported_key) friend_request.person.save friend_request.save end From a15ee6feab9f010475a553eefb4b74082448a3a8 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 12:06:39 -0700 Subject: [PATCH 33/49] Changing db seed to friending --- db/seeds/backer.rb | 17 +++++++++-------- db/seeds/tom.rb | 12 +++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index c8d6bdf79..552fd804e 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -58,15 +58,16 @@ def create(backer_number, password) :url=> "#{email}.joindiaspora.com") # Make connection with Diaspora Tom - Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => "Alexander", :last_name => "Hamiltom")) + User.owner.send_friend_request_to('http://tom.joindiaspora.com/') + #Person.create( :email => "tom@joindiaspora.com", :url => "http://tom.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => "Alexander", :last_name => "Hamiltom")) # Make people - (0..10).each { |n| - email = backer_info[n][2].gsub(/ /,'').downcase - Person.create( :email => "#{email}@joindiaspora.com", - :url => "http://#{email}.joindiaspora.com/", - :active => true, - :profile => Profile.new(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number - } + #(0..10).each { |n| + #email = backer_info[n][2].gsub(/ /,'').downcase + #Person.create( :email => "#{email}@joindiaspora.com", + #:url => "http://#{email}.joindiaspora.com/", + #:active => true, + #:profile => Profile.new(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number + #} end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 4ce85ff1d..0f572b7b1 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -1,4 +1,4 @@ -# This file should contain all the record creation needed to seed the database with its default values. +#This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: @@ -50,9 +50,11 @@ names = [ ["George", "Washington"], ] # Make people -(0..10).each { |n| - email = names[n][1].gsub(/ /,'').downcase - Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) +#(0..10).each { |n| + #email = names[n][1].gsub(/ /,'').downcase + #Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) +#} +Request.all.each{|r| + User.owner.accept_friend_request(r.id) } - From 4bd50d47b76a8002d32f5eeb30269902a293e6e3 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 14 Jul 2010 12:41:22 -0700 Subject: [PATCH 34/49] DB seeds now use friending, presidents are not friends. --- db/seeds/tom.rb | 4 +--- lib/tasks/db.rake | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 0f572b7b1..b6aed413e 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -54,7 +54,5 @@ names = [ ["George", "Washington"], #email = names[n][1].gsub(/ /,'').downcase #Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) #} -Request.all.each{|r| - User.owner.accept_friend_request(r.id) -} + diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index c984a2155..916750c00 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -18,6 +18,11 @@ namespace :db do end end + task :accept_requests do + puts "Accepting all friend requests for #{Rails.env}" + require 'db/seeds/accept' + end + desc 'Delete the collections in the current RAILS_ENV database' task :purge do require 'config/environment' From 2d5d3a2f2daae52f81a543011242fa3c737fb62d Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 13:29:21 -0700 Subject: [PATCH 35/49] commit more often --- app/models/comment.rb | 39 +++++++- app/models/post.rb | 56 ++++------- db/seeds/request.rb | 6 ++ gpg/diaspora-test/pubring.gpg | Bin 37824 -> 38446 bytes gpg/diaspora-test/secring.gpg | Bin 1332 -> 2006 bytes gpg/diaspora-test/trustdb.gpg | Bin 1520 -> 1600 bytes lib/encryptable.rb | 33 +++++++ spec/controllers/publics_controller_spec.rb | 2 +- spec/models/person_spec.rb | 1 + spec/spec_helper.rb | 9 +- spec/user_encryption_spec.rb | 99 +++++++++++++++----- 11 files changed, 174 insertions(+), 71 deletions(-) create mode 100644 db/seeds/request.rb create mode 100644 lib/encryptable.rb diff --git a/app/models/comment.rb b/app/models/comment.rb index b1cdc493b..67918dd96 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,12 +2,13 @@ class Comment include MongoMapper::Document include ROXML include Diaspora::Webhooks - + include Encryptable xml_accessor :text xml_accessor :person, :as => Person xml_accessor :post_id + key :text, String timestamps! @@ -25,10 +26,42 @@ class Comment (self.message == other.message) && (self.person.email == other.person.email) end + #ENCRYPTION + + before_validation :sign_if_mine, :sign_if_my_post + validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} + + xml_accessor :creator_signature + key :creator_signature, String + key :post_creator_signature, String + + def signable_accessors + accessors = self.class.roxml_attrs.collect{|definition| + definition.accessor} + accessors.delete 'person' + accessors.delete 'creator_signature' + accessors.delete 'post_creator_signature' + accessors + end + + def signable_string + signable_accessors.collect{|accessor| + (self.send accessor.to_sym).to_s}.join ';' + end + + def verify_post_creator_signature + verify_signature(post_creator_signature, post.person) + end + protected - - def send_people_comments_on_my_posts + def sign_if_my_post + if self.post.person == User.owner + self.post_creator_signature = sign + end + end + + def send_people_comments_on_my_posts if User.owner.mine?(self.post) && !(self.person.is_a? User) self.push_to(self.post.people_with_permissions) end diff --git a/app/models/post.rb b/app/models/post.rb index a4d710f19..9b711d6ce 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -4,9 +4,9 @@ class Post include MongoMapper::Document include ROXML include Diaspora::Webhooks + include Encryptable xml_accessor :_id - xml_accessor :owner_signature xml_accessor :person, :as => Person key :person_id, ObjectId @@ -44,45 +44,27 @@ class Post end #ENCRYPTION - before_validation :sign_if_mine - validates_true_for :owner_signature, :logic => lambda {self.verify_signature} - - key :owner_signature, String - - def signable_accessors - accessors = self.class.roxml_attrs.collect{|definition| - definition.accessor} - accessors.delete 'person' - accessors.delete 'owner_signature' - accessors - end - - def signable_string - signable_accessors.collect{|accessor| - (self.send accessor.to_sym).to_s}.join ';' - end - - def verify_signature - return false unless owner_signature && person.key_fingerprint - validity = nil - GPGME::verify(owner_signature, signable_string, - {:armor => true, :always_trust => true}){ |signature| - validity = signature.status == GPGME::GPG_ERR_NO_ERROR && - signature.fpr == person.key_fingerprint - } - return validity - end - - protected - def sign_if_mine - if self.person == User.owner - self.owner_signature = GPGME::sign(signable_string,nil, - {:armor=> true, :mode => GPGME::SIG_MODE_DETACH}) + validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} + + xml_accessor :creator_signature + key :creator_signature, String + + def signable_accessors + accessors = self.class.roxml_attrs.collect{|definition| + definition.accessor} + accessors.delete 'person' + accessors.delete 'creator_signature' + accessors end - end - def destroy_comments + def signable_string + signable_accessors.collect{|accessor| + (self.send accessor.to_sym).to_s}.join ';' + end + +protected + def destroy_comments comments.each{|c| c.destroy} end diff --git a/db/seeds/request.rb b/db/seeds/request.rb new file mode 100644 index 000000000..b0c652ca8 --- /dev/null +++ b/db/seeds/request.rb @@ -0,0 +1,6 @@ + +require 'config/environment' + +Request.all.each{|r| + User.owner.accept_friend_request(r.id) +} diff --git a/gpg/diaspora-test/pubring.gpg b/gpg/diaspora-test/pubring.gpg index 46e8a37d1e84b145278442b92bfe4314e1562434..6949770abe15219a8dcf14b912cd2644bb33bfae 100644 GIT binary patch delta 587 zcmV-R0<`_Wrvk3505dr|0qY0$kdxdzTE6fSs(WcMRqa| zALLYdZ%#zKSpoh(mgvSaG5%;4GrrfXJv6VQN=0)e)bVb`G#vFzz zxQnm?00X#<1WZ0Yf)D}#!5w|QHp|6JRj3MAdABt04O&k#*sJnJp@W#o*8tYqV#i`x3Ah zmm01}y)Z|ilU2w>^jTjcv+(O82+6_dd2bBVE%|n1Q-zl z00{*GOg=t>0vikf3JDORTycmr?{<}H0|1|0O;rypspQg~ZyGzEW@`vgorK7tVf0GFc)q}+Rjc%v)K3E$*PnPdJf79PVQKFe}n zpxXLfucJyub0yUAZpAcrz)*i%a&4R0H=Tt=%+EI2 z_n`HaK)f=V{@FW4U*Tsn#EMv)?0o_J4`~58T4V&CJ@eXBfJFdf^Y#a$Rc!eOG-7&j zS2;%cyl7FcOof)m_8Q=*rIm5z+&PEB-nzRj7;E%iDlS!I005pWY^j{;f+MpPB~s;} z+`1oUf%M)BJ+x6mQ)OdsZe$=va%p95WFRPLbaZe!FE3li&j&f1+G*h&1nZ zm4HJ4pn()q<~%=;@;~f3qOG&4T~~1p)prdFm3Re#PL>6>GF-r27)E7nd5YNWCye zp_5g}MD$r-BeU@9A_&R9-!cf94U;E0A8*`OVHuus&w9o2*kJwu0I0vikf3JDORTycmrHScznY6AeCGlKBj t91<_~e$6eBBNMFl2Ch*d0G=qQyaCj?7?`a0p;!n(q;h(qyGO7B006xAAsGMw delta 7 Ocmcb{zlCdq2`c~$WCD!< diff --git a/gpg/diaspora-test/trustdb.gpg b/gpg/diaspora-test/trustdb.gpg index 45e0c76adf3c9bab923cb7a571bcdc1d64ff4598..1fec81fc8c39a371e7de456d93e66eb9dd3172ee 100644 GIT binary patch delta 119 zcmeyseSk-RF})z2nVFH5k%581$Ifo`#6aTZmTY7+yMHcwzoU true, :always_trust => true}){ |signature| + puts signature + validity = signature.status == GPGME::GPG_ERR_NO_ERROR && + signature.fpr == person.key_fingerprint + } + return validity + end + + protected + def sign_if_mine + if self.person == User.owner + self.creator_signature = sign + end + end + + def sign + GPGME::sign(signable_string,nil, + {:armor=> true, :mode => GPGME::SIG_MODE_DETACH, :signers => [User.owner.key]}) + end + end + diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index e9539b464..be297a64f 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -4,7 +4,7 @@ describe PublicsController do render_views before do - @user = Factory.create(:user, :profile => Profile.create( :first_name => "bob", :last_name => "smith")) + @user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith")) request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user) end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index a882b9849..72cad89ac 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -65,6 +65,7 @@ describe Person do Person.friends.all.count.should == 1 u.unfriend(f.id) Person.friends.all.count.should == 0 + Person.all.count.should == 1 end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7273c0d28..79412d92d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,10 +42,11 @@ end end def stub_signature_verification - Post.any_instance.stubs(:verify_signature).returns(true) - StatusMessage.any_instance.stubs(:verify_signature).returns(true) - Blog.any_instance.stubs(:verify_signature).returns(true) - Bookmark.any_instance.stubs(:verify_signature).returns(true) + Post.any_instance.stubs(:verify_creator_signature).returns(true) + StatusMessage.any_instance.stubs(:verify_creator_signature).returns(true) + Blog.any_instance.stubs(:verify_creator_signature).returns(true) + Bookmark.any_instance.stubs(:verify_creator_signature).returns(true) + Comment.any_instance.stubs(:verify_creator_signature).returns(true) end def unstub_mocha_stubs diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index af4fcfc4e..63f4785c9 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -10,17 +10,21 @@ describe 'user encryption' do end before do unstub_mocha_stubs - @u = Factory.create(:user) - @u.send(:assign_key) - @u.save + @user = Factory.create(:user) + @user.send(:assign_key) + @user.save @person = Factory.create(:person, :key_fingerprint => GPGME.list_keys("Remote Friend").first.subkeys.first.fpr, :profile => Profile.new(:first_name => 'Remote', :last_name => 'Friend'), :email => 'somewhere@else.com', - :url => 'http://distant-example.com/', - :key_fingerprint => '57F553EE2C230991566B7C60D3638485F3960087') - + :url => 'http://distant-example.com/') + @person2 = Factory.create(:person, + :key_fingerprint => GPGME.list_keys("Second Friend").first.subkeys.first.fpr, + :profile => Profile.new(:first_name => 'Second', + :last_name => 'Friend'), + :email => 'elsewhere@else.com', + :url => 'http://distanter-example.com/') end after do @@ -44,18 +48,18 @@ describe 'user encryption' do end it 'should have a key fingerprint' do - @u.key_fingerprint.should_not be nil + @user.key_fingerprint.should_not be nil end it 'should retrieve a user key' do - @u.key.subkeys[0].fpr.should == @u.key_fingerprint + @user.key.subkeys[0].fpr.should == @user.key_fingerprint end describe 'key exchange on friending' do it 'should send over a public key' do Comment.send(:class_variable_get, :@@queue).stub!(:add_post_request) - request = @u.send_friend_request_to("http://example.com/") - Request.build_xml_for([request]).include?( @u.export_key).should be true + request = @user.send_friend_request_to("http://example.com/") + Request.build_xml_for([request]).include?( @user.export_key).should be true end it 'should receive and marshal a public key from a request' do @@ -70,8 +74,9 @@ describe 'user encryption' do xml = Request.build_xml_for [request] person.destroy + personcount = Person.all.count store_objects_from_xml(xml) - Person.all.count.should == 3 + Person.all.count.should == personcount + 1 new_person = Person.first(:url => "http://test.url/") new_person.key_fingerprint.nil?.should == false new_person.id.should == id @@ -83,54 +88,54 @@ describe 'user encryption' do describe 'signing and verifying' do it 'should sign a message on create' do - message = Factory.create(:status_message, :person => @u) - message.verify_signature.should be true + message = Factory.create(:status_message, :person => @user) + message.verify_creator_signature.should be true end it 'should not be able to verify a message from a person without a key' do person = Factory.create(:person, :key_fingerprint => "123") message = Factory.build(:status_message, :person => person) message.save(:validate => false) - message.verify_signature.should be false + message.verify_creator_signature.should be false end it 'should verify a remote signature' do message = Factory.build(:status_message, :person => @person) - message.owner_signature = GPGME.sign(message.signable_string, nil, + message.creator_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.save(:validate => false) - message.verify_signature.should be true + message.verify_creator_signature.should be true end it 'should know if the signature is from the wrong person' do message = Factory.build(:status_message, :person => @person) message.save(:validate => false) - message.owner_signature = GPGME.sign(message.signable_string, nil, + message.creator_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) - message.person = @u - message.verify_signature.should be false + message.person = @user + message.verify_creator_signature.should be false end it 'should know if the signature is for the wrong text' do message = Factory.build(:status_message, :person => @person) - message.owner_signature = GPGME.sign(message.signable_string, nil, + message.creator_signature = GPGME.sign(message.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) message.message = 'I love VENISON' message.save(:validate => false) - message.verify_signature.should be false + message.verify_creator_signature.should be false end end describe 'sending and recieving signatures' do it 'should contain the signature in the xml' do - message = Factory.create(:status_message, :person => @u) + message = Factory.create(:status_message, :person => @user) xml = message.to_xml.to_s - xml.include?(message.owner_signature).should be true + xml.include?(message.creator_signature).should be true end - it 'the signature should be verified on marshaling' do + it 'A message with an invalid signature should be rejected' do message = Factory.build(:status_message, :person => @person) - message.owner_signature = GPGME.sign(message.signable_string, nil, - {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@u.key]}) + message.creator_signature = GPGME.sign(message.signable_string, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@user.key]}) message.save xml = Post.build_xml_for([message]) message.destroy @@ -140,4 +145,46 @@ describe 'user encryption' do end end + describe 'comments' do + before do + @remote_message = Factory.build(:status_message, :person => @person) + @remote_message.creator_signature = GPGME.sign(@remote_message.signable_string, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person.key]}) + @remote_message.save + + end + it 'should attach the creator signature if the user is commenting' do + @user.comment "Yeah, it was great", :on => @remote_message + @remote_message.comments.first.verify_creator_signature.should be true + end + + it 'should sign the comment if the user is the post creator' do + message = Factory.create(:status_message, :person => @user) + @user.comment "Yeah, it was great", :on => message + StatusMessage.first.comments.first.verify_creator_signature.should be true + StatusMessage.first.comments.first.verify_post_creator_signature.should be true + end + + it 'should verify a comment made on a remote post by a different friend' do + comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) + comment.creator_signature = GPGME.sign(@remote_message.signable_string, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person2.key]}) + comment.verify_creator_signature.should be true + + end + + it 'should reject comments on a remote post with only a creator sig' do + comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) + comment.creator_signature = GPGME.sign(@remote_message.signable_string, nil, + {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person2.key]}) + comment.verify_creator_signature.should be true + comment.verify_post_creator_signature.should be false + comment.save.should be false + end + + it 'should receive remote comments on a user post with a creator sig' do + + end + + end end From 50addb830970cbb98ea13627d296141f64ad2053 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 13:53:43 -0700 Subject: [PATCH 36/49] Took password out of db:seed:backer --- db/seeds/backer.rb | 6 ++++-- lib/tasks/db.rake | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 13be3e6be..2468e4b47 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -10,7 +10,7 @@ require 'config/environment' -def create(backer_number, password) +def create(backer_number) backer_info = [ [5072,"George", "Washington"], [3742,"John", "Adams"], [7782,"Thomas", "Jefferson"], @@ -66,7 +66,9 @@ def create(backer_number, password) Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, - :profile => Profile.create(:first_name => backer_info[n][1], :last_name => backer_info[n][2])) unless n == backer_number + :profile => Profile.create( + :first_name => backer_info[n][1], + :last_name => backer_info[n][2])) unless n == backer_number } end diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 6d61abd4a..645d66e72 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -11,10 +11,10 @@ namespace :db do require 'db/seeds/dev' end - task :backer, :num, :password do |t, args| + task :backer, :num do |t, args| puts "Seeding the database for #{Rails.env}..." require 'db/seeds/backer' - create( Integer(args.num), args.password ) + create( Integer(args.num)) end end From 862787ea93423731859f765139ea40abffc38ac9 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 14:12:01 -0700 Subject: [PATCH 37/49] RS, DG; person destruction no longer deletes comments --- app/models/person.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/person.rb b/app/models/person.rb index c60f74968..9d3cf99a4 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -59,7 +59,6 @@ class Person def remove_all_traces self.posts.delete_all - Comment.delete_all(:person_id => self.id) end From d7e07dfda8ab2e87fe33a8fd991c087d1c3414b7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 14:41:39 -0700 Subject: [PATCH 38/49] comment specs fixed, comments now signed by post poster --- app/models/comment.rb | 11 ++++++++--- app/models/person.rb | 2 +- gpg/diaspora-test/pubring.gpg | Bin 38446 -> 38446 bytes lib/encryptable.rb | 1 - spec/models/person_spec.rb | 6 +++--- spec/spec_helper.rb | 3 +++ spec/user_encryption_spec.rb | 5 ++--- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 67918dd96..8fbd9dd0c 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -29,7 +29,8 @@ class Comment #ENCRYPTION before_validation :sign_if_mine, :sign_if_my_post - validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} + #validates_true_for :creator_signature, :logic => lambda {self.verify_creator_signature} + validates_true_for :post_creator_signature, :logic => lambda {self.verify_post_creator_signature} xml_accessor :creator_signature key :creator_signature, String @@ -49,8 +50,12 @@ class Comment (self.send accessor.to_sym).to_s}.join ';' end - def verify_post_creator_signature - verify_signature(post_creator_signature, post.person) + def verify_post_creator_signature + unless person == User.owner + verify_signature(post_creator_signature, post.person) + else + true + end end diff --git a/app/models/person.rb b/app/models/person.rb index 62729c9aa..968ba5dd7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -26,7 +26,7 @@ class Person validates_true_for :url, :logic => lambda { self.url_unique?} - after_destroy :remove_all_traces#, :remove_key + after_destroy :remove_all_traces, :remove_key scope :friends, where(:_type => "Person", :active => true) diff --git a/gpg/diaspora-test/pubring.gpg b/gpg/diaspora-test/pubring.gpg index 6949770abe15219a8dcf14b912cd2644bb33bfae..413a37f87c212997fa5d9f104ba7c7e9c90756ac 100644 GIT binary patch delta 19 bcmZ3thH2dzrVZ2jHy@as$FzA`zZMGsVWbHP delta 19 bcmZ3thH2dzrVZ2jH?vIAV%a>cKaU9jS+)pG diff --git a/lib/encryptable.rb b/lib/encryptable.rb index 10a9ac39c..c35ba70c3 100644 --- a/lib/encryptable.rb +++ b/lib/encryptable.rb @@ -11,7 +11,6 @@ validity = nil GPGME::verify(creator_signature, signable_string, {:armor => true, :always_trust => true}){ |signature| - puts signature validity = signature.status == GPGME::GPG_ERR_NO_ERROR && signature.fpr == person.key_fingerprint } diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 72cad89ac..8d6e75f51 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -34,7 +34,7 @@ describe Person do end - it 'should delete all of user upon user deletion' do + it 'should delete all of user except comments upon user deletion' do Factory.create(:user) f = Factory.create(:person) @@ -53,8 +53,8 @@ describe Person do f.destroy Post.count.should == 1 - Comment.all.count.should == 1 - s.comments.count.should == 1 + Comment.all.count.should == 4 + s.comments.count.should == 4 end it 'should let a user unfriend another user' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 79412d92d..f0156464d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -47,6 +47,9 @@ end Blog.any_instance.stubs(:verify_creator_signature).returns(true) Bookmark.any_instance.stubs(:verify_creator_signature).returns(true) Comment.any_instance.stubs(:verify_creator_signature).returns(true) + Comment.any_instance.stubs(:verify_post_creator_signature).returns(true) + Person.any_instance.stubs(:remove_key).returns(true) + User.any_instance.stubs(:remove_key).returns(true) end def unstub_mocha_stubs diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 63f4785c9..b0083f0ec 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -36,7 +36,6 @@ describe 'user encryption' do end it 'should remove the key from the keyring on person destroy' do - pending "We can implement deleting from the keyring later, its annoying to test b/c no stub any instance of" person = Factory.create :person keyid = person.key_fingerprint original_key = person.export_key @@ -167,7 +166,7 @@ describe 'user encryption' do it 'should verify a comment made on a remote post by a different friend' do comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) - comment.creator_signature = GPGME.sign(@remote_message.signable_string, nil, + comment.creator_signature = GPGME.sign(comment.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person2.key]}) comment.verify_creator_signature.should be true @@ -175,7 +174,7 @@ describe 'user encryption' do it 'should reject comments on a remote post with only a creator sig' do comment = Comment.new(:person => @person2, :text => "balls", :post => @remote_message) - comment.creator_signature = GPGME.sign(@remote_message.signable_string, nil, + comment.creator_signature = GPGME.sign(comment.signable_string, nil, {:mode => GPGME::SIG_MODE_DETACH, :armor => true, :signers => [@person2.key]}) comment.verify_creator_signature.should be true comment.verify_post_creator_signature.should be false From 57d9bd1543a9cd3e4376567af5df7b1b48eec974 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 15:38:49 -0700 Subject: [PATCH 40/49] Added friending route to dashboards --- app/controllers/dashboards_controller.rb | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 10d0b8fd0..28649a21e 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -33,4 +33,29 @@ class DashboardsController < ApplicationController StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.owner, :created_at => Time.now-150000) end end + + def zombiefriends + render :nothing => true + backer_info = ["http://washington.joindiaspora.com", + "http://adams.joindiaspora.com", + "http://jefferson.joindiaspora.com", + "http://madison.joindiaspora.com", + "http://monroe.joindiaspora.com", + "http://quincyadams.joindiaspora.com", + "http://jackson.joindiaspora.com", + "http://buren.joindiaspora.com", + "http://harrison.joindiaspora.com", + "http://tyler.joindiaspora.com", + "http://polk.joindiaspora.com", + #"http://taylor.joindiaspora.com", + #"http://fillmore.joindiaspora.com", + #"http://pierce.joindiaspora.com", + ] + + if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil + backer_info.each do |backer| + User.owner.send_friend_request_to(backer) + end + end + end end From 89cf2db10e68b6c33824ffd8bb216778c84f0acb Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 15:47:27 -0700 Subject: [PATCH 41/49] fixing db seed --- config/routes.rb | 1 + lib/tasks/db.rake | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/config/routes.rb b/config/routes.rb index 45e1942e0..47f98ed93 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,7 @@ Diaspora::Application.routes.draw do |map| resources :requests match 'warzombie', :to => "dashboards#warzombie" + match 'zombiefriends', :to => "dashboards#zombiefriends" #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 323496225..dbcd29617 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -20,7 +20,7 @@ namespace :db do task :accept_requests do puts "Accepting all friend requests for #{Rails.env}" - require 'db/seeds/accept' + require 'db/seeds/request' end desc 'Delete the collections in the current RAILS_ENV database' From 788f668db0eff80eb8769010111a51370ac07efc Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 15:49:28 -0700 Subject: [PATCH 42/49] updated bson_ext --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5357ed917..d40e7b65f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'mongo_mapper', :git => "http://github.com/BadMinus/mongomapper.git" gem 'devise', :git => "http://github.com/BadMinus/devise.git" gem 'jnunemaker-validatable', :git => "http://github.com/BadMinus/validatable.git" gem 'mongo_ext' -gem "bson_ext", "1.0.1" +gem 'bson_ext' gem "haml" gem 'roxml', :git => "git://github.com/Empact/roxml.git" From 417df7f8748acadf3b189de8c8569a9fade7a0cb Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 16:03:48 -0700 Subject: [PATCH 43/49] debugging zombiefriends --- app/controllers/dashboards_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 28649a21e..da06a8285 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -53,7 +53,8 @@ class DashboardsController < ApplicationController ] if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil - backer_info.each do |backer| + backer_info.each do |backer| + puts backer User.owner.send_friend_request_to(backer) end end From 82e3f6a14e4eb53e2dea4023d8a7c5348e1bfe18 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 16:06:10 -0700 Subject: [PATCH 44/49] debugging zombiefriends --- app/controllers/dashboards_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index da06a8285..5db00abf3 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -54,7 +54,7 @@ class DashboardsController < ApplicationController if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil backer_info.each do |backer| - puts backer + logger.info backer User.owner.send_friend_request_to(backer) end end From 63f27d8a9e3f6b5272ed6aee4e3b6e5fcaea9684 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 16:09:15 -0700 Subject: [PATCH 45/49] Made email relative to subdomain --- db/seeds/backer.rb | 8 ++++---- db/seeds/dev.rb | 4 ++-- db/seeds/tom.rb | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 4708871aa..d06379762 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -51,11 +51,11 @@ def create(backer_number) # Create seed user - email = backer_info[backer_number][2].gsub(/ /,'').downcase - user = User.create( :email => "#{email}@joindiaspora.com", - :password => "#{email+backer_info[backer_number][0].to_s}", + username = backer_info[backer_number][2].gsub(/ /,'').downcase + user = User.create( :email => "#{username}@#{username}joindiaspora.com", + :password => "#{username+backer_info[backer_number][0].to_s}", :profile => Profile.new( :first_name => backer_info[backer_number][1], :last_name => backer_info[backer_number][2] ), - :url=> "#{email}.joindiaspora.com") + :url=> "#{username}.joindiaspora.com") # Make connection with Diaspora Tom User.owner.send_friend_request_to('http://tom.joindiaspora.com/') diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index dae6ae374..1c285c59b 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -51,8 +51,8 @@ names = [ ["George", "Washington"], # Make people (0..10).each { |n| - email = names[n][1].gsub(/ /,'').downcase - Person.create( :email => "#{email}@joindiaspora.com", :url => "http://#{email}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) + username = names[n][1].gsub(/ /,'').downcase + Person.create( :email => "#{username}@#{username}joindiaspora.com", :url => "http://#{username}.joindiaspora.com/", :active => true, :profile => Profile.new(:first_name => names[n][0], :last_name => names[n][1])) } diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index b6aed413e..364580fed 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -9,7 +9,7 @@ require 'config/environment' # Create seed user -user = User.create( :email => "tom@joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) +user = User.create( :email => "tom@tom.joindiaspora.com", :password => "evankorth", :url => "http://tom.joindiaspora.com/", :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) names = [ ["George", "Washington"], ["John", "Adams"], From 613e2da3e6fa8f38853d8be8c726951e3b5d3a6d Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 16:11:08 -0700 Subject: [PATCH 46/49] Made logging clearer, fixing zombiefriends --- app/controllers/dashboards_controller.rb | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 5db00abf3..a5bdc0202 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -36,25 +36,25 @@ class DashboardsController < ApplicationController def zombiefriends render :nothing => true - backer_info = ["http://washington.joindiaspora.com", - "http://adams.joindiaspora.com", - "http://jefferson.joindiaspora.com", - "http://madison.joindiaspora.com", - "http://monroe.joindiaspora.com", - "http://quincyadams.joindiaspora.com", - "http://jackson.joindiaspora.com", - "http://buren.joindiaspora.com", - "http://harrison.joindiaspora.com", - "http://tyler.joindiaspora.com", - "http://polk.joindiaspora.com", - #"http://taylor.joindiaspora.com", - #"http://fillmore.joindiaspora.com", - #"http://pierce.joindiaspora.com", + backer_info = ["http://washington.joindiaspora.com/", + "http://adams.joindiaspora.com/", + "http://jefferson.joindiaspora.com/", + "http://madison.joindiaspora.com/", + "http://monroe.joindiaspora.com/", + "http://quincyadams.joindiaspora.com/", + "http://jackson.joindiaspora.com/", + "http://buren.joindiaspora.com/", + "http://harrison.joindiaspora.com/", + "http://tyler.joindiaspora.com/", + "http://polk.joindiaspora.com/", + #"http://taylor.joindiaspora.com/", + #"http://fillmore.joindiaspora.com/", + #"http://pierce.joindiaspora.com/", ] if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil backer_info.each do |backer| - logger.info backer + logger.info "Zombefriending #{backer}" User.owner.send_friend_request_to(backer) end end From e5a5b5a82858f8800deb8565faaf68590b6fe95d Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 16:20:38 -0700 Subject: [PATCH 48/49] Fixing zombies --- app/controllers/dashboards_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index a5bdc0202..aa0780f87 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -16,7 +16,7 @@ class DashboardsController < ApplicationController def warzombie render :nothing => true - if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil + if User.owner.email == "tom@tom.joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.owner) Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.owner ) StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.owner, :created_at => Time.now-930) @@ -52,7 +52,7 @@ class DashboardsController < ApplicationController #"http://pierce.joindiaspora.com/", ] - if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil + if User.owner.email == "tom@tom.joindiaspora.com" && Person.friends.first.nil? backer_info.each do |backer| logger.info "Zombefriending #{backer}" User.owner.send_friend_request_to(backer) From 7fb7c519cc8320c32773ad25553d8d0c285703b2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 15 Jul 2010 16:30:56 -0700 Subject: [PATCH 49/49] Adding active to friend view --- app/views/people/show.html.haml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index 50050d2eb..ee0892315 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -1,6 +1,10 @@ .span-20.last %h1= "#{@person.real_name}" = link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete +%p + %b Active? +%p + = @person.active - if @person_profile %p %b First Name