Commit Graph

73 Commits (fa362ecef2f71419d3819a763313167c42da9443)

Author SHA1 Message Date
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
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 16f593f786 Fix some linting errors 2017-12-06 13:55:51 +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 7236090989
Add config option to disable registration (#360) 2017-12-04 17:07:45 +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 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 8599a36fa6
Use a Postgres database rather than Memory for Naffka (#337)
* Update naffka dep

* User Postgres database rather than Memory for Naffka
2017-11-16 17:35:28 +00:00
Erik Johnston 561315e1d6
Add gofmt linter (#339)
* Check that gofmt has been run

* gofmt files

* Tabs and spaces
2017-11-16 10:12:02 +00:00
Richard van der Hoff 4124ce2ac0
Store keys rather than json in the keydatabase (#330)
* bump gomatrixserverlib

(changes to KeyFetcher and KeyDatabase interfaces)

* Store keys rather than json in the keydatabase

Rather than storing the raw JSON returned from a /keys/v1/query call in the
table, store the key itself.

This makes keydb.Database implement the updated KeyDatabase interface.
2017-11-15 17:46:16 +00:00
Erik Johnston 139fae988e Fix linting errors in go1.9.1 (#336)
Fix linting errors in go1.9.1
2017-11-15 11:13:09 +00:00
Richard van der Hoff bf855a7e5c
Factor out keyring initialisation (#329)
Take the keyring init from the client-api-server and the monolith out to a
shared file
2017-11-13 18:39:09 +00:00
Michael Telatynski 90396b5620 implement voip/turnServer API endpoint (#323)
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-11-09 09:58:45 +00:00
Andrew Morgan b7cfc2e057 Federation: Implement Query Profile API (#317)
* Federation: Implement Query Profile API

Implements the server portion of: `GET
/_matrix/federation/v1/query/profile?user_id=...&field=...`

Closes #278

Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>

* Properly export profile-related structs and fix wording

Signed-off-by: Andrew (anoa) <anoa@openmailbox.org>

* Check provided user's domain matches our own.
2017-11-05 14:03:54 -04:00
Erik Johnston e5944e0fdb Move BuildEvent to common package (#315)
This is in preperation for implementing various federation APIs that
need to build events.
2017-10-25 14:44:33 +01:00
Erik Johnston 464fb5de1c Update vendor libraries and dendrite to s/Sirupsen/sirupsen/ (#304) 2017-10-13 14:42:57 +01:00
Mark Haines 847621bc5d Add config for setting up a jaeger opentracing reporter (#271)
* Add config for setting up a jaeger opentracing reporter

* Remove redundant comment
2017-09-28 17:00:23 +01:00
Mark Haines c4947c2ffb Add opentracing Spans to the HTTP APIs (#270)
* Add opentracing Spans to the HTTP APIs

* Add opentracing spans to the HTTP RPC clients

* Set the span in the request context

* More docstring
2017-09-28 14:50:40 +01:00
Erik Johnston 8dabca0f07 Implement shared secret registration (#257)
* Implement shared secret registration

* Use HexString from gomatrixserverlib

* Correctly check username validility
2017-09-22 16:13:19 +01:00
Mark Haines fef290c47e Add context to the server key database (#248) 2017-09-21 16:16:02 +01:00
Mark Haines a7773d3d3d Add context to the partition offset table (#249) 2017-09-21 15:09:19 +01:00
Erik Johnston 340a84cdc0 Add staticcheck lint (#245) 2017-09-20 14:54:17 +01:00
Erik Johnston 584acbe9a9 Add 'unused' lint (#241)
* Add 'unused' lint

* Keep testdata consts
2017-09-20 14:47:29 +01:00
Erik Johnston cc2f755cb3 Add gosimple linter (#242) 2017-09-20 14:15:38 +01:00
Erik Johnston b72142ace5 Add vet linter (#240) 2017-09-20 13:40:22 +01:00
Erik Johnston 8a36a7e89b Add errcheck linter (#238)
* Add errcheck linter

* Add config for 'fast' linters

* Fix errcheck lint stuff

* Fix errcheck lint
2017-09-20 10:59:19 +01:00
Mark Haines 029e71828a Add context.Context to the federation client (#225)
* Add context.Context to the federation client

* gb vendor update github.com/matrix-org/gomatrixserverlib
2017-09-13 11:03:41 +01:00
Brendan Abolivier f1fce55697 Add config and checks for trusted ID servers (#206)
* Add config for trusted ID servers

* Add new error

* Implement check for trusted ID server

* Complete unfinished comment

* Make comment more explicit in the config file

* Use go standard errors in membership.go

* Use standard errors instead of JSON responses in threepid

* Doc errors

* Remove unused parameter
2017-09-11 19:18:19 +01:00
Brendan Abolivier 4d1d503d43 Processing of pending invites on 3PID binding (#218)
* Add missing file headers

* Move the ID server's signatures verification to common

* Allow verification without specifying a server name

* Add third-party structs to membership events content

* Add processing of 3PID onbind requests

* Use reference for third party invite data

* Fix return arguments order

* Revert "Move the ID server's signatures verification to common"

This reverts commit 93442010316ce71a77ac58ffd3613754ce8fe969.

* Revert "Allow verification without specifying a server name"

This reverts commit fd27afbf82eac50fe9f7b83b26cfce3c66d530d2.

* Remove checks that are already occurring in gomatrixserverlib

* Change return type of createInviteFrom3PIDInvite

* Add doc, add checks in fillDisplayName

* Use MakeFedAPI

* Invert condition

* Use AuthEvents to retrieve the 3PID invite

* Update comment

* Remove unused parameter

* gb vendor update github.com/matrix-org/gomatrixserverlib
2017-09-08 15:17:12 +01:00
Mark Haines 643d05b157 Add function for making authed federation APIs (#208) 2017-09-04 13:14:01 +01:00
Richard van der Hoff 8c2e6273e3 Add command to generate test keys/certs (#204)
Add `generate-keys` command, which can be used to generate TLS keys/certs, and,
more usefully, matrix signing keys.
2017-08-31 12:28:58 +01:00
Brendan Abolivier 2183712e04 Process requests for 3PID invites (#201)
* Structure for 3PID invite

* Generate invite from 3PID known by ID server

* Load user profile in a separate function

* Generate m.room.third_party_invite if the ID server doesn't know the 3PID

* Fix URLs to the spec in comments

* Move third-party invites to a separate package and doc' it

* Handle non-OK status codes on lookup

* Send display name to identity server when asking to store an invite

* Remove join response structure

* Change the way some variables are declared or passed as argument

* Use gomatrixserverlib.Base64String instead of the builtin base64 package

* Don't copy the public keys array
2017-08-29 15:17:26 +01:00
Brendan Abolivier b15ce900ab Implement public rooms APIs (#185)
* Move events contents to common

* Basic database structure

* Complete database update

* Support visibility update and retrieval

* Add HTTP methods for visibility update and retrieval

* Add the database for the new component

* Add a listener for the new component

* Fix attribute update statements

* Create public rooms component

* Fix failing test

* Add roomserver consumer

* Fix a bug in aliases creation

* Add a check on type

* Implement public rooms directory

* Use auth API for visibility update

* Support filtering

* Add component to monolith

* Various fixes

* Fix computation of next public rooms batch

* Retrieve state events from the roomserver query API + avoid dupes on join

* Split update of string or boolean attribute in two separate functions

* Use event type to detect duplicate joins

* Improve the joined members counter computation

* Use event.RoomID()
2017-08-22 11:12:51 +01:00
Mark Haines 808c2e09f6 Make txn *sql.Tx arguments optional everywhere using a utility function (#191)
* Make txn *sql.Tx arguments optional everywhere using a utility function

* Clarify that if the txn is nil the stmt will run outside a transaction
2017-08-21 17:20:23 +01:00
Mark Haines 57b7097368 Add input API for adding invites to the roomserver. (#187)
* Add input API for adding invites to the roomserver.

This API handles invites received over federation that occur outside of a room.

* Add some docstring for withTransaction

* Use a nicer pattern for wrapping transactions

* Fix MembershipUpdater method to not commit the transaction before returning it

* Use the Transaction interface from common
2017-08-21 16:37:11 +01:00
Mark Haines 81179a0595 Fix integration test proxy certificate arguments (#190) 2017-08-21 16:23:59 +01:00
Mark Haines c27d1fdfb4 Optionally use naffka in the monolithic server (#183)
* dependency injection for the kafka consumers/producers

* Optionally use naffka in the monolithic server

* remember to call setupKafka()

* tweak imports

* fix integration tests

* Add use_naffka to the example config

* Update comment on the listen APIs
2017-08-16 13:36:41 +01:00
Mark Haines 4d1504ee93 Add prefixes to namespace the SQL tables. (#177)
* Add prefixes to namespace the SQL tables.

This means that multiple components can share a single database schema
without colliding with each other.

Once this lands it will be possible to run a single monolithic dendrite
against a single postgresql schema.

Hopefully this will make trivial deployments and development easier.

* Comment
2017-08-07 11:51:46 +01:00
Mark Haines 4975eb9074 Move setting up the api mux to outside the routing.Setup functions. (#173)
This makes it possible to setup all the component APIs on a single http
listener which is necessary if we want to combine all the components
into a single monolith.
2017-08-03 15:10:39 +01:00
Brendan Abolivier 0fbb8b7824 Make account data sync incremental (#170)
* Clean roomserver consumer

* Make account data sync incremental

* Use a different name for the sync AD table

* Improved error logging

* Created missing topic in tests

* Add client API topic to tests

* Add client API topic to common

* Move data batch retrieval

* Add database index for data retrieval

* Fix typo in table name

* Fix indentation
2017-08-02 16:21:35 +01:00
Mark Haines e6d77d6bde Use HTTP API for roomserver input. (#161)
* Use HTTP API for roomserver input.

* Use synchronous HTTP API for writing events to the roomserver

* Remove unused config for kafka topic

* Tweak comments
2017-07-18 13:40:03 +01:00
Brendan Abolivier d9b8e5de45 Keep track of membership in Client API (#159)
* Saving memberships

* Removed unused index

* Removed useless log

* Fixed membership not being saved on the right conditions + added membership removal

* Updated outdated comment

* Use server lib method + check server name + use new roomserver API

* Better handling of events from the room server

* Fixed membership removal

* Corrected indentation

* Fix tests (hopefully)

* Replace broken kafka mirror

* Apply requested changes on database management

* Remove useless check and function

* Moved memberships update to the database package

* Use new common function

* Remove useless function
2017-07-17 18:10:56 +01:00
Mark Haines b06d1124f7 Factor out runTransaction to common code (#162) 2017-07-17 17:20:57 +01:00
Brendan Abolivier 355ab5eedf Notify profile update (#153)
* Profile retrieval

* Saving avatar (without propagating it)

* Saving display name (without propagating it)

* Getters for display name and avatar URL

* Doc'd

* Introduced new Kafka topic and producer

* Updated config with new kafka topic

* Switched to samara producer and now sending messages

* Doc'd

* Put kafka update after the database insert

* Doc'd profileUpdate structure

* Removed unused parameter

* Moved user updates producer to clientapi/producers
2017-07-11 14:14:06 +01:00
Mark Haines b2f9b8c641 Update the example configs with the new unified config (#146)
* Update the example configs with the new unified config

* Review comments

* Use an int for the config version
2017-07-05 13:10:28 +01:00
Mark Haines 8f1dca4e74 Add a component for sending event to remote matrix servers using fede… (#148)
* Add a component for sending event to remote matrix servers using federation

* Use named constants

* Comment on why we combine the deltas

* Comments

* Copyright headers!

* Fix the copy+Pasted comment

* Add tests for combineDeltas

* Review comments

* More review comments

* More comments

* Even more comments

* Name the mutexes

* Document what the mutexes are protecting

* Simplify the SQL, and more comments
2017-06-28 16:10:17 +01:00
Mark Haines e67f9401be Replace the cmd specific config with common config. (#144)
* Move all the dendrite config in to a single place

* Add tests for config parsing

* replace syncserver config with common config

* Replace client API config with common config

* Replace federation API config with common config

* Replace media api config with common config

* Replace room server config with common config

* Remove unused readKey function

* Fix the integration tests

* Comment on hardcoding roomserver to HTTP

* Add a method for getting RoomServerURL

This moves the hardcoding of HTTPs into one place.
2017-06-19 15:21:04 +01:00