bitly / oauth2_proxy

A reverse proxy that provides authentication with Google, Github or other provider
MIT License
5.1k stars 1.21k forks source link

Allow providers to set session User and Email #229

Open raphink opened 8 years ago

raphink commented 8 years ago

Currently, Oauth2_proxy computers session User from session Email (as the left part of the email string).

It would be better to have providers provide that information, to have a correct X-Forwarded-User value.

raphink commented 8 years ago

Use case: in gogs, the field can be used to automatically create users. Passing usernames makes more sense than passing emails for that need.

hexedpackets commented 8 years ago

This would also be very useful for GitHub, where the user's primary email can often be meaningless to the upstream service (especially if they have a dozen emails on their account like I do), but the username is a useful identifier.

ekristen commented 7 years ago

+1, what can we do to get this added? Thanks!

h4wkmoon commented 7 years ago

Hi, I'm not a go dev, but my guess is that the issue is here

func (s *SessionState) userOrEmail() string {
    u := s.User
    if s.Email != "" {
        u = s.Email
    }
    return u
}

As you can see, if the user has an email (which happens all the time), the email overrides the username. My proposal would be to, either:

As I said, I don't know golang. How I can I compile and test the changes I could make ? (Code is already cloned on my laptop)