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

Feature/impersonate #119

Closed
wants to merge 1 commit into from
Closed

Conversation

Skeen
Copy link
Contributor

@Skeen Skeen commented May 1, 2022

This PR introduces impersonation, a functionality for admins to impersonate other users.

image

@Skeen Skeen force-pushed the feature/impersonate branch from 6725dde to f5225b0 Compare May 1, 2022 20:00
@jmattheis
Copy link
Member

What's the use case for this? Please create a ticket to discuss the feature before you open a PR.

@Skeen
Copy link
Contributor Author

Skeen commented May 2, 2022

What's the use case for this? Please create a ticket to discuss the feature before you open a PR.

Hi,

I'm building an integration between Traggo and Redmine to synchronize timespan entries for all users from Traggo to Redmine.
Thus I need to be able to query all timespans for a all users.

I considered the following solutions:

  • Having each user create a never expiring device and submitting it to the synchronizer software.

I would like to avoid this solution, as it would require each users to put in effort to get the integration working for them.

  • Expanding the GraphQL interface for querying Timespan, such that a user-id can be provided by admins and query results will be filtered for that user.

This solution just seemed dirty in comparison to the chosen solution, as the current solution with impersonation seemed cleaner and more general.

I'm very open to alternative ideas to solve this issue, but impersonation did not seem like a bad idea, as it is a feature offered by many IAM systems.

@jmattheis
Copy link
Member

Okay, I kinda dislike the added device for the user, and that the cookie of the current user will be overridden by this. How about we add a special header like X-Traggo-Impersonate. Inside auth/middleware.go in registerUser it could look like this: (untested)

impersonate := request.Header.Get("X-Traggo-Impersonate")
if user.Admin && impersonate != "" {
    if userID, err := strconv.Atoi(impersonate); err == nil {
        impersonateUser := &model.User{}
        if !db.Find(user, userID).RecordNotFound() {
            user = impersonateUser
        }
    }
}

It also would be cool if a impersonating user X banner would be displayed at the top inside the UI.

@Skeen Skeen mentioned this pull request May 15, 2022
@Skeen Skeen closed this May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants