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

Added impersonate header #120

Merged
merged 1 commit into from
May 18, 2022
Merged

Conversation

Skeen
Copy link
Contributor

@Skeen Skeen commented May 15, 2022

This PR introduces impersonation via a HTTP Header as suggested on #119.
This allows admins to impersonate other users, fetching their data, etc.

Currently this is a backend only implementation to support integrations.

@codecov
Copy link

codecov bot commented May 15, 2022

Codecov Report

Merging #120 (d6d9d23) into master (d08d03d) will increase coverage by 0.13%.
The diff coverage is 95.45%.

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
+ Coverage   92.61%   92.74%   +0.13%     
==========================================
  Files          70       70              
  Lines        1530     1558      +28     
==========================================
+ Hits         1417     1445      +28     
  Misses         79       79              
  Partials       34       34              
Impacted Files Coverage Δ
auth/middleware.go 98.13% <95.45%> (+0.66%) ⬆️

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 d08d03d...d6d9d23. Read the comment docs.

@@ -51,33 +52,55 @@ func sessionCallbacks(request *http.Request, writer http.ResponseWriter) *http.R
}

func reqisterUser(request *http.Request, writer http.ResponseWriter, db *gorm.DB) *http.Request {
Copy link
Member

Choose a reason for hiding this comment

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

Hey, the code looks fine, could you add some tests in auth/middleware_test.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some HTTP status-code returns and a few tests.

@Skeen Skeen force-pushed the feature/impersonate_lite branch from 4d11888 to 2554636 Compare May 18, 2022 15:05
Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

Looks good, I fixed the formatting via go fmt.

@jmattheis jmattheis merged commit bba7f60 into traggo:master May 18, 2022
@Skeen Skeen deleted the feature/impersonate_lite branch May 18, 2022 19:06
if err != nil {
msg := "Issue fetching token"
log.Info().Msg(msg)
http.Error(writer, msg, 400)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is problematic @jmattheis.

I'm seeing output like this (on http://localhost:3030/):

Issue fetching token
<!doctype html><html lang="en"><head><meta charset="utf-8"/>...</head><body>...</body></html>

Do you see the same issue on your end?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, fixed in the last commit.

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