aboutsummaryrefslogtreecommitdiff
path: root/userapi
AgeCommit message (Collapse)Author
2021-01-04Ensure appservices can auth as users in their namespaces (#1672)Jason Robinson
* Ensure appservices can auth as users in their namespaces Currently in Dendrite appservices can only auth as a user if the user was created by said appservice. This does not align with the appservices spec which specifically says: > The application service may specify the virtual user to act as through use of a user_id query string parameter on the request. The user specified in the query string must be covered by one of the application service’s user namespaces. https://matrix.org/docs/spec/application_service/r0.1.2#identity-assertion In the case that a user has been created for example via manual registration but belongs to an appservice namespace, the current functionality does not allow appservices to auth as them. This PR fixes that by replacing the appservice ID check with a check against the appservice namespace. This also matches Synapse functionality, which I confirmed to allow appservices to auth as a user in their namespace, irregardless of how the user was registered. * Also allow appservice itself to auth with user_id Appservice user_id + access token check needs to work both when user_id is the appservice and when appservice has the user in their user namespace. Signed-off-by: Jason Robinson <mail@jasonrobinson.me>
2020-12-21fix imports (#1665)6543
* fix imports Signed-off-by: 6543 <6543@obermui.de> * add sqlite driver import back Signed-off-by: 6543 <6543@obermui.de> * rm import of userapi/storage/accounts/sqlite3/storage.go
2020-12-02Top-level setup package (#1605)Neil Alexander
* Move config, setup, mscs into "setup" top-level folder * oops, forgot the EDU server * Add setup * goimports
2020-11-20Update last seen on sync requests (#1593)Neil Alexander
* Update last seen on sync requests * Fix MSC2836 unit tests * Only update once per minute * Remove debug logging * Configurable option * Simplify updateLastSeen/cleanLastSeen
2020-11-17Implemented whois endpoint (#1573)David Spenler
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2020-10-19Fix internal http api (#1535)S7evinK
Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
2020-10-15Automatically upgrade databases on startup (#1529)Kegsay
* Support auto-upgrading accounts DB * Auto-upgrade device DB deltas * Support up/downgrading from cmd/goose * Linting * Create tables then do migrations then prepare statements To avoid failing due to some things not existing * Linting
2020-10-09Use default value when adding column which is not null (#1501)S7evinK
Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
2020-10-09Extend device_devices table (#1471)S7evinK
* Add last_used_ts and IP to database * Add migrations * Rename column Prepare statements * Add interface method and implement it Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Rename struct fields * Add user_agent to database * Add userAgent to registration calls * Add missing "IF NOT EXISTS" * use txn writer * Add UserAgent to Device Co-authored-by: Kegsay <kegan@matrix.org>
2020-10-02Implement account deactivation (#1455)Loïck Bonniot
* Implement account deactivation See #610 Signed-off-by: Loïck Bonniot <git@lesterpig.com> * Rename 'is_active' to 'is_deactivated' Signed-off-by: Loïck Bonniot <git@lesterpig.com> Co-authored-by: Kegsay <kegan@matrix.org>
2020-09-24Update all usages of tx.Stmt to sqlutil.TxStmt (#1423)Sam
* Replace all usages of txn.Stmt with sqlutil.TxStmt Signed-off-by: Sam Day <me@samcday.com> * Fix sign off link in PR template. Signed-off-by: Sam Day <me@samcday.com> Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
2020-09-04Password changes (#1397)Neil Alexander
* User API support for password changes * Password changes in client API * Update sytest-whitelist * Remove debug logging * Default logout_devices to true * Fix deleting devices by local part
2020-09-01Storage tweaks (#1373)Neil Alexander
* Sync API tweaks * User API tweaks
2020-08-27Remove device DB from clientapi (#1352)Kegsay
* Remove device DB from clientapi * Remove device DB from startup configuration It's all an impl detail now in user API
2020-08-21Component-wide TransactionWriters (#1290)Neil Alexander
* Offset updates take place using TransactionWriter * Refactor TransactionWriter in current state server * Refactor TransactionWriter in federation sender * Refactor TransactionWriter in key server * Refactor TransactionWriter in media API * Refactor TransactionWriter in server key API * Refactor TransactionWriter in sync API * Refactor TransactionWriter in user API * Fix deadlocking Sync API tests * Un-deadlock device database * Fix appservice API * Rename TransactionWriters to Writers * Move writers up a layer in sync API * Document sqlutil.Writer interface * Add note to Writer documentation
2020-08-19Transaction writer changes, move roomserver writers (#1285)Neil Alexander
* Updated TransactionWriters, moved locks in roomserver, various other tweaks * Fix redaction deadlocks * Fix lint issue * Rename SQLiteTransactionWriter to ExclusiveTransactionWriter * Fix us not sending transactions through in latest events updater
2020-08-12Fix more E2E sytests (#1265)Kegsay
* WIP: Eagerly sync device lists on /user/keys/query requests Also notify servers when a user's device display name changes. Few caveats: - sytest `Device deletion propagates over federation` fails - `populateResponseWithDeviceKeysFromDatabase` is called from multiple goroutines and hence is unsafe. * Handle deleted devices correctly over federation
2020-08-10Configuration format v1 (#1230)Neil Alexander
* Initial pass at refactoring config (not finished) * Don't forget current state and EDU servers * More shifting around * Update server key API tests * Fix roomserver test * Fix more tests * Further tweaks * Fix current state server test (sort of) * Maybe fix appservices * Fix client API test * Include database connection string in database options * Fix sync API build * Update config test * Fix unit tests * Fix federation sender build * Fix gobind build * Set Listen address for all services in HTTP monolith mode * Validate config, reinstate appservice derived in directory, tweaks * Tweak federation API test * Set MaxOpenConnections/MaxIdleConnections to previous values * Update generate-config
2020-08-10bugfix: when a user's key changes, don't notify everyone on the server (#1253)Kegsay
* bugfix: when a user's key changes, don't notify everyone on the server Instead just notify the users you share a room with. * Update whitelist
2020-07-31Fix edge cases around device lists (#1234)Kegsay
* Fix New users appear in /keys/changes * Create blank device keys when logging in on a new device * Add PerformDeviceUpdate and fix a few bugs - Correct device deletion query on sqlite - Return no keys on /keys/query rather than an empty key * Unbreak sqlite properly * Use a real DB for currentstateserver integration tests * Race fix
2020-07-30Notify clients when devices are deleted (#1233)Kegsay
* Recheck device lists when join/leave events come in * Add PerformDeviceDeletion * Notify clients when devices are deleted * Unbreak things * Remove debug logging
2020-07-28User directory (#1225)Neil Alexander
* User directory * Fix syncapi unit test * Make user directory only show remote users you know about from your joined rooms * Update sytest-whitelist * Review comments
2020-07-22Handle inbound federation E2E key queries/claims (#1215)Kegsay
* Handle inbound /keys/claim and /keys/query requests * Add display names to device key responses * Linting
2020-07-21Use TransactionWriter in other component SQLite (#1209)Neil Alexander
* Use TransactionWriter on other component SQLites * Fix sync API tests * Fix panic in media API * Fix a couple of transactions * Fix wrong query, add some logging output * Add debug logging into StoreEvent * Adjust InsertRoomNID * Update logging
2020-07-15Protect User API SQLite calls with mutexes (#1201)Neil Alexander
* Protect SQLite calls with mutexes (replaces #1200) * Remove locks on reads
2020-07-01Fix Yggdrasil gobind build, set display name at registrationNeil Alexander
2020-06-30Remove membership table from account DB (#1172)Kegsay
* Remove membership table from account DB And make code which needs that data use the currentstate server * Unbreak tests; use a membership enum for space
2020-06-26Implement /sync `limited` and read timeline limit from stored filters (#1168)Kegsay
* Move filter table to syncapi where it is used * Implement /sync `limited` and read timeline limit from stored filters We now fully handle `room.timeline.limit` filters (in-line + stored) and return the right value for `limited` syncs. * Update whitelist * Default to the default timeline limit if it's unset, also strip the extra event correctly * Update whitelist
2020-06-24Hopefully fix databased is locked errors on sqlite account creation (#1162)Kegsay
2020-06-19Fix comment in InputAccountDataRequestNeil Alexander
2020-06-18Refactor account data (#1150)Neil Alexander
* Refactor account data * Tweak database fetching * Tweaks * Restore syncProducer notification * Various tweaks, update tag behaviour * Fix initial sync
2020-06-17Move account/device DBs to userapi (#1141)Kegsay
2020-06-17Make userapi control account creation entirely (#1139)Kegsay
This makes a chokepoint with which we can finally fix 'database is locked' errors on sqlite during account creation
2020-06-16BREAKING: Make eduserver/appservice use userapi (#1138)Kegsay
* BREAKING: Make eduserver/appservice use userapi This is a breaking change because this PR restructures how the AS API tracks its position in Kafka streams. Previously, it used the account DB to store partition offsets. However, this is also being used by `clientapi` for the same purpose, which is bad (each component needs to store offsets independently or else you might lose messages across restarts). This PR changes this behaviour to now store partition offsets in the `appservice` database. This means that: - Upon restart, the `appservice` component will attempt to replay all room events from the beginning of time. - An additional table will be created in the appservice database, which in and of itself is backwards compatible. * Return ErrorConflict
2020-06-16Make syncapi use userapi (#1136)Kegsay
* Make syncapi use userapi * Unbreak things * Fix tests * Lint
2020-06-16Make federationapi use userapi (#1135)Kegsay
Removes dependencies on account DB, device DB and ASAPI.
2020-06-16Make userapi responsible for checking access tokens (#1133)Kegsay
* Make userapi responsible for checking access tokens There's still plenty of dependencies on account/device DBs, but this is a start. This is a breaking change as it adds a required config value `listen.user_api`. * Cleanup * Review comments and test fix
2020-06-15Fix rooms v3 url paths for good - with tests (#1130)Kegsay
* Fix rooms v3 url paths for good - with tests - Add a test rig around `federationapi` to test routing. - Use `JSONVerifier` over `KeyRing` so we can stub things out more easily. - Add `test.NopJSONVerifier` which verifies nothing. - Add `base.BaseMux` which is the original `mux.Router` used to spawn public/internal routers. - Listen on `base.BaseMux` and not the default serve mux as it cleans paths which we don't want. - Factor out `ListenAndServe` to `test.ListenAndServe` and add flag for listening on TLS. * Fix comments * Linting
2020-06-15Add bare bones user API (#1127)Kegsay
* Add bare bones user API with tests! * linting