Commit Graph

194 Commits

Author SHA1 Message Date
Eli Yukelzon
480796a1df MM-33708 - Add MentionCountRoot column to ChannelMembers (#17099)
* added new column for root-only mentions

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-04-01 14:43:09 +03:00
Max Erenberg
6a77e24adc MM-28090 User settings api when ldap sync (#16822)
Automatic Merge
2021-03-22 19:02:16 +01:00
Jesús Espino
9cc5089af8 Moving mlog to corelibs (#16915)
* Moving mlog to corelibs

* Regenerating app layers

* Fix golangci-lint problem

* Fixing golangci-lint errors

* Renaming from corelibs to shared

* Renaming from corelibs to shared

* Fixing import

* Fixing merge problems

* Fixing build
2021-03-05 09:18:37 +01:00
Eli Yukelzon
23d51ed1f2 MM-32655 - Collapsed threads websocket handling (#16909)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-03-02 16:49:00 +02:00
Eli Yukelzon
9a33c3706a MM-32525 Incorrect number of mentions for channels when threads are enabled (#16853) 2021-02-09 12:03:32 +02:00
Eli Yukelzon
13616cac0f MM-31711 - Implement cursor paging for threads (#16748)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-31 12:28:14 +02:00
Eli Yukelzon
bb7e5b6e9d MM-31712 Server/API: Unreads-only filter for GetUserThreads (#16660)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-31 11:54:35 +02:00
Eli Yukelzon
77da23e84b MM-31713 Server/API: GetUserThread method (#16659)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-28 18:07:39 +02:00
Madhav Hugar
94c24eea20 Fix empty string comparison issues in the codebase (#16686)
Automatic Merge
2021-01-25 11:15:17 +01:00
Agniva De Sarker
1aae3444c0 MM-32013: Do not allow password change in /auth endpoint (#16770)
We were allowing new password to be reset without asking
for the old password. This was not advertised but was possible nevertheless
through the API.

Since there is already a separate API to change password, we choose to remove
this functionality.

https://mattermost.atlassian.net/browse/MM-32013

```release-note
The /api/v4/users/me/auth API endpoint cannot be used to change password anymore.
This was a hidden feature that was not documented, but was nevertheless possible.
We are just removing the hidden feature.
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-22 09:58:08 +05:30
Agniva De Sarker
dccdc9f6cf MM-31721: Fix Cache-Control directives (#16763)
We were incorrectly setting the cache control to public
when it should be rather private.

https://mattermost.atlassian.net/browse/MM-31721

```release-notes
Fix Cache-Control headers to instruct that responses may only be cached
on browsers.
```
2021-01-21 12:38:49 +01:00
Ibrahim Serdar Acikgoz
f9c0c1072f [MM-31360] downgrade error logs which doesn't break the flow (#16612)
* downgrade error logs which doesn't break the flow

* reflect revivew comments
2021-01-04 17:02:34 +03:00
Agniva De Sarker
c1dd23a3c8 MM-31063: Change constants to use CamelCase (#16608)
* MM-31063: Change constants to use CamelCase

* store package

* change allcaps to camel case (#16615)

* New tools.mod

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2021-01-04 11:32:29 +05:30
Agniva De Sarker
6487d0ca91 MM-31062: Rewrite empty string checks to be more idiomatic (#16587)
https://mattermost.atlassian.net/browse/MM-31062

```release-note
NONE
```
2020-12-22 19:20:59 +05:30
Scott Bishel
f548ecbee1 MM-27688-OpenId Connect (#16222)
* implement openid connect

* update error strings

* handle OpenIdSetting.Secret as FAKE SETTING

* add openid to telemetry

* update config defaults, add telemetry

* fix bug with Office365

* Retrieve Office365 AuthData from IdToken

* fix linter

* add feature flag, reset defaults for config

* fix build error

* fix unit tests

* add authentication permission to Feature
Flags

* turn off feature flag

* set default button color

* set default button color only on openid

* fix for merging FeatureFlags in config

* remove feature flag

* revert config changes

* remove debug statements

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-08 19:58:37 -07:00
Eli Yukelzon
86e228b6c6 MM-30558 - Add unreadReplies and unreadMentions to thread membership (#16304) 2020-12-06 10:02:53 +02:00
Farhan Munshi
c9a4a475d3 [MM-28717] Refactor applyMultiRoleFilters to use sq builder (#15500)
* Refactor apply multi role filters and add role filters to get all profiles

* Add some tests

* Fix tests

* Fix lint

* Trigger CI

* Rename param to make more sense

* Tie get filtered user stats to usermanagement read users

* Dont filter out other system roles when searching for team members or team admins only filter out system admins

* add new permissions

* add migration

* fix test

* remove system roles as default permissions

* implement changes discussed with dennis

* add read only and fix i18n

* use model consts instead of strings

* turn the permissions into pseudo constants

* Update read only default permissions

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Hossein Ahmadian-Yazdi <hyazdi1997@gmail.com>
2020-11-13 10:57:57 -05:00
Eli Yukelzon
45e340b5be MM-29987 Implement new collapsed threads API (#16091) 2020-11-08 10:36:46 +02:00
Joram Wilander
483441cea2 Soft fail on cloud user limit warnings when creating user (#16230) 2020-11-07 11:39:32 -05:00
Nick Misasi
3697f92045 [MM-28363] User Limit Overage Warning Emails (#16053)
* Adding files, commit of UI in good shape

* Translations added, working with activation and deactivation

* Add check for error

* Fix i18n?

* Push without subscription check so Steve and Matt can look at it

* Fix font-weight in chrome

* Fix font-weight on button

* UX fixes

* Fixes for PR

* Add back subscription stuff

* Fix tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-26 13:24:26 -04:00
Claudio Costa
e5e2dbdf1a [MM-29731] Fix panic in saveUserTermsOfService (#16044)
* Fix panic in saveUserTermsOfService

* Remove unneeded initialization
2020-10-21 17:08:33 +02:00
Nick Misasi
90738de75f Add webhook event for when user status changes from activated to deactivated and vice versa (#15990)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-19 10:29:43 -04:00
Farhan Munshi
6766853f8a [MM-28533] [MM-28532] [MM-28531] Fixes several bugs with sysconsole_write_usermanagement (#15559)
* MM-28533 Fix incorrect permission check for reset password

* Allow write users to edit other users, promote and demote guests

* Update ancillary perms for PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_USER

* MM-28532

* Dont allow non sysadmin to update passwords / reset passwords / patch user on sysadmins

* MM-28532: Updates test.

* MM-28533: Merge fix.

* MM-28533: Adds ability for new roles to activate/deactivate non-system-admin users.

Co-authored-by: Martin Kraft <martin@upspin.org>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-07 17:41:46 -06:00
Ibrahim Serdar Acikgoz
e69a2a41ca [MM-28210] sqlstore/user_store: filter deleted users for GetProfilesInChannel (#15390)
* sqlstore/user_store: filter deleted users for GetProfilesInChannel

* allow GetProfilesInChannel use userGetOptions

* sqlstore/user_store: add more test cases

* store/user_store: refine filter
2020-09-16 11:04:17 +03:00
Claudio Costa
9c272f0b20 [MM-26812] Add support for resumable file uploads (#15252)
* Implement AppendFile for FileBackend

* Split test into subtests

* [MM-26812] Add support for resumable file uploads (#15252)

* Implement UploadSession

* Implement UploadSessionStore

* Add error strings

* Implement resumable file uploads

* Add UploadType

* Fix retry layer tests

* Regenerate store layers

* Fix store error handling

* Use base for filename

* Prevent concurrent uploads on the same upload session

* Fix erroneus error string

* Improve error handling

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* Fix translations

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-09-15 21:28:25 +02:00
Mario de Frutos Dieguez
22297a9bf4 [MM-28083] CWS one-time login logic (#15356)
* Cloud token login

This PR adds the capability of activate the cloud token login that
will be used in our Cloud installations to let the customer login
for the first time without using credentials.

* Read CSRF from cookie when is not on the header and we're login with CWS

* Create new CWS login endpoint

- New endpoint created
- We're using the cloud feature from the license instead of the
configuration flag
- Removed the CSRF changes

* Reduce amount of work if cws token is not set

* Removed unused config key

* Now we store the token to detect it was used

If the token is in the token store then we are assuming that the
token was used

* Add tests

* Add i18n strings
2020-09-01 08:50:43 -04:00
Ibrahim Serdar Acikgoz
26cdbd5dba api4/user: fix-failing-ee-tests (#15372)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-09-01 12:25:00 +03:00
Ibrahim Serdar Acikgoz
c30fea5f2d [MM-25645] api4/user: add migrate_auth endpoints (#14966)
* api4/user: add migrate_auth endpoints

* api4/user: reflect review comments

* add translations

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-08-31 14:56:36 +03:00
Gabe Jackson
90ef61f74c Add functionality to update password with password hash (#15343)
* Add functionality to update password with password hash

This can be used to update a user's password with a direct password
hash instead of providing the password in plaintext.

* Use test helper for local mode
2020-08-26 17:28:00 +02:00
Martin Kraft
8354206e5c MM-25543: New Admin Roles (#14960)
* MM-23832: Initial set of changes

* MM-23832: further iteration

* MM-23832: further iteration

* MM-23832: further iteration

* MM-23832: Fixes merge.

* create migration for new Roles

* MM-23832: Renames some roles.

* MM-23832: Adds ability to see logs.

* MM-23832: Removes manage roles from restricted admin.

* MM-23832: Make authentication section read-only for restricted admin.

* MM-23832: Allow restricted admin to purge caches.

* MM-23832: Adds ability to recycle DB connections.

* MM-23832: Adds ability to purge indexes.

* MM-23832: Adds ability to test email and S3 config.

* MM-23832: Adds abilituy to read job status.

* MM-23832: Adds ability to read plugin statuses.

* MM-23832: Renames Restricted Admin to System Manager.

* MM-23832: Adds manage team roles to system_user_manager.

* MM-23832: Updates some permissions.

* MM-23832: Allow get all channels and get moderations.

* MM-23832: Adds some permissions to User Manager.

* MM-23832: Remove write users from user manager.

* MM-23832: Changes permissions for the usermanagement > users sysconsole section.

* MM-23832: Removes read_settings and write_settings permissions. Ensures the usermanagement parent permissions encompass the sub-permissions.

* MM-23832: Updates permissions.

* MM-23832: Changes some permissions checks, adds new permissions to roles.

* MM-23832: Adds ability to update a role.

* MM-23832: Permissions updates.

* MM-23832: Removes write access to plugins for system manager.

* MM-23832: Removes read compliance from new roles.

* MM-23832: Adds mock for new roles creation migration.

* MM-23832: Changes to variadic param.

* MM-23832: Removes some duplication in the permissions model. Renames some permissions constants.

* MM-23832: Updates some migrations.

* MM-23832: Removes some unnecessary constants.

* MM-23832: Changes back to old app method name.

* MM-23832: Fixes incorrect permission check.

* MM-23832: Changes write to read permission check.

* MM-23832: Removes the authentication permission from link/unlink group.

* MM-23832: Enable testing LDAP with read permissions.

* MM-23832: Make testing elasticsearch a read permission.

* MM-23832: Warn metrics are associated to any system console read permissions.

* MM-23832: Updates some permissions checks.

* MM-23832: Removes non-systemconsole permissions from roles.

* MM-23832: Update default permission assignment of sysadmin.

* MM-23832: Fixes incorrect permission check. Removes some unused stuff.

* MM-23832: Update permission to check.

* MM-23832: Switches to struct tags.

* MM-23832: Adds some docs for the permissions tag.

* MM-23832: Removes whitespace.

* MM-23832: Combines system admin restricted access with other acess-control tag.

* MM-23832: Fixes some tests.

* MM-23832: Clarifies docs, does not assume prior permission check in '-' access value case.

* MM-23832: Updates to correct access tag value.

* MM-23832: Adds test of the config settings tag access.

* MM-23832: Undoes whitespace change.

* MM-23832: Removes comment.

* MM-23832: Adds the permissions to the new roles rather than using OR conditions on the permissions checks.

* MM-23832: Removes or condition on permission check.

* MM-23832: Updates mapping.

* MM-23832: Typo fix.

* MM-23832: Adds new 'read_jobs' permission.

* MM-23832: Add read_jobs to all roles with manage_jobs.

* MM-23832: Adds new permission read_other_users_teams.

* MM-23832: Adds read filtering of config.

* MM-23932: Change tag value.

* MM-23832: Fixes some tests. Adds test for read config access tag.

* MM-23832: Adds permissions to list teams.

* MM-23832: Removes the '-' tag value. Adds a new permission read_channel_groups. Updates a permission check.

* MM-23832: Removes unnecessary parent permission for user_management. Fixes permission check change error.

* MM-23832: Removes unused parameter to filter/merge function.

* MM-23832: Renames migration name.

* MM-23832: Fix for godoc.

* MM-23832: Fixes tests.

* MM-23832: Only makes a map once rather than every function call. Doesn't require access tag on config field structs. Reverts one test update and fixes another.

* MM-23832: Removes all of the unnecessary uses of (*App).SessionHasPermissionToAny since removing the user_management parent permission.

* MM-23832: Updates constant type.

* MM-23832: Removes unnecessary comment.

* MM-23832: Renames permissions.

* MM-23832: Fix for permission name changes.

* MM-23832: Adds missing config access tags. Adds some requirec ancillary permissions for write_usermanagement_teams.

* MM-23832: Adds local API endpoint for getting config.

* MM-23832: If tag value is blank or restrict_sys_admin_write then don't do the permission check.

* MM-23832: nil check for strings prior to dereferencing.

* MM-23832: Fix for config display logic.

* MM-23832: Updates godoc.

* MM-23832: Delays the unrestricted check for parity with other permissions checks if the channel id does not exist.

* MM-23832: Removes tautology.

* MM-23832: Re-adds status code check.

* MM-23832: Adds new permission to edit brand image.

* MM-23832: Exports variable for use by mmctl.

* MM-23832: Initialize exported map for use by mmctl.

* MM-23832: Accept deprecated permissions as valid.

* MM-23832: Adds missing permissions to archive a channel.

* MM-23832: Adds missing permissions for managing team.

* MM-23832: Properly filters config values in patch and update API responses.

* MM-23832: Fixes license viewing and writing permissions.

* MM-23832: Require license to assign 'new system roles'.

* MM-23832: Adds translation keys.

* MM-23832: Updates translation order.

* MM-27529: Splits read_channel_groups into read_public_channel_groups and read_private_channel_groups.

* MM-23832: Prevent read-only permissions from editing site url test parameter.

* MM-23832: Prevent read permissions from sniffing ports and elastic password.

* MM-23832: Adds missing permission required for write user management channels.

* MM-23832: Allows new roles to search for channels.

* MM-23832: Adds ability for system_manager to manage jobs.

* MM-23832: Cluster status access by sysconsole permission, not manage_system.

* MM-23832: Adds 'add_user_to_team' permission to sysconsole write usermanagement teams.

* MM-23832: Fixes lint.

* MM-23832: Test fix.

* MM-23832: Test fix.

Co-authored-by: Catalin Tomai <catalin.tomai@mattermost.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-08-21 16:49:31 -04:00
Doug Lauder
7f64199a37 MM-27184 deprecate model.SetExpireInDays (#15165)
Mobile users were having their sessions unexpectedly expired, despite having ServiceSettings.ExtendSessionLengthWithActivity enabled. 

Every time a mobile app is opened it called `/api/v4/sessions/device` which calls attachDeviceId which calls `(*Session)SetExpireInDays`. This code above assumed the expiry should be relative to CreateAt which is incorrect when ExtendSessionLengthWithActivity is enabled. Therefore, every time the mobile app was opened, the maximum expiry was set in memory to CreateAt + session_length, even if the session was extended.

(*Session)SetExpireInDays is now deprecated and replaced with (*App)SetSessionExpireInDays which takes into account the ExtendSessionLengthWithActivity setting.
2020-08-04 16:10:37 -04:00
Ashish Bhate
7602dc0b19 [MM-25647]: ability to permanently delete users (#14944)
Summary:
    Config option to allow permanent user deletion ServiceSettings.EnableAPIUserDeletion
    Expose permanent user deletion through API
    Local mode for delete user for use in mmctl

Ticket Link:
    Server part of https://mattermost.atlassian.net/browse/MM-25647
2020-07-22 17:32:23 +05:30
Ibrahim Serdar Acikgoz
263e5e8945 api4/user: convey redirect link through email verification (#15052) 2020-07-21 17:09:49 +03:00
Ibrahim Serdar Acikgoz
6a4e3293f8 [MM-25648] api4: add user/bot convert endpoints (#14877)
* api4: add user/bot convert endpoints

* api4: add convert user/bot to local mode

* api4: fix linting issues

* api4/bot: reflect review comments

* api4: update convert user endpoint paths

* remove shadow decl

* fix translation problems
2020-07-17 10:00:43 +03:00
Farhan Munshi
c0bfa58ec1 [MM-26574] Add role filters to get users, users search and add getFilteredUserStats endpoint (#14998)
* MM-26574 Add role filters to user search and get

* Add ability to get filtered user stats

Add support for include bots

* Add tests for user count with filters

Add tests

* Apply changes from code review

* Fix guest filtering

* Fix up tests related to guests

* Clean role names

* Trigger CI

* Trigger CI
2020-07-16 12:37:26 -04:00
Rodrigo Villablanca
8b6a5fc5d7 TokenStore migration to return plain errors (#14875)
* TokenStore migration to return plain errors

* Fix translations

* Fix: returned error is ignored and http.StatusBadRequest is always returned

* Fix

* Fix translations

* Suggestions

* Changed from BadRequest to NotFound

* Setting the correct http status

* Changed test to expect 404 status

* Fix error
2020-07-09 12:46:27 +05:30
Jesús Espino
b977017ca7 Extracting email functions into a service (#14802)
* Extracting email functions into a service

* Fixing two shadowing errors

* Address PR review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-07-07 10:03:21 +02:00
Hossein Ahmadian-Yazdi
4c50c7c59b [MM-25780] Fix incorrect session length when logging in through mobile using SSO (#14874)
* Pass device ID

* dont use device id as way of detecting

* fix spelling mistake

* update layers

* fix test

* fix linting

* save schema

* put columns in correct place

* fix linting

* update

* upgrade go change

* use props

* fix stuff

* update session tests

* address PR comments

* address PR comments
2020-06-30 10:34:05 -04:00
Michael Kochell
11bc28b5fb [MM-26532] Support "active" filter on profile search (#14923)
* Support "active" filter on profile search

* Add tests for active user filter
2020-06-29 15:52:46 -04:00
Mario de Frutos Dieguez
4c33b7a35d [MM-25767] Quick switch users search is always falling back to the database (#14762)
* Refactor of getListOfAllowedChannelsForTeam

Also, I've fixed some problematic scenarios:

- The quick search doesn't provide team id so it was always failing
- When the teamId was empty and view restrictions too we always
  return all the channels because if we do "strings.Contains("foo", "")
  it always returns true
- There was a case, in quick search with a guest account, where you
  get an empty result because teamId is not provided

* Error if team id is not passed when searching for the channel

If we search users passing the channel id, we must pass the team id
too so we avoid returning all the channels if we remove the empty
team id restriction we have in the getListOfAllowedChannelsForTeam

There is no known reason to search for a channel but not filtering
using the team id. Even guest accounts belong to a team
2020-06-26 20:37:35 +02:00
Ibrahim Serdar Acikgoz
f7f1f0d268 [MM-23721] api4/user: add verify user by Id endpoint (#14244)
* api4/user: add verify user by id method

* Update api4/user.go

Co-Authored-By: Miguel de la Cruz <miguel@mcrx.me>

* Update model/client4.go

Co-Authored-By: Miguel de la Cruz <miguel@mcrx.me>

* api4/user: reflect review comments

* Update api4/user_test.go

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>

Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-26 16:08:01 +03:00
Farhan Munshi
77bee1d4f1 MM-25263 Add group members to search and get users and create getGroupStats endpoint (#14733)
Add tests for SearchInGroup
2020-06-18 10:22:35 -04:00
Attila Molnar
66597d0fcb Expand Plugin and REST APIs to trigger user typing event (#14331) 2020-06-16 11:41:05 +02:00
Jesús Espino
f5eab1271b Removing all FakeApp usages (#14174)
* Removing some other fake apps

* More FakeApp removed

* Removing entirely FakeApp

* Fixing some tests

* Fixing get Cluster id from get plugin status

* Fixing failing tests

* Fixing tests

* Fixing test initialization for web

* Fixing InitServer for server tests

* Fixing InitServer for server tests

* Reverting go.sum and go.mod

* Removing unneded HTMLTemplates function in App layer

* Moving back some functions to its old place to easy the review

* Moving back some functions to its old place to easy the review

* Using the last struct2interface version

* Generating store layers

* Fixing merge problems

* Addressing PR comments

* Small fix

* Fixing app tests build

* Fixing tests

* fixing tests

* Fix tests

* Fixing tests

* Fixing tests

* Fixing tests

* Moving license to server struct

* Adding some fixes to the test compilation

* Fixing cluster and some jobs initialization

* Fixing some license tests compilation problems

* Fixing recursive cache invalidation

* Regenerating app layers

* Fix test compilation

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-06-12 13:43:50 +02:00
Jesús Espino
224b72c61e MM-24037 Adding getKnowUsers API endpoint (#14332)
* Adding getKnowUsers API endpoint

* Adding i18n strings

* Fixing golint errors

* Adding doc strings

* Remove debug line

* Updating app_iface

* Fixing gofmt
2020-04-28 12:52:43 +02:00
Doug Lauder
6a27ed4a1d MM-22785 audit server CLI (#14144)
Add auditing to server CLI.

Also:
- simplify auditing in API layer
- reduce number of AddMeta calls
- have models serialize themselves
- more consistent field naming
2020-04-08 00:52:30 -04:00
Doug Lauder
4ac0619c90 MM-22273 New auditing system (phase 1) (#13967)
* New auditing API outputting to syslog via TLS

* New config section for specifying remote syslog server IP, port, and cert.

* Legacy audit API retained for access history feature
2020-03-12 15:50:21 -04:00
catalintomai
ed52acd89c MM-18062 - add support for Office365Settings Directory (tenant) Id (#13737)
* MM-18062 add directory id field to O365 settings
2020-02-14 09:55:40 -08:00
Eli Yukelzon
17523fa5d9 MM-21898 - Part 1: Generate and use an interface instead of *A… (#13840)
* Generate and use an interface instead of *App
2020-02-13 13:26:58 +01:00
Shota Gvinepadze
a7854f1b97 [MM-22037] Enable uppercase letters in the email (#13794)
* Enable uppercase letters in the email

* Lowercase email on every input

* Remove invalid test
2020-02-12 08:51:45 -05:00