Commit Graph

10736 Commits

Author SHA1 Message Date
Martin Kraft
ca52ca7016 MM-14415: Removes 'CanLeave' field. (#10426) 2019-03-12 08:58:18 -04:00
Jesús Espino
62a94d53f4 MM-14488: Autogenerate mention_keys on creation if mention_keys aren't provided (#10430)
* MM-14488: Autogenerate mention_keys on creation if mention_keys aren't provided

* Fixing test case
2019-03-12 09:29:55 +01:00
Sandeep Sukhani
fdf9c3e218 [MM-10199] Capture of stack traces into Mattermost logs (#10379)
* [MM-10199] Printing stack traces from http handlers panics in mattermost logs

Previously recovery handlers from gorilla mux was used, which was printing stack traces from panics in stderr
Removing it should print stack traces into logger passed to http.Server, which as of now is created from mlog

Refer #10351

* Logging errors from http server at error level instead of info level
Added test for verifying whether panic gets logged in server logger

* Fixed failing test due to tls error

* Closing temp file for panic log before removing and checking errors for closure and removal

* Added regular log line in panic handler for TestPanicLog to check whether it gets logged
2019-03-11 13:02:34 -04:00
Carlos Tadeu Panato Junior
27daa7b45b remove stale bot in favor of mattermod (#10428) 2019-03-11 16:39:22 +01:00
Yusuke Nemoto
1684f240e0 [MM-4819] Add MinimumHashtagLength config (#10248)
#### Summary
Add `MinimumHashtagLength` config

#### Ticket Link
#9156 
https://mattermost.atlassian.net/browse/MM-4819

#### Checklist
N/A
2019-03-11 14:09:50 +01:00
Jesús Espino
86a3bd064b MM-14481: Do not allow to edit or delete in archived channels (#10422)
* MM-14481: Do not allow to edit or delete in archived channels

* Fixing govet

* Adding new tests
2019-03-11 09:26:31 +01:00
Jesse Hallam
9ef8c1e8b1 MM-14439: experimental restrict system admin (#10414)
* api4: break out license and config from system

* app: move some config functions from admin.go to config.go

* add ExperimentalSettings.RestrictSystemAdmin

* forbid various actions to restricted system admin

* update default.json

* fix function names in errors
2019-03-08 13:15:28 -05:00
Jesús Espino
200cfdd4a7 Fixing emojis and webhooks permissions split (#10420) 2019-03-08 11:40:44 +01:00
Yusuke Nemoto
74c2759117 Trigger mentions for keyword including multibyte characters in sentences (#10262) 2019-03-08 15:44:25 +08:00
Carlos Tadeu Panato Junior
c7802d2433 remove reference from jenkins (#10417) 2019-03-07 17:26:11 +01:00
Jesús Espino
84afd47021 Split Emojis and Webhooks permissions (#10239)
* Split Emojis and Webhooks permissions

* Fixing some tests

* Fixing more tests

* Fix more tests

* Fixed review comments

* Fixing review comments
2019-03-07 16:07:09 +01:00
Jesse Hallam
a4e3dfaebc TestDoCommandRequest: fix non-determinism (#10391)
This test would sometimes fail spuriously because the timeout wasn't triggered. Instead, just make the "slow" HTTP server block altogether.
2019-03-07 09:00:00 -05:00
Miguel de la Cruz
04467b8dc9 [MM-13694] Sets a default value for SiteName if empty (#10406) 2019-03-07 11:53:37 +00:00
Jesse Hallam
1e462da2d4 MM-14143 config cleanup final (#10374)
* TestGetLicenseFileFromDisk: avoid using fileutils.FindConfigFile

* config: abstract config-related file access, extend memory store

* simplify config validate to avoid file knowledge

* fix relative file tests

* cluster: fix ConfigChanged event

The old and new configurations were swapped when notifying the enterprise code of configuration changes, creating needless instability in propagating config updates across a cluster.

* config/database: ignore duplicates

* test cleanup

* remove unnecessary Save() in test
2019-03-06 15:06:45 -05:00
Dmytro Chukmasov
3716918c57 [MM-12365] Create CLI command "team rename" (#9764) (#10083)
Allow renaming teams like in `channel rename` command

Example: `team rename myteam newteamname --display_name "My New Team Name`
2019-03-06 18:48:49 +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
Miguel de la Cruz
80e0d01fe5 [MM-14300] Return 400 if a post is created with a child post as root (#10403) 2019-03-05 10:52:33 +00:00
Jesse Hallam
15f8656088 explicitly configure DisableLegacyMFA for TestCheckUserMfa (#10401) 2019-03-04 12:32:55 -05:00
Jesús Espino
43e6e261d6 MM-14357: Remove store call that can provoke dead locks (#10393)
* MM-14357: Remove store call that can provoke dead locks

* Simplify query

* Adding unit test
2019-03-04 17:52:26 +01:00
Jesse Hallam
46a035df79 skip TestUserLoginMFAFlow/WithCorrectMFA as it fails at random (#10390) 2019-03-04 07:38:55 -08: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
Dan Maas
6903980152 Update NOTICE.txt (#10400)
- add new dependency (sqlx)
2019-03-04 14:08:27 +01:00
Lev
3ad901b50b MM-10516: Added support for PostActions in ephemeral posts (#10258)
* Added support for PostActions in ephemeral posts

The general approach is that we take all the metadata that DoPostAction
needs to process client DoPostActionRequests, and store it in a
serialized, encrypted Cookie field, in the PostAction struct.

The client then must send it back, and it is then used to process
PostActions as a fallback top the metadata in the database.

This PR adds a new config setting, `ServiceSettings.ActionCookieSecret`.
In a cluster environment it must be the same for all instances.

- Added type PostActionCookie, and a Cookie string to PostAction.
- Added App.AddActionCookiesToPost.
- Use App.AddActionCookiesToPost in api4.createEphemeralPost,
  App.SendEphemeralPost, App.UpdateEphemeralPost.
- Added App.DoPostActionWithCookie to process incoming requests with
  cookies. For backward compatibility, it prefers the metadata in the
  database; falls back to cookie.
- Added plugin.API.UpdateEphemeralPost and plugin.API.DeleteEphemeralPost.
- Added App.encryptActionCookie/App.decryptActionCookie.

* Style

* Fixed an unfortunate typo, tested with matterpoll

* minor PR feedback

* Fixed uninitialized Context

* Fixed another test failure

* Fixed permission check

* Added api test for DoPostActionWithCookie

* Replaced config.ActionCookieSecret with Server.PostActionCookieSecret

Modeled after AsymetricSigningKey

* style

* Set DeleteAt in DeleteEphemeralPost

* PR feedback

* Removed deadwood comment

* Added EXPERIMENTAL comment to the 2 APIs in question
2019-03-01 10:15:31 -08: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
Carlos Tadeu Panato Junior
6a3fdbd489 update go to 1.12 (#10382)
* update go to 1.12

* update per feedback

* fix test

* revert test changes

* remove zap.AddCallerSkip(1)
2019-03-01 12:55:35 -05:00
Sandeep Sukhani
7f9e1273d7 [MM-12667] Allow including deactivated users in bulk import and export (#10353)
* [MM-12667] Allow including deactivated users in bulk import and export

1. Added `deleteAt` for user type import line
2. Adding deactivated users data in bulk export
3. Importing deactivated users data in bulk import

Added/Updated relevant test cases

* Fixed export of replies to posts by deleted users.
Updated tests for same
2019-03-01 15:50:24 +00:00
Daniel Schalla
7ac5715a02 [MM-14333] Stricten external HTTP Calls to require that own IPs need to be explicitly whitelisted (#10375)
* Stricten external HTTP Calls to require that own IPs need to be explicitly whitelisted

* gofmt

* Documentation; Style fixes for IsOwnIP function
2019-03-01 16:22:24 +01:00
Saturnino Abril
d85dff81a8 skip tutorial steps for sysadmin, user-1 and user-2 from generated sample data (#10387) 2019-03-01 20:11:38 +08:00
Daniel Schalla
a3ee3ac193 [MM-14313] Use LogAudit for Active/Deactive Action (#10357) 2019-02-28 23:30:26 +01:00
Christopher Poile
476a66099f [MM-11142] Console logging should be human readable during developmen… (#10352)
* MM-11142: Console logging should be human readable during dev #10349

* MM-11142: Console logging should be human readable during dev #10349
2019-02-28 11:42:56 -05:00
Christopher Poile
8bd182c38f MM-14145: The config store Set will now Save automatically (#10377)
* MM-14145: The config store Set will now Save automatically

When UpdateConfig (and configStore.Set) is called in admin.go and
config.go, commonStore.Set now takes a store-specific persist function.
It uses that persist function to save the configuration automatically.

Removed: Now callers do not have to call configStore.Save or
app.PersistConfig, and those functions have been removed.

Possible downside: this means a "failed to persist config" error can now
be thrown during a app.UpdateConfig or commonStore.Set call. But
considering application code never really sets a config without saving
it (except in the test cases, which were testing that -- see below), it
seems fine to group these responsibilities.

Also removed: tests for 'set without save'. Since that can not happen
anymore, the tests are not needed.

* Removed Save completely, cleaned up formatting, joined save test with
set tests.

* fixed shadowed variable error
2019-02-28 10:51:42 -05:00
Harrison Healey
06261d32ba MM-14082 Don't print warnings when saving duplicate metadata (#10376)
* MM-14082 Don't print warnings when saving duplicate metadata

* Fix order of arguments passed to assert.Equal
2019-02-28 10:32:52 -05:00
jfrerich
bbfcac84c9 [MM-13721] Fix the etag function GetEtagForProfilesNotInTeam (#10360)
* Initial solution for Draft PR

* Reformat tabs to spaces for readability

* Remove my comments and debugging lines for Core Commiter to see changes
more easily

* Remove all comments and show only code changes

* Match indentation spacing of new query to old query to make diff reading
easier for core committer

* Remove everything except what want to show core commiter

* Restrucure query and resulting etag value.
get number of users not in team from SELECT subquery.
etag return values is now of the form
<model.CurrenVersion>.<UpdateAt>.<number_profiles_not_int_team>

* Remove skipped test for solution to https://mattermost.atlassian.net/browse/MM-13721.
Remove comment for failing description of test
store u4 with prepended "u4".  Similar to u1, u2, u3.  This is easier
for debugging when looking in the database
Added skipped test:
  check that etag does not change when a user, not in team 1, is added
  to different team.  UpdateAt will change, but users in the set does
  not

* Remove skipped test for solution to https://mattermost.atlassian.net/browse/MM-13721.
Remove comment for failing description of test
store u4 with prepended "u4".  Similar to u1, u2, u3.  This is easier
for debugging when looking in the database
Added skipped test:
  check that etag does not change when a user, not in team 1, is added
  to different team.  UpdateAt will change, but users in the set does
  not

* remove commented out tests

* Restructure and simplify the SQL query for GetEtagForProfilesNotInTeam.
- Build the query to get all profiles not in a specified team
- select latest UpdateAt Value by getting Max value from UpdateAt field.
- select Number of profiles not in Team from count of the returned Ids

The previous query required building a complex query with multiple
joins and repeated code in a select subquery, and derived table

* Format SQL styling indentation, spaces around equal signs, and new lines

* Add description for skipped test
2019-02-27 18:51:06 -08:00
Jesse Hallam
4f259970e6 MM-14194: fix subpath csp directive until server restart (#10365)
* MM-14194: fix subpath csp directive until server restart

The SiteURL organically doesn't take effect until server restart, but in v5.8, the required CSP directive would change immediately. If changing from one subpath to another, the webapp would effectively be bricked until a server restart.

Avoid this by determining the CSP directive when the static handler is created.

* simplify access to config
2019-02-27 14:53:53 -05:00
Dean Whillier
df6b8ff768 [MM-13158] Initial attempt at extracting SVG dimensions (#10332)
* initial attempt at extracting svg dimensions

* rafactor SVG dimensions extraction

* pass SVG parsing errors to calling context

* tweaks to svg parsing placement

- also stopped trying to pre/post process SVG’s as images

* add svg parsing tests

* updates for PR change requests

* code review updates

* correct a conditional typo
2019-02-27 14:06:56 -05:00
Miguel de la Cruz
4013e77e3e [MM-13810] Modifies invalid parameter error message for update post and team (#10361) 2019-02-27 14:02:21 +00:00
Jesús Espino
9052d81790 MM-13817: Increase the time limit of tokens existency from 24h to 48h (#10318) 2019-02-27 12:44:46 +01:00
Jesse Hallam
e1ed46605a use hard-coded names for saml certificates (#10341)
This preserves the ability to use custom file names -- required for backwards compatibility -- but forces names upon all newly uploaded certificates, avoiding clashes with other configuration files and skipping the need for file safety checks.
2019-02-26 12:17:49 -05:00
Jesse Hallam
72448d12a9 deprecate timezones.json (#10311) 2019-02-25 12:07:45 -04:00
κουκουλοφόρος
5b24c44e19 Add missing transaction rollbacks for SQL store (#9964)
* Add missing transaction rollbacks for SQL store

* Add `defer transaction.Rollback()` in SQL stores.

* abstract finalizeTransaction
2019-02-23 11:44:52 -08:00
Shobhit Gupta
b4d645f121 [MM-13746] Add GetTeamMembersForUser and GetChannelMembersForUser apis (#10269)
* Add GetTeamMembersForUser and GetChannelMembersForUser apis

* Address comments

* Fix tests

* Fix test

* Fix comment

* Fix minimum server version

* Change to []*model.ChannelMember

* Fix panic, add more tests

* Remove print statement
2019-02-23 11:41:19 -08:00
Daniel Schalla
0e50ec6a35 Use LogAudit instead of LogAuditWithUser for role/auth provider modification (#10312) 2019-02-22 16:20:59 +01:00
Jesse Hallam
7150b9aada einterfaces: simply saml.ConfigureSP error handling (#10306) 2019-02-21 09:51:25 -08:00
Katie Wiersgalla
659af08ee4 Update PRIVACY_POLICY.md (#10287) 2019-02-21 10:30:35 -05:00
Angela Chang
1018ead619 [MM-8421] Fix tiff preview - backend (#10170) 2019-02-21 09:06:59 +01:00
Daniel Schalla
26d3362eca Invalidate password recovery tokens on eMail change (#10302) 2019-02-21 00:48:28 +01:00
Daniel Schalla
ab812207ab [MM-13610] Fix Login Hooks for SAML (#10288)
* Fix Login Hooks for SAML

* Update unit tests

* Delete extra whitespace

Co-Authored-By: DSchalla <daniel@schalla.me>
2019-02-20 18:04:50 +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
Daniel Schalla
1218e774ba Make CSRF Logging less verbose if not enforced (#10279) 2019-02-20 15:21:19 +01:00