Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-14] Add at-rest encryption for OAuth2 token #143

Merged
merged 6 commits into from
May 28, 2020

Conversation

larkox
Copy link
Contributor

@larkox larkox commented May 22, 2020

Summary

Add at-rest encryption for OAuth2 token

Ticket Link

Fix #14

@larkox larkox added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels May 22, 2020
@larkox larkox requested review from levb and mickmister May 22, 2020 11:14
@codecov-commenter
Copy link

codecov-commenter commented May 22, 2020

Codecov Report

Merging #143 into master will decrease coverage by 0.01%.
The diff coverage is 22.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #143      +/-   ##
==========================================
- Coverage   24.22%   24.20%   -0.02%     
==========================================
  Files          66       67       +1     
  Lines        2634     2702      +68     
==========================================
+ Hits          638      654      +16     
- Misses       1916     1964      +48     
- Partials       80       84       +4     
Impacted Files Coverage Δ
server/mscalendar/client.go 20.00% <0.00%> (-8.58%) ⬇️
server/mscalendar/user.go 17.00% <0.00%> (-0.18%) ⬇️
server/utils/encryption.go 0.00% <0.00%> (ø)
server/mscalendar/notification.go 52.09% <50.00%> (-0.20%) ⬇️
server/mscalendar/oauth2.go 81.48% <72.72%> (-3.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e4fd89...7c3b1f1. Read the comment docs.

Copy link
Contributor

@mickmister mickmister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@levb levb removed the 2: Dev Review Requires review by a core committer label May 22, 2020
@levb
Copy link
Contributor

levb commented May 22, 2020

Do we really need to QA this one, other than the general Oauth2/use regression?

@larkox
Copy link
Contributor Author

larkox commented May 22, 2020

Use and regression is all I can think about. Proper behavior on upgrade could also be necessary, but since we still do not have any release out, I think it is not necessary.

@larkox larkox requested a review from DHaussermann May 26, 2020 08:36
@DHaussermann
Copy link

DHaussermann commented May 26, 2020

@larkox when I deploy this, I can no longer run connect or disconnect command. Error log shows

{"level":"debug","ts":1590523742.088871,"caller":"web/handlers.go:89","msg":"Received HTTP request","method":"POST","url":"/api/v4/commands/execute","request_id":"bfitqmz44ifkbem5q7tkzai99w"}
{"level":"error","ts":1590523742.0895622,"caller":"mlog/sugar.go:23","msg":"token encryption key not generated","plugin_id":"com.mattermost.mscalendar"}
{"level":"error","ts":1590523742.089841,"caller":"mlog/log.go:175","msg":"Unable to execute command.","path":"/api/v4/commands/execute","request_id":"bfitqmz44ifkbem5q7tkzai99w","ip_addr":"74.15.49.102","user_id":"ri814hfoubngxp8e838raoxxsw","method":"POST","err_where":"mscalendarplugin.ExecuteCommand","http_code":500,"err_details":"token encryption key not generated"}

Please advise on any next steps for investigation.

@DHaussermann
Copy link

@larkox disregard previous comment At Rest Token Encryption Key was missing.
Regarding the testing:

  • Tested disconnect and connect with multiple users.
  • Functional testing found nor regreassions
    However for the test user where I watched the KV store I did not see a change in access_token
    is there a way to validate the current value is properly encrypted?

@larkox
Copy link
Contributor Author

larkox commented May 27, 2020

This should do the trick:
https://play.golang.org/p/67MSocnXQn9
I put there the decryption code. You have to fill the key and the "message to decrypt" and hit run. If it is something that has not been encrypted before, it should not work. Therefore, if what is stored in the KVStore passes the decryption, it should be fine. If you need any more guidance, feel free to ask.

Copy link

@DHaussermann DHaussermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and passed

  • Tested disconnect and connect with multiple users.
  • Functional testing found nor regressions and plugin works as expected when changing encryption key
  • Confirmed access_token is properly encrypted.

@DHaussermann DHaussermann added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels May 27, 2020
@larkox larkox merged commit 0dd13f8 into mattermost:master May 28, 2020
mickmister added a commit that referenced this pull request Jun 1, 2020
mickmister added a commit that referenced this pull request Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add at-rest encryption for OAuth2 token
5 participants