- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.5k
 
forwardAuth.addHeadersToResponse #6893
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
Conversation
| 
           Looks like tests not related to current changes have failed  | 
    
| 
           Hey hey, thanks for your work on that! We're currently trying to figure out an answer for your question and I think, adding the  Do you have the time to contribute that as well?  | 
    
| 
           Hi @SantoDE thanks for your response! 
 Sure, I would like to! Just need a bit of instructions on best way to implement it 🙂  | 
    
| 
           Any updates @SantoDE @jbdoumenjou ? 🙂  | 
    
| 
           Hi @iamolegga, Thanks for your contribution and sorry for the delay :) After analysis, as the RFC says : 
 To be compliant, the Set-Cookie header received from the authentication server response should only be applied after checking the Set-Cookie header value sent by the backend. The right way to do that would be to use the ModifyResponse mechanism from go. However, there is currently no way to keep track of the headers from the authentication server until the handling of the backend response. This is why, to accept this Pull Request, a technical way to apply the header a posteriori must be found. Unless you have a better technical proposal, we will unfortunately close this PR.  | 
    
| 
           Hi @jbdoumenjou 
 good catch, I didn't see that before, thanks 👍 
 I think that passing set-cookie header from auth service is expected behaviour, if we set it, right?  | 
    
| 
           As I said before, without a technical proposal compatible with the RFC, we are forced to close this PR.  | 
    
| 
           Why closing this PR? My proposition is totally compliant with RFC @jbdoumenjou  | 
    
| 
           @jbdoumenjou why are you closing pr that is still in progress, what's the reason? Please read again my previous messages, I just wanted to know if described behaviour could be merged, then I could change this pr to technical proposal compatible with the RFC  | 
    
| 
           Hi @iamolegga, The team has discussed your proposal to determine if it is compliant with RFC and it appears that it is not. For example, if you copy the header  
 As mentioned by @jbdoumenjou, to implement said functionality would require logic to handle the auth header being copied only if the backend response does not contain a  As there is no technical proposal compatible with the RFC we were forced to close this PR. If you have ideas on how to implement this without breaking the RFC, we would welcome the discussion in the aforementioned issue that relates to this PR. It is also possible to implement this functionality in custom middleware plugin where it isn't necessarily required to be compliant with the RFC specifications. If you'd like to learn more about how to build such a plugin, please reference the plugindemo repository. If you have any additional questions or comments, feel free to respond here or in the aforementioned issue.  | 
    
| 
           Hello @notsureifkevin Sorry, but I didn't get it, are we discussing now only  My original question was about concatinating header values from both auth and backend (of course we must exclude   | 
    
| 
           @notsureifkevin please check this lines  | 
    
| 
           @iamolegga according to the team, the response would include multiple   | 
    
| 
           @notsureifkevin um, but tests pass 😐  | 
    
| 
           Hello, If you swap the lines L81 and L82 in your integration test, you will see that it is not working: This is related to the fact that in your implementation, only the first value of  If you replace your implementation by the following code (which copies all the values of a header), you will see that your test (without any modification) will not work: for _, headerName := range fa.addHeadersToResponse {
	for _, v := range forwardResponse.Header.Values(headerName) {
		rw.Header().Add(headerName, v)
	}
}So in this case, it cannot be compliant with the RFC. Thanks anyway.  | 
    
What does this PR do?
closes #3660
Motivation
described in #3660
More
Additional Notes
Before reviewing this please read this comment in related issue for understanding desired behaviour.
This PR CAN be merged, it does pass headers from
forwardAuthservice to response, but if backend has the same header, it overwrites values of the first one (Set-Cookiesheaders will be set from both services if have differentnames, if both responses have sameSet-Cookie'snamevalue from backend will be set).Desired behaviour from my point of view is when values of headers from both services will be concatenated (through
Add). So my question is to someone from the core team: what is the best way to deal with it? Or we can merge it now as it is, but implementing desired behaviour in next iteration will be breaking changeThanks 🙂