0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-10-20 08:38:56 +02:00
Commit graph

346 commits

Author SHA1 Message Date
Anant Prakash
7ac1efc4b3 Scan AppServiceID from accounts table, fix typo (#474) 2018-05-31 10:46:50 +01:00
Andrew Morgan
04551becb4
Filter Roomserver Events Based on Application Service (#467)
* Compile room and alias namespace regexs

We'll be needing these for event filtering in the appservice component.

Signed-off-by: Andrew Morgan <andrewm@matrix.org>

* App service filters roomserver events

Doing so based on namespace regexes that each app service has defined.

To get the aliases for a roomID a new aliasAPI endpoint was defined,
GetAliasesFromRoomID, which does exactly what it says on the tin.

Next step is to queue events to be sent off to each homeserver.

* Additionally filter state events for app services

* Fixed context, logging, derps, config handling

* Prevented user from creating more than one regex per namespace type

Got caught out by realizing I had an extra '-' in the config file. This
prevents anyone from making the same mistake :)

* Removed exclusive RoomID namespace regex, as we won't need to check
upon room creation if the ID is reserved exclusively by an AS (as this
is silly and horribly inefficient).

* Fixed all else mentioned
2018-05-30 13:43:13 +01:00
Anant Prakash
60e77959ee [roomserver] Store transaction ID and prevent reprocessing of events (#446) 2018-05-26 12:03:35 +01:00
Andrew Morgan
ed388a32b7
Add Application Service component (#462)
* Add Application Service component

The component subscribes to the Roomserver kafka stream, filtering
events to be eventually sent off to relevant app services, as well as
handling incoming HTTP traffic from app services on the
`/matrix/app/r0/*` route.

Signed-off-by: Andrew Morgan <andrewm@matrix.org>

* Make linting happy

Signed-off-by: Andrew Morgan <andrewm@matrix.org>
2018-05-24 13:54:42 +01:00
Andrew Morgan
1d7278d950
Fix typo and bug in /devices/{deviceID} (#465)
* Fix typo in API Endpoint

Signed-off-by: Andrew Morgan <andrewm@matrix.org>

* Fixed another typo and bug

Use a sql.NullInt64 instead of an Int64 as that allows for values to
sometimes be null when pulling from a postgres table. Can result in
error otherwise.

Signed-off-by: Andrew Morgan <andrewm@matrix.org>
2018-05-24 13:53:22 +01:00
Andrew Morgan
c238048599
Update Prometheus metrics tracking (#459)
Signed-off-by: Andrew Morgan <andrewm@matrix.org>
2018-05-23 15:42:08 +01:00
Andrew Morgan
93a6178d45 Fix typo in register.go
All in a hard day's work.

Signed-off-by: Andrew Morgan <andrewm@matrix.org>
2018-05-22 18:44:07 +01:00
Andrew Morgan
f5cc5bd9bb
Revert "Add token generation using go macaroon (#437)" (#448)
This reverts commit afeab7b2d4.

Signed-off-by: Andrew Morgan <andrewm@matrix.org>
2018-05-22 11:29:19 +01:00
Anant Prakash
afeab7b2d4 Add token generation using go macaroon (#437)
* Add Go macaroon library

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>

* Add macaroon generation and serialization, for login token.

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>

* Remove copyright, trim empty lines

* Make Serialize functions private

* Fix typos
2018-05-22 10:13:58 +01:00
Zero King
89e0a9e812 Fix typo (#445)
Signed-off-by: Zero King <l2dy@icloud.com>
2018-05-21 05:34:04 -07:00
Anant Prakash
29532e7bc3 Make clientapi:sendevents idempotent (#444)
* Add transactions.Cache to clientapi setup

* Add idempotency to clientapi/SendEvent
2018-05-18 10:49:40 +01:00
Anant Prakash
8861437c26 Add module for transactions cache (#440)
* Add transactions cache, write tests.

Add a transactions module in dendrite/common. This is needed for idempotent APIs.

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>

* Use cycling double map instead, improve code logic, remove unneeded test

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>

* Update code comments

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>

* Use two constructors for default and custom cleanupPeriod
Add code comments

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>
2018-05-16 11:36:40 +01:00
Zero King
4c807e082f Fix typo (#441)
Signed-off-by: Zero King <l2dy@icloud.com>
2018-05-15 10:14:26 +01:00
Anant Prakash
1f61537d66 Refactor username parsing function of clientapi:login (#432)
* Refactor username parse function of login

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>

* Add tests for userutil

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>
2018-04-20 15:52:21 +01:00
mohit kumar singh
aff401ed06 fix probable bugs, package names and keywords used as identifiers (#428)
Signed-off-by: MohitKS5 <mohitkumarsingh907@gmail.com>
2018-04-20 15:50:44 +01:00
Tristan Claverie
58c10c6d54 Enable debug logs using a configuration parameter and put all logs in a single file (#379) 2018-04-10 13:21:20 +01:00
Anant Prakash
8a1f3195ca Return empty list instead of null for new UI-auth sessions (#406)
fixes #399

Signed-off-by: Anant Prakash <anantprakashjsr@gmail.com>
2018-03-15 17:21:08 +00:00
Andrew Morgan
66af311b6a Add r0.3.0 to supported client API versions (#426)
Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2018-03-14 17:36:02 +00:00
Scott Raine
c9add39768 Use http.Status* and http.Method* where appropriate (#417)
Signed-off-by: Scott Raine <me@nylar.io>
2018-03-13 15:55:45 +00:00
Andrew Morgan
f12ffb660d Correct if statement logic (#415)
Should return error if we didn't find an Application Service, not the
other way around. Reported by @APWhitehat

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2018-03-13 15:35:56 +00:00
Vincent Glize
6b55972183 Fix error when keyblock is nil (#394) 2018-03-03 12:18:28 +00:00
Andrew Morgan
72a1bdffd6 Fix typo (#402)
accouqnt -> account

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2018-03-02 09:08:02 +00:00
Andrew Morgan
dfcf31f293 Prevent AS user check if no AS registered (#392)
When a user registered on a homeserver with no application services
 registered, registration would check if the meta-regexp object matched
 the proposed user's new username.

 Apparently "" is a regex that matches everything, so every user was
 then barred from registering as they were supposedly registering inside
 an AS' exclusive namespace.

 This change prevents that check from happening by setting the exclusive
 regex to ^$ instead, preventing any matches from occurring.

 We also prevent the check for exclusivity if there are no namespaces
 registered for performance.

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2018-02-27 11:42:10 +00:00
Andrew Morgan
08274bab5a Application Service Registration (#390)
* Add ability for App Services to register users

AS Tokens are pulled from their respective configs, which are then
checked against when an AS tries to register using
m.login.application_service. If the token exists and the new username is
within their specified namespace, then the user is created as a
password-less user.

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>

* Validate loaded Application Services

* Ensure no two app services have the same token or ID
* Check namespaces are valid regex
* Ensure users can't register inside an exclusive app service namespace
* Ensure exclusive app service namespaces are exclusive with each other
* Precompile application service namespace regexes so we don't need to
do so every time a user is registered

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2018-02-08 11:02:48 +00:00
Thibaut CHARLES
27c335438f selectRecentEvents: reverse events in SQL query (#386)
Signed-off-by: Thibaut CHARLES cromfr@gmail.com
2018-01-02 10:33:25 +00:00
Thibaut CHARLES
8a3f9b0561 Implement some createRoom parameters (#374)
* Impl some createRoom parameters

* Fix linter warnings

* Cleaned comments
2018-01-02 10:32:53 +00:00
Erik Johnston
d22fb24a66
Factor out component setup from commands (#384)
* Add base component

* Convert clientapi to using base component

* Convert federationapi to using base component

* Convert federationsender to using base component

* Convert mediaapi to using base component

* Convert publicroomsapi to using base component

* Convert roomserver to using base component

* Convert syncapi to using base component

* Convert monolith to using base component

* Split out config parsing and roomserver API creation
2018-01-02 10:26:56 +00:00
Andrew Morgan
fa362ecef2 Load Application Service Configuration Files (#377)
Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2017-12-19 17:00:44 +00:00
Richard van der Hoff
899f267c47
Fix roomserver deadlock (#380)
Move the mutex lock outside the loop so that we don't lock up if there is more
than one event
2017-12-19 11:29:49 +00:00
Thibaut CHARLES
ec30d143cd User registration return M_USER_IN_USE when username is already taken (#372)
When registering a new user using POST `/_matrix/client/r0/register`, the server was returning a 500 error when user name was already taken.

I added a check in `completeRegistration` to verify if the username is available before inserting it, and return a 400 `M_USER_IN_USE` error if there is a conflict, as [defined in matrix-doc](https://matrix.org/speculator/spec/HEAD/client_server/unstable.html#post-matrix-client-r0-register)

Signed-off-by: Thibaut CHARLES cromfr@gmail.com
2017-12-19 09:49:42 +00:00
Erik Johnston
b835e585c4
Add transaction ID to events if sending device (#368) 2017-12-15 15:42:55 +00:00
Erik Johnston
de6529d766
Ensure we only process one event at a time (#376) 2017-12-15 15:22:06 +00:00
Richard van der Hoff
58e228fc3a s/VerifyEventSignatures/VerifyAllEventSignatures/
gomatrixserverlib API has been updated
2017-12-12 10:26:25 +00:00
Erik Johnston
16f593f786 Fix some linting errors 2017-12-06 13:55:51 +00:00
Erik Johnston
75aa316a6a
Write and read transaction id from sync DB (#367) 2017-12-06 09:37:18 +00:00
Erik Johnston
578d8cf492
Add CORS headers to all responses including errors (#364) 2017-12-06 09:36:50 +00:00
Andrew Morgan
bc3dd821f9 Implemented ReCaptcha registration method (#343)
Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>
2017-12-05 16:16:14 +00:00
Erik Johnston
7d38e82f25
Pass client transaction IDs along the kafka streams (#362) 2017-12-04 18:07:52 +00:00
Erik Johnston
7236090989
Add config option to disable registration (#360) 2017-12-04 17:07:45 +00:00
Andrew Morgan
791a5ee7f4 Squash username to all lowercase letters upon registration (#361)
* Squash username to all lowercase letters upon registration

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2017-12-04 09:40:36 +00:00
Erik Johnston
cc12fc930a Fix typo 2017-11-29 09:48:55 +00:00
Andrew Morgan
a4460dd6ee Set up proper registration flow (#354)
* Refactor registration to align with the spec
* We now keep track of sessions and their completed registration stages.
* We only complete registration if the client has completed a full flow.
* New Derived section in config for data derived from config options.
* New config options for captcha.
* Send params back to client for each registration stage.

Signed-off-by: Andrew Morgan (https://amorgan.xyz) <andrew@amorgan.xyz>
2017-11-29 09:43:03 +00:00
Erik Johnston
b7a3b92a9f
Implement /make_join and /send_join (#316) 2017-11-29 09:38:56 +00:00
Richard van der Hoff
fc92fdbe0a
Add OPTIONS handlers everywhere (#355)
Everything gets pre-flighted now, because of the Authorization header, so we
need to support OPTIONS everywhere.
2017-11-27 12:18:48 +00:00
Richard van der Hoff
0786318a04
Bump gomatrixserverlib (#353)
* Bump gomatrixserverlib

Mostly because I want to use Erik's go-faster jsoning.

* Update KeyDB for new KeyFetcher API

we now need to implement FetcherName.

* Attempt to fix integ tests

CanonicalJSON doesn't like the empty string, apparently, and anyway
canonicalising it is pointless.

* More integ test fix
2017-11-27 12:05:14 +00:00
Erik Johnston
9e352e7311
Implement query to get state and auth chain (#352)
* Implement query to get state and auth chain

* Add routing for queryStateAndAuthChain

* Comments

* Fix fetching wrong set of events

* Add tests

* Shuffle and comment
2017-11-27 10:20:00 +00:00
Erik Johnston
0d72e34acf
Fix panic if upload name wasn't supplied (#351) 2017-11-22 15:45:03 +00:00
Erik Johnston
f42f44391f
Fix /sync when we have no events (#341)
* Fix /sync when we have no events

We used a since token of 0 to mean that no token was given. However, naffka
streams start at 0. This causes clients to get stuck spinning forever until an
event is sent.

This changes it so that we pass around pointers instead, with nil meaning a
since token wasn't given.

* Comment

* Fix unit tests

* Comments

* Fix typo
2017-11-22 09:51:12 +00:00
Ross Schulman
ea53558cca Implement room_alias federation end point (#338)
* Add room alias query endpoint

* Try to fix indentation problems

* Fix linting errors and use of httpReq.FormValue

Signed-off-by: Ross Schulman <ross@rbs.io>

* Run gofmt

* Check for empty alias parameter and fix route URL

Signed-off-by: Ross Schulman <ross@rbs.io>

* Fix some linting errors

Signed-off-by: Ross Schulman <ross@rbs.io>

* Delete extra copy of directory route
2017-11-20 14:33:49 +00:00
Erik Johnston
19a716e7da
Fix create filter API (#342) 2017-11-18 15:06:51 +00:00