Commit Graph

162 Commits

Author SHA1 Message Date
Agniva De Sarker
2a28edcd93 MM-21481: Fixed several issues from user marshalling (#13627)
* MM-21481: Fixed several issues from user marshalling

- Fixed the root cause for panic by properly converting
the map to a User struct.
- Added a check for type conversion for extra safety.
- Fixed a somewhat unrelated issue of a pointer to pointer reference.

* Fix tests
2020-01-16 09:18:08 +01:00
catalintomai
37ce413b7d MM-20698: Add server support for getting SAML metadata and updating S… (#13311)
* MM-20698: Add server support for getting SAMl metadata and updating SAMl settings
2020-01-09 21:25:20 -08:00
Claudio Costa
80dd2915db [MM-19914] Fix data races in WebSocketEvent (#13039)
* Make WebSocketEvent type immutable

* Update code to use updated immutable WebSocketEvent type

* Export WebSocketEvent fields and mark them as deprecated
2019-12-24 09:32:11 +01:00
Jesús Espino
b3e49ec45c Use require/assert.Empty instead of require/assert.Len(t, X, 0) (#13413) 2019-12-22 12:35:31 +01:00
Jesús Espino
a63684fcb5 Consistent license message for all the go files (#13235)
* Consistent license message for all the go files

* Fixing the last set of unconsistencies with the license headers

* Addressing PR review comments

* Fixing busy.go and busy_test.go license header
2019-11-29 12:59:40 +01:00
Claudio Costa
eeec08c071 [MM-19979] Stop sending new_user websocket event to guests (#13191)
* Stop sending new_user websocket event to guests

* Remove debug msg

* Revert go.mod/go.sum

* Fix linting issues
2019-11-28 14:24:04 +00:00
Miguel de la Cruz
2259b7f2a8 [MM-19948] Set version on module file and internal paths (#13186)
* [MM-19948] Set version on module file and internal paths

* Fixes after merge

* Fix i18n checker error
2019-11-28 14:39:38 +01:00
Jesús Espino
7031f51b41 Deactivating and invalidating sessions of guest users on guest disable (#13007)
Automatic Merge
2019-11-15 09:43:52 -05:00
Vinício Augusto
10e1fa4382 Migrate tests from "api4/user_test.go" to use testify (#12967)
* testify in api4/user_test.go

* more semantic treatments for require.Nil

* fix err shadowing

* gofmt

* trying to pass require.NoError problems

* trying to pass more require.NoError problems
2019-11-15 09:13:32 -05:00
Scott Bishel
e07e114def don't clear AuthService/AuthData if user is System Admin (#12986) 2019-11-07 12:12:37 -07:00
Ben Schumacher
7a665aacdd Run gosimple against codebase (#12928) 2019-10-29 07:45:09 +01:00
Agniva De Sarker
20ff7032a6 Fixed some ineffective assignments (#12543) 2019-10-03 15:45:27 +03:00
Jesús Espino
ecbc5ef5e1 Fixing autocomplete endpoint for in/out of channels (#12147) 2019-09-18 20:27:32 +02:00
Daniel Schalla
a92c830e57 Add additional input validation for user creation (#11937) 2019-08-27 10:39:01 +02:00
Micah Thompson
903085feb8 Migrate "User.UpdateMfaActive" to Sync by default (#11566) 2019-07-10 14:55:17 -04:00
Marc Argent
b55b9a3d97 GH-11465 Migrate User.UpdateMfaSecret to Sync by default (#11496)
* GH-11465 Migrate User.UpdateMfaSecret to Sync by default

* GH-11465 make mfa call async

* GH-11465 return *model.AppError directly
2019-07-02 16:22:24 -04:00
Guillermo Vayá
b664291f21 [Mm-7854] [Backend] Add an endpoint to revoke sessions from all users (#11200)
* first steps towards revoke all sessions endpoint

* route added

* change permission into a more restrictive one

* fix url

* add store code

* testing & mocking

* fixing what merge broke

* remove sessions without retrieving them

* flush sessions from cache

* stop going through sessions to revoke caches, not needed anymore

* add test, fix func name

* fix tests

* remove unneeded code

* [MM-7854]remove access tokens, move to users

* fix docstring

* [MM-7854] improve readability by using require

* [MM-7854] fix tests

* [MM-7854]fix comment

* [MM-7854]improve testing logic
2019-07-01 22:28:46 +01:00
Harrison Healey
4b96437370 MM-16477 Add api to get users modified since a given time (#11406)
* MM-16477 Add api to get users modified since a given time

* Address feedback
2019-06-27 09:37:03 -04:00
krjn
72d482de0e [MM-16512] Migrate Token.Save to Sync by default (#11353)
* [MM-16512] Migrate Token.Save to Sync by default

* refactor: formatting

* test: add checks for errors while saving tokens

* test: fixup
2019-06-26 16:06:41 +05:30
Jesús Espino
6df57d7a83 Migrate User Store methods related to enterprise to sync by default (#11332) 2019-06-26 10:41:45 +02:00
Miguel de la Cruz
9e9b008f3d [MM-13500] Adds channel /search_group endpoint (#10805)
* [MM-13500] Adds channel /search_group endpoint

* Add LIMIT to the queries

* Fix i18n extract

* Fix tests

* Add a new endpoint to get profiles by group channel ids

* Rebase fix
2019-06-22 00:14:21 +01:00
krjn
604e247135 [MM-16514] Migrate Token.GetByName to Sync by Default (#11355)
* [MM-16514] Migrate Token.GetByToken to Sync by default

* test: use testify

* fix: shadowing
2019-06-22 00:20:27 +02:00
Christopher Speller
1ca421472f Fix bots being unable to post when personal access tokens are disabled. (#11105) 2019-06-13 11:54:09 -07:00
Jesús Espino
76bab4f0c2 Migrating User Store VerifyEmail, GetByAuth and GetByEmail functions to sync by default (#10941) 2019-06-12 19:30:50 +02:00
Daniel Schalla
f49a0881bf Display Lockout Error to User (#11135) 2019-06-12 18:35:53 +02:00
Harrison Healey
803ce61ef8 MM-15889 Add unit tests for CSRF checks (#11058)
* MM-15889 Add unit tests for CSRF checks

* Moved CSRF token test to login tests

* Remove empty test

* Remove debug messages
2019-06-11 15:09:00 -04:00
Daniel Schalla
79fb20bc1a [MM-15767] Mask errors in login flow only explicitly (#11051)
* Explicit list of errors that should be masked for login flow

* Fix unit test

* fix test #2

* Use of whitelist of passed through errors; Rework error messages
2019-06-10 23:25:25 +02:00
Martin Kraft
c8646eae51 MM-15947: Prevents new user creation with invite link to group-constrained team. (#11023) 2019-06-03 12:38:33 -04:00
Daniel Schalla
f3801d7db5 Dont expose any information about the user status on login failure (#10925) 2019-05-28 11:26:02 -07:00
Andres Orozco
88005fbf54 MM-15662: Rename "CreateBotAccounts" config.json setting to "EnableBotAccountCreation" (#10875)
* MM-15662 change conflig flag to EnableBotAccountCreation

* undo changes to i18n

* MM-15662: Change config flag for bot creation

adds newline to i18n

* MM-15662 Update diagnostics.go to use new config flag
2019-05-23 13:03:22 -07:00
Andres Orozco
30061df036 MM-14723: Add config flag for creating bots (#10795)
* MM-14723 add config flag for creating bots

* MM-14723 - update i18n to handle new config flag

* MM-14723 - change API tests to allow bots by default

* Update i18n/en.json

Co-Authored-By: andresoro <ao15@my.fsu.edu>

* MM-14723: add config flag for enabling/disabling bot creation

* undo changes to apitestlib.go to explicitly change config in each test

* add unit tests for config changes

* MM-14723 update test cases

* MM-14723 update test cases to use UpdateConfig method
2019-05-13 07:48:32 -07:00
d28park
4552c20d5b [MM-12958] Support running two Mattermost instances on the same domain using subpaths (#10493) 2019-05-03 22:52:32 +02:00
Jesús Espino
c8920588a0 Adding new "VIEW_MEMBERS" permissions restrict the scope of users visibility (#10487)
* MM-14138: Adding new "VIEW_MEMBERS" permissions restrict the scope of users visibility

* Fixing gofmt

* Fixing broken tests

* Addressing PR review comments from Miguel de la Cruz

* Removed hack

* A bit nicer and cleaner code in the UserBelongsToChannels function

* Adding cluster cache invalidation for user team ids

* Checking in the correct order permissions to not leek existency information

* Adding restrictions to TeamMembers and User status requests

* Fixing tests

* Fixing status endpoint permissions checks

* Adding more tests

* Fixing tests

* More tests and making the restrictions query based only on joins

* Adding more tests

* Adding more tests

* fixing merge problems

* Reverting status changes to avoid performance issues

* Adding more tests

* Fixing test

* i18n extract

* Adding extra method for get restrictions for a team

* Add the new elasticsearch functions to search users with restrictions

* Add missing translation string

* Rename restrictedChannelIds to restrictedToChannels

* Remove ToDo

* Adding the permission to the SystemAdmin role during permissions migrations
2019-04-29 16:56:56 +02:00
Daniel Schalla
f7982216e4 [MM-13671] Rework Team InviteId Creation and Updates (#10536)
* Add regenerate invite ID endpoint; Dont allow inviteID updates via other methods; Remove unrequired checks in get handler

* Fix tests; Dont accept TeamId as invite ID

* Ensure all teams have an InviteID set

* Custom Selector to get empty teams; dont crash when inviteid set fails

* Remote InviteId from TeamPatch

* Add missing translation

* Translation string order

* Use sync store

* gofmt
2019-04-25 23:09:38 +02:00
Miguel de la Cruz
83a0e965d3 [MM-15126] Adding terms of service to the login response (#10625) 2019-04-16 17:59:07 +01:00
Daniel Schalla
957ec1388b [MM-14381] Fix brittle MFA Login Successful Test (#10565)
* Fix brittle MFA Login Successful Test

* Fix 2FA Conversion issue

Co-Authored-By: DSchalla <daniel@schalla.me>

* Unify naming
2019-04-15 18:40:14 +02:00
Harshil Sharma
f84be43937 Returned User TermsOfService Data in Certain GetUser APIs To Be Used on Webapp for Decicion Making (#10478)
* Used user TOS data embedded in user object itself

* #MI-372 Added user TOS data in getUserByUsername API and updated tests

* #MI-372 returned user TOS data only for admin or self

* #MI-372 fixed tests

* #MI-372 added user ID checks in a missing place
2019-03-27 14:01:35 +01:00
Christopher Speller
06b579d18a MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)

* bots model, store and api

Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119

* uncomment tests incorrectly commented, and fix merge issues

* add etags support

* add missing licenses

* remove unused sqlbuilder.go (for now...)

* rejig permissions

* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS

* conform to general rest api pattern

* eliminate redundant http.StatusOK

* Update api4/bot.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* s/model.UserFromBotModel/model.UserFromBot/g

* Update model/bot.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* Update model/client4.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* move sessionHasPermissionToManageBot to app/authorization.go

* use api.ApiSessionRequired for createBot

* introduce BOT_DESCRIPTION_MAX_RUNES constant

* MM-13512 Prevent getting a user by email based on privacy settings (#10021)

* MM-13512 Prevent getting a user by email based on privacy settings

* Add additional config settings to tests

* upgrade db to 5.7 (#10019)

* MM-13526 Add validation when setting a user's Locale field (#10022)

* Fix typos (#10024)

* Fixing first user being created with system admin privilages without being explicity specified. (#10014)

* Revert "Support for Embeded chat (#9129)" (#10017)

This reverts commit 3fcecd521a.

* s/DisableBot/UpdateBotActive

* add permissions on upgrade

* Update NOTICE.txt (#10054)

- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates

* avoid leaking bot knowledge without permission

* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)

* 6798 added a new api to get the bulk reactions for posts

* 6798 added the permsission check before getting the reactions

* GH-6798 added a new app function for the new endpoint

* 6798 added a store method to get reactions for multiple posts

* 6798 connected the app function with the new store function

* 6798 fixed the review comments

* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)

Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023

* Trigger Login Hooks with OAuth (#10061)

* make BotStore.GetAll deterministic even on duplicate CreateAt

* fix spurious TestMuteCommandSpecificChannel test failure

See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw

* fix race in TestExportUserChannels

* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway

* MM-13117: bot tokens (#10111)

* eliminate redundant Client/AdminClient declarations

* harden TestUpdateChannelScheme to API failures

* eliminate unnecessary config restoration

* minor cleanup

* make TestGenerateMfaSecret config dependency explicit

* TestCreateUserAccessToken for bots

* TestGetUserAccessToken* for bots

* leverage SessionHasPermissionToUserOrBot for user token APIs

* Test(Revoke|Disable|Enable)UserAccessToken

* make EnableUserAccessTokens explicit, so as to not rely on local config.json

* uncomment TestResetPassword, but still skip

* mark assert(Invalid)Token as helper

* fix whitespace issues

* fix mangled comments

* MM-13116: bot plugin api (#10113)

* MM-13117: expose bot API to plugins

This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.

* gofmt issues

* expunge use of BotList in plugin/client API

* introduce model.BotGetOptions

* use botUserId term for clarity

* MM-13129 Adding functionality to deal with orphaned bots (#10238)

* Add way to list orphaned bots.

* Add /assign route to modify ownership of bot accounts.

* Apply suggestions from code review

Co-Authored-By: crspeller <crspeller@gmail.com>

* MM-13120: add IsBot field to returned user objects (#10103)

* MM-13104: forbid bot login (#10251)

* MM-13104: disallow bot login

* fix shadowing

* MM-13136 Disable user bots when user is disabled. (#10293)

* Disable user bots when user is disabled.

* Grammer.

Co-Authored-By: crspeller <crspeller@gmail.com>

* Fixing bot branch for test changes.

* Don't use external dependancies in bot plugin tests.

* Rename bot CreatorId to OwnerId

* Adding ability to re-enable bots

* Fixing IsBot to not attempt to be saved to DB.

* Adding diagnostics and licencing counting for bot accounts.

* Modifying gorp to allow reading of '-' fields.

* Removing unnessisary nil values from UserCountOptions.

* Changing comment to GoDoc format

* Improving user count SQL

* Some improvments from feedback.

* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
Jesse Hallam
15f8656088 explicitly configure DisableLegacyMFA for TestCheckUserMfa (#10401) 2019-03-04 12:32:55 -05:00
Jesse Hallam
55103b0a78 fix vettool; run vet on all available packages (#10389)
#### Summary
Unfortunately, `which shadow` didn't resolve to the shadow binary, so hard-code the expected path in `$GOPATH/bin`. At the same time, run `go vet` across both the server and enterprise (if present), reducing the number of required invocations.

This is accompanied by an enterprise change to fix shadowing issues there.

#### Ticket Link
N/A (tooling upgrade)

#### Checklist
- [x] Has enterprise changes: https://github.com/mattermost/enterprise/pull/403
2019-03-04 15:27:59 +01:00
Daniel Schalla
dcf611b735 [MM-14081] Disable checkMFA Endpoint by default and add tests for MFA login (#10356) 2019-03-01 18:56:11 +01:00
Daniel Schalla
166ab15f38 Check whether self-deactivation is enabled in delete handler (#10300) 2019-02-20 16:56:26 +01:00
Daniel Schalla
f046163a12 [MM-13840] Change eMail as a post-verification action (#10253)
* Change eMail as a post-verification action

* Fix broken test

* comment for special behavior, tests

* govet

* Check for already existent eMails when require email verification is turned on before accepting update
2019-02-20 15:50:52 +01:00
Christopher Speller
9cfcab2307 MM-14039 Improving password lockout functionality. (#10254)
* Improving password lockout functionality.

* Switching order of mfa password checks to passowrd -> mfa
2019-02-12 07:56:41 -08:00
Daniel Schalla
85c60f1402 [MM-13839] Check for password when updating the eMail (#10207)
* Check for password when updating the eMail

* Require password for email change

* Enhance unit testing

* Restructure error handling for update email path

* govet
2019-02-01 19:06:49 -04:00
Daniel Schalla
7cc66ee1d4 [MM-10346] CSRF Token Implementation + Tests (#10067)
* CSRF Token Implementation + Tests

Remove debug statements

Implement requested changes

* Fix non-cookie authentication methods stripping auth data from requests

* Fail when CSRF cookie is not returned as part of login
2019-01-31 20:39:02 +01:00
Joram Wilander
2ca222033c MM-10658 Change config fields to pointers (#9033)
* MM 10658 Change config fields to pointers (#8898)

* Change fields of config structs to pointers and set defaults

MM-10658 https://github.com/mattermost/mattermost-server/issues/8841

* Fix tests that go broken during switching config structs to pointers

MM-10658 https://github.com/mattermost/mattermost-server/issues/8841

* Apply changes of current master while switching config structs to pointers

MM-10658 https://github.com/mattermost/mattermost-server/issues/8841

* Fix new config pointer uses

* Fix app tests

* Fix mail test

* remove debugging statement

* fix TestUpdateConfig

* assign config consistently

* initialize AmazonS3Region in TestS3TestConnection

* initialize fields for TestEmailTest

* fix TestCheckMandatoryS3Fields
2019-01-31 08:12:01 -05:00
Jesse Hallam
8af05aa43a Unit test fixes (#10117)
* eliminate redundant Client/AdminClient declarations

* harden TestUpdateChannelScheme to API failures

* eliminate unnecessary config restoration

* minor cleanup

* make TestGenerateMfaSecret config dependency explicit

* Update api4/user_test.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* Update api4/user_test.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* fix fix for TestUpdateChannelScheme...
2019-01-24 12:19:32 -08:00
Harrison Healey
f639c7c617 MM-13512 Prevent getting a user by email based on privacy settings (#10021)
* MM-13512 Prevent getting a user by email based on privacy settings

* Add additional config settings to tests
2018-12-18 16:04:25 -05:00
Christopher Speller
ef4e37fb6b Fix update user auth. (#10013) 2018-12-17 15:04:30 -05:00