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

fix: Add middleware earlier #1775 #1776

Merged
merged 4 commits into from
Sep 23, 2021
Merged

Conversation

abador
Copy link
Contributor

@abador abador commented Sep 22, 2021

Related issue(s)

#1775

Checklist

Further Comments

No docs and tests, itonly changes the order of middlewares

@abador abador changed the title Fix: Add middleware earlier #1775 fix: Add middleware earlier #1775 Sep 22, 2021
Comment on lines 82 to 84
n.Use(reqlog.NewMiddlewareFromLogger(l, "public#"+c.SelfPublicURL(nil).String()))
n.Use(sqa(ctx, cmd, r))
n.Use(r.PrometheusManager())
Copy link
Member

Choose a reason for hiding this comment

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

Please move this after the for loop below

Comment on lines 141 to 143
n.Use(reqlog.NewMiddlewareFromLogger(l, "admin#"+c.SelfPublicURL(nil).String()))
n.Use(sqa(ctx, cmd, r))
n.Use(r.PrometheusManager())
Copy link
Member

Choose a reason for hiding this comment

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

Please move this after the for loop below

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Actually, I don't think that this is really solving the issue you described. The only thing this does is that the negroni middleware is executed before cleanpath and the csrf middleware!

@abador
Copy link
Contributor Author

abador commented Sep 22, 2021

Actually, I don't think that this is really solving the issue you described. The only thing this does is that the negroni middleware is executed before cleanpath and the csrf middleware!

Yeah this also looked a bit weird to me. This shouldn't make much difference, but it does, since the CSRFHandler is based on the router

@aeneasr
Copy link
Member

aeneasr commented Sep 22, 2021

Oh I see, that makes sense! :)

for _, mw := range modifiers.mwf {
n.UseFunc(mw)
}
n.Use(r.PrometheusManager())
Copy link
Member

Choose a reason for hiding this comment

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

I meant to say to move all n.Use after the modifiers :) The modifiers are used only for testing, and it is important for them to execute before all other middleware. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad :) Done

@codecov
Copy link

codecov bot commented Sep 22, 2021

Codecov Report

Merging #1776 (417e2c9) into master (5b456b3) will increase coverage by 0.02%.
The diff coverage is 73.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1776      +/-   ##
==========================================
+ Coverage   74.10%   74.13%   +0.02%     
==========================================
  Files         260      260              
  Lines       12715    12733      +18     
==========================================
+ Hits         9423     9439      +16     
- Misses       2667     2668       +1     
- Partials      625      626       +1     
Impacted Files Coverage Δ
selfservice/strategy/link/strategy_recovery.go 67.92% <69.23%> (+0.91%) ⬆️
cmd/daemon/serve.go 83.33% <100.00%> (ø)
persistence/sql/persister_courier.go 88.33% <0.00%> (+3.33%) ⬆️

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 131e62e...417e2c9. Read the comment docs.

@CLAassistant
Copy link

CLAassistant commented Sep 23, 2021

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

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

Awesome, thank you! 🎉 Your contribution makes Ory better :)

@aeneasr aeneasr merged commit b9d253e into ory:master Sep 23, 2021
harnash pushed a commit to Wikia/kratos that referenced this pull request Sep 29, 2021
Closes ory#1775

Co-authored-by: Michał Turek <raucously@gmail.com>
harnash pushed a commit to Wikia/kratos that referenced this pull request Oct 5, 2021
Closes ory#1775

Co-authored-by: Michał Turek <raucously@gmail.com>
harnash pushed a commit to Wikia/kratos that referenced this pull request Oct 21, 2021
Closes ory#1775

Co-authored-by: Michał Turek <raucously@gmail.com>
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.

None yet

4 participants