Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
hubzilla
addons
Commits
d6febe92
Commit
d6febe92
authored
Nov 04, 2020
by
Mario
Browse files
make sure the signature is valid and fix an issue with public keys storage
parent
16583244
Changes
2
Hide whitespace changes
Inline
Side-by-side
pubcrawl/Mod_Inbox.php
View file @
d6febe92
...
...
@@ -25,6 +25,11 @@ class Inbox extends \Zotlabs\Web\Controller {
$hsig
=
HTTPSig
::
verify
(
$data
);
if
(
!
(
$hsig
[
'header_signed'
]
&&
$hsig
[
'header_valid'
]
&&
$hsig
[
'content_signed'
]
&&
$hsig
[
'content_valid'
]))
{
logger
(
'HTTPSig::verify() failed: '
.
print_r
(
$hsig
,
true
),
LOGGER_DEBUG
);
http_status_exit
(
403
,
'Permission denied'
);
}
$AS
=
new
ActivityStreams
(
$data
);
if
(
$AS
->
is_valid
()
&&
$AS
->
type
===
'Announce'
&&
is_array
(
$AS
->
obj
)
...
...
@@ -104,8 +109,10 @@ class Inbox extends \Zotlabs\Web\Controller {
return
;
}
if
(
is_array
(
$AS
->
actor
)
&&
array_key_exists
(
'id'
,
$AS
->
actor
))
if
(
is_array
(
$AS
->
actor
)
&&
array_key_exists
(
'id'
,
$AS
->
actor
))
{
as_actor_store
(
$AS
->
actor
[
'id'
],
$AS
->
actor
);
}
if
(
$AS
->
type
==
'Announce'
&&
is_array
(
$AS
->
obj
)
&&
array_key_exists
(
'attributedTo'
,
$AS
->
obj
))
{
$arr
=
[];
...
...
pubcrawl/as.php
View file @
d6febe92
...
...
@@ -1127,6 +1127,37 @@ function as_actor_store($url,$person_obj) {
if
(
!
is_array
(
$person_obj
))
return
;
// it seems we were loosing public keys due to an issue Lib/Activity::encode_person()
// if so, refetch the person object and fix it.
$fix_pubkey
=
false
;
if
(
!
$person_obj
[
'publicKey'
][
'publicKeyPem'
])
{
$fix_pubkey
=
true
;
$x
=
as_fetch
(
$url
);
if
(
!
$x
)
return
;
$AS
=
new
ActivityStreams
(
$x
);
if
(
!
$AS
->
is_valid
())
{
return
;
}
$person_obj
=
null
;
if
(
in_array
(
$AS
->
type
,
[
'Application'
,
'Group'
,
'Organization'
,
'Person'
,
'Service'
]))
{
$person_obj
=
$AS
->
data
;
}
elseif
(
$AS
->
obj
&&
(
in_array
(
$AS
->
obj
[
'type'
],
[
'Application'
,
'Group'
,
'Organization'
,
'Person'
,
'Service'
]
)))
{
$person_obj
=
$AS
->
obj
;
}
else
{
return
;
}
}
$icon
=
''
;
$name
=
$person_obj
[
'name'
];
if
(
!
$name
)
...
...
@@ -1223,9 +1254,8 @@ function as_actor_store($url,$person_obj) {
// Record exists. Cache existing records for one week at most
// then refetch to catch updated profile photos, names, etc.
$d
=
datetime_convert
(
'UTC'
,
'UTC'
,
'now - 1 week'
);
if
(
$r
[
0
][
'xchan_name_date'
]
>
$d
)
if
(
$r
[
0
][
'xchan_name_date'
]
>
$d
&&
$fix_pubkey
===
false
)
return
;
// update existing record
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment