-
-
Notifications
You must be signed in to change notification settings - Fork 303
feat: supporter user role #3248
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
Open
Anty0
wants to merge
29
commits into
main
Choose a base branch
from
jirikuchynka/supporter-role
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
add5452
feat: supporter user role
Anty0 15c5f85
feat: implemented read only tokens and impersonation actor support
Anty0 65ed5a6
feat: handle read only distinction in interceptors
Anty0 2e55e3d
chore: fix lint
Anty0 08695b5
feat: implement supporter role on FE side + fixes;
Anty0 5c16726
fix: add missing permission to the hierarchy
Anty0 fed70dd
fix: tests for new interceptors
Anty0 737810f
fix: make sure override annotations won't be ignored
Anty0 0a748d3
fix: updated tests for existing interceptors + fixes and readability …
Anty0 f82763c
fix: separate message for read only denied requests + don't filter pr…
Anty0 7bf1562
fix: log rejected requests by read only interceptor + better feature …
Anty0 24a97a0
fix: move all read only mode checks to read only interceptor and igno…
Anty0 8afd570
fix: document if operation is read only or not in openapi
Anty0 62e5284
fix: setup proper read only rules for existing controllers
Anty0 4cbb9bc
fix: better handling of extended permissions for supporter
Anty0 d17a67e
chore: document `emitTokenRefreshForCurrentUser` behavior
Anty0 33ddbec
fix: make sure actor can impersonate when validating token; doc impro…
Anty0 e12649e
fix: store actor id explicitly as string
Anty0 15bf3f8
chore: update JwtServiceTest
Anty0 195c772
fix: use precalculated list of read only scopes
Anty0 ed09083
chore: fix interceptor docstrings
Anty0 523b1eb
fix: update schema
Anty0 67c782c
chore: fix missing field in read only interceptor test
Anty0 29ecf07
chore: fix project and organization interceptors to follow updated in…
Anty0 d651140
fix: code readability improvements
Anty0 9ba48c2
fix: code readability improvements
Anty0 c58cac8
fix: build
Anty0 1f3db23
fix: allow bypassing `checkLanguagePermissionByTag` and merge view pe…
Anty0 2eb7aa3
fix: use UserAccountDto instead of full entity
Anty0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package io.tolgee.api.v2.controllers | |
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import io.tolgee.constants.Message | ||
import io.tolgee.dtos.cacheable.isAdmin | ||
import io.tolgee.dtos.queryResults.organization.OrganizationView | ||
import io.tolgee.exceptions.BadRequestException | ||
import io.tolgee.hateoas.organization.OrganizationModel | ||
|
@@ -147,7 +148,18 @@ class AdministrationController( | |
fun generateUserToken( | ||
@PathVariable userId: Long, | ||
): String { | ||
val user = userAccountService.get(userId) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @JanCizmar Is there a reason to use the full |
||
return jwtService.emitToken(user.id, true) | ||
val isAlreadyImpersonating = authenticationFacade.actingUser != null | ||
if (isAlreadyImpersonating) { | ||
// We don't want to recreate the Inception movie here | ||
throw BadRequestException(Message.ALREADY_IMPERSONATING_USER) | ||
} | ||
|
||
val actingUser = authenticationFacade.authenticatedUser | ||
val user = userAccountService.getDto(userId) | ||
if (user.isAdmin() && !actingUser.isAdmin()) { | ||
// We don't allow impersonation of admin by supporters | ||
throw BadRequestException(Message.IMPERSONATION_OF_ADMIN_BY_SUPPORTER_NOT_ALLOWED) | ||
} | ||
return jwtService.emitImpersonationToken(user.id) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
backend/api/src/main/kotlin/io/tolgee/hateoas/auth/AuthInfoModel.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.tolgee.hateoas.auth | ||
|
||
import org.springframework.hateoas.RepresentationModel | ||
|
||
class AuthInfoModel( | ||
val isReadOnly: Boolean | ||
) : RepresentationModel<AuthInfoModel>() |
18 changes: 18 additions & 0 deletions
18
backend/api/src/main/kotlin/io/tolgee/hateoas/auth/AuthInfoModelAssembler.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.tolgee.hateoas.auth | ||
|
||
import io.tolgee.api.v2.controllers.InitialDataController | ||
import io.tolgee.security.authentication.TolgeeAuthentication | ||
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AuthInfoModelAssembler : RepresentationModelAssemblerSupport<TolgeeAuthentication, AuthInfoModel>( | ||
InitialDataController::class.java, | ||
AuthInfoModel::class.java, | ||
) { | ||
override fun toModel(entity: TolgeeAuthentication): AuthInfoModel { | ||
return AuthInfoModel( | ||
isReadOnly = entity.isReadOnly, | ||
) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.