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

Add revokeTokens route to Security Controller #1374

Merged
merged 13 commits into from Aug 8, 2019

Conversation

Yoann-Abbes
Copy link
Contributor

@Yoann-Abbes Yoann-Abbes commented Aug 1, 2019

What does this PR do ?

Add a revokeTokens route to the security controller, with tests and documentation page.

This route allows an administrator to revoke all of a user's tokens.

https://jira.kaliop.net/browse/KZL-507

How should this be manually tested?

unit/functional tests

@alexandrebouthinon alexandrebouthinon changed the title Add revokeTokens rout to Security Controller Add revokeTokens route to Security Controller Aug 1, 2019
@Yoann-Abbes Yoann-Abbes self-assigned this Aug 1, 2019
@Aschen
Copy link
Contributor

Aschen commented Aug 1, 2019

I'm thinking that we could both have revoke all tokens and revoke one token with this route.
User could provide an array of token that need to be revoked to revoke specific token.
If no array if provided, this route revoke all user tokens.

Also maybe this route could be useful in the auth controller to I think, so currently logued users can revoke their tokens

@scottinet scottinet added changelog:new-features Increase the minor version number and removed changelog:enhancements labels Aug 1, 2019
@scottinet
Copy link
Contributor

@Aschen That would mean that an administrator would know what tokens to revoke beforehand and that does not sound practical to me. How do you propose to make that work? 🤔

@Aschen
Copy link
Contributor

Aschen commented Aug 1, 2019

@Aschen That would mean that an administrator would know what tokens to revoke beforehand and that does not sound practical to me. How do you propose to make that work? thinking

I just thinking about and you're right, we would need a security:listToken before

@scottinet
Copy link
Contributor

scottinet commented Aug 1, 2019

@Aschen I'm absolutely and completely against any addition to the API allowing tokens to be leaked to the outside.

@scottinet
Copy link
Contributor

@Aschen > check out JIRA KZL-509, I described how we could let users manage their sessions, without ever leaking tokens. I think this is the way to go, and it would be easy to add API routes in the security controller to allow an administrator to manage another user's sessions.

@codecov
Copy link

codecov bot commented Aug 1, 2019

Codecov Report

Merging #1374 into 1-dev will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##            1-dev    #1374      +/-   ##
==========================================
+ Coverage   93.88%   93.88%   +<.01%     
==========================================
  Files         106      106              
  Lines        7291     7298       +7     
==========================================
+ Hits         6845     6852       +7     
  Misses        446      446
Impacted Files Coverage Δ
lib/config/httpRoutes.js 100% <ø> (ø) ⬆️
lib/api/controllers/securityController.js 98.34% <100%> (+0.03%) ⬆️

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 ff651b3...2797a9a. Read the comment docs.

@codecov
Copy link

codecov bot commented Aug 1, 2019

Codecov Report

Merging #1374 into 1-dev will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##            1-dev    #1374      +/-   ##
==========================================
+ Coverage   93.92%   93.93%   +<.01%     
==========================================
  Files         106      106              
  Lines        7330     7337       +7     
==========================================
+ Hits         6885     6892       +7     
  Misses        445      445
Impacted Files Coverage Δ
lib/config/httpRoutes.js 100% <ø> (ø) ⬆️
lib/api/controllers/securityController.js 98.38% <100%> (+0.03%) ⬆️

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 3a69c80...ce5da7f. Read the comment docs.

@Aschen
Copy link
Contributor

Aschen commented Aug 2, 2019

@Aschen > check out JIRA KZL-509, I described how we could let users manage their sessions, without ever leaking tokens. I think this is the way to go, and it would be easy to add API routes in the security controller to allow an administrator to manage another user's sessions.

Yes you're right, I have been thinking about it and it's not possible to have this kind of route.
Eventually the route could list token by another identifier but we would need to add metadata (like ip adress) to allow users to identify legitimate sessions.

And what do you think about a auth:revokeTokens to allow currently logged user to revoke his token ?

lib/config/httpRoutes.js Outdated Show resolved Hide resolved
lib/api/controllers/securityController.js Outdated Show resolved Hide resolved
features/kuzzle.feature Outdated Show resolved Hide resolved
test/api/controllers/securityController/users.test.js Outdated Show resolved Hide resolved
doc/1/api/controllers/security/revoke-tokens/index.md Outdated Show resolved Hide resolved
doc/1/api/controllers/security/revoke-tokens/index.md Outdated Show resolved Hide resolved
doc/1/api/controllers/security/revoke-tokens/index.md Outdated Show resolved Hide resolved
features/kuzzle.feature Outdated Show resolved Hide resolved
lib/api/controllers/securityController.js Outdated Show resolved Hide resolved
@Yoann-Abbes Yoann-Abbes requested a review from Aschen August 6, 2019 11:10
Copy link
Contributor

@Aschen Aschen left a comment

Choose a reason for hiding this comment

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

I'm blocking this PR as long as #1333 is not merged so this code can use the errorManager

lib/api/controllers/securityController.js Outdated Show resolved Hide resolved
@Yoann-Abbes Yoann-Abbes requested a review from Aschen August 7, 2019 17:03
if (!user) {
errorsManager.throw('user_not_found', userId);
}
return this.kuzzle.repositories.token.deleteByUserId(userId);
Copy link
Contributor

Choose a reason for hiding this comment

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

The documentation indicate that this route return null but here you return the result of deleteByUserId

@Aschen Aschen merged commit a84a659 into 1-dev Aug 8, 2019
@Aschen Aschen deleted the KZL-507-add-revokeTokens-route branch August 8, 2019 08:49
@Aschen Aschen restored the KZL-507-add-revokeTokens-route branch August 8, 2019 08:49
@Aschen Aschen deleted the KZL-507-add-revokeTokens-route branch August 8, 2019 08:49
Yoann-Abbes added a commit that referenced this pull request Aug 20, 2019
Adds a revokeTokens route to the security controller, with tests and documentation page
@Aschen Aschen mentioned this pull request Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:new-features Increase the minor version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants