Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
f292ad4b
Commit
f292ad4b
authored
10 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Add script to check and auth chain and current state of a room
parent
6de79942
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/check_auth.py
+65
-0
65 additions, 0 deletions
scripts/check_auth.py
with
65 additions
and
0 deletions
scripts/check_auth.py
0 → 100644
+
65
−
0
View file @
f292ad4b
from
synapse.events
import
FrozenEvent
from
synapse.api.auth
import
Auth
from
mock
import
Mock
import
argparse
import
itertools
import
json
import
sys
def
check_auth
(
auth
,
auth_chain
,
events
):
auth_chain
.
sort
(
key
=
lambda
e
:
e
.
depth
)
auth_map
=
{
e
.
event_id
:
e
for
e
in
auth_chain
}
create_events
=
{}
for
e
in
auth_chain
:
if
e
.
type
==
"
m.room.create
"
:
create_events
[
e
.
room_id
]
=
e
for
e
in
itertools
.
chain
(
auth_chain
,
events
):
auth_events_list
=
[
auth_map
[
i
]
for
i
,
_
in
e
.
auth_events
]
auth_events
=
{
(
e
.
type
,
e
.
state_key
):
e
for
e
in
auth_events_list
}
auth_events
[(
"
m.room.create
"
,
""
)]
=
create_events
[
e
.
room_id
]
try
:
auth
.
check
(
e
,
auth_events
=
auth_events
)
except
Exception
as
ex
:
print
"
Failed:
"
,
e
.
event_id
,
e
.
type
,
e
.
state_key
print
ex
print
json
.
dumps
(
e
.
get_dict
(),
sort_keys
=
True
,
indent
=
4
)
# raise
print
"
Success:
"
,
e
.
event_id
,
e
.
type
,
e
.
state_key
if
__name__
==
'
__main__
'
:
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
json
'
,
nargs
=
'
?
'
,
type
=
argparse
.
FileType
(
'
r
'
),
default
=
sys
.
stdin
,
)
args
=
parser
.
parse_args
()
js
=
json
.
load
(
args
.
json
)
auth
=
Auth
(
Mock
())
check_auth
(
auth
,
[
FrozenEvent
(
d
)
for
d
in
js
[
"
auth_chain
"
]],
[
FrozenEvent
(
d
)
for
d
in
js
[
"
pdus
"
]],
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment