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

AppendPath parameter #476

Merged
merged 3 commits into from
Feb 9, 2022
Merged

Conversation

samutamm
Copy link
Contributor

@samutamm samutamm commented Jan 25, 2022

As consequence of #472, it's now possible to have following custom-data:

rebuild: true
list:
 - key: bob-bananas
   username: bob
   extra-field: ...

 - key: bob-pearls
   username: bob
   extra-field: ...

and following configuration for HeaderLookup:

name: headerLookup
kind: HeaderLookup
headerKey: "X-AUTH-USER"
etcdPrefix: "credentials/"
headerSetters:
  - etcdKey: "extra-field"
    headerKey: "user-extra-field"

that aims to retrieve the extra-field of the authenticated user. However if the authenticated user is bob (= value of X-AUTH-USER header is bob), bob cannot retrieve data entries bob-bananas and bob-pearls.

This PR aims to solve this by introducing pathRegExp parameter that extracts specified part of the path and appends it to the custom-data key, when retrieving data. Let's change the configuration of the HeaderLookup to

name: headerLookup
kind: HeaderLookup
headerKey: "X-AUTH-USER"
etcdPrefix: "credentials/"
pathRegExp: "^/(.+)" # add this line
headerSetters:
  - etcdKey: "extra-field"
    headerKey: "user-extra-field"

Now when header("X-AUTH-USER") = "bob" and request path = /bananas, the HeaderLookup retrieves the custom-data entry bob-bananas.

@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2022

Codecov Report

Merging #476 (04316af) into main (3c21251) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #476      +/-   ##
==========================================
+ Coverage   80.29%   80.33%   +0.03%     
==========================================
  Files          83       83              
  Lines        9676     9685       +9     
==========================================
+ Hits         7769     7780      +11     
+ Misses       1464     1463       -1     
+ Partials      443      442       -1     
Impacted Files Coverage Δ
pkg/filter/headerlookup/headerlookup.go 88.81% <100.00%> (+5.22%) ⬆️
pkg/filter/validator/basicauth.go 78.89% <0.00%> (-1.84%) ⬇️

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 3c21251...04316af. Read the comment docs.

@samutamm samutamm merged commit d14d7fe into easegress-io:main Feb 9, 2022
@samutamm samutamm deleted the headerlookup-append-path branch February 9, 2022 10:37
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.

4 participants