-
Notifications
You must be signed in to change notification settings - Fork 330
Description
Thanks for vouch, I was able to get it working with our local, home-grown oauth2 provider, but hit two issues. (Bear with me, I'm new to golang)
Took me a bit to realize that I had to provide one of the listed providers, since there's no default fallback for getUserInfo()
. So, go ahead and use oidc
. This lead to the first, biggest problem, is that our code is oauth2, not OpenID, so vouch
gets through all of the authentication hand-shaking steps, but when going to grab the UserInfo, it falls down on doing the code to token exchange, here:
vouch-proxy/handlers/handlers.go
Line 528 in 5f336c4
ptokens.PIdToken = providerToken.Extra("id_token").(string) |
Since our oauth2 server doesn't sent an id_token (or any Extra, for that matter), this line blows up. As far as I can tell, the PIdToken
is never used elsewhere in vouch-proxy
, so I commented this line out, and make it to the next problem. :-) (BTW, I see value in upgrading our server to provide this JWT token in any case, so this problem may go away, for me. Otherwise, I don't know enough go to test if the providerToken has an Extra member, sorry. )
Also, the error for that one looks almost exactly like what was seen here:
#20 (no real hint where the actual problem is)
The next problem seems to be the usual - everyone's UserInfo is different. In our case, emails are nested inside a contacts hash, we provide no top-level email member in the json. We do however, provide a username at the toplevel. So this code:
vouch-proxy/pkg/structs/structs.go
Lines 27 to 29 in 5f336c4
// PrepareUserData implement PersonalData interface | |
func (u *User) PrepareUserData() { | |
u.Username = u.Email |
stomps on the username. Which caused the attempt to store in the bold db to fail.
For that fix, I just conditionalized it:
// PrepareUserData implement PersonalData interface
func (u *User) PrepareUserData() {
if u.Username == "" {
u.Username = u.Email
}
}
If we decide to use vouch
in production, I think I'll just go ahead and define an openstax
provider, and encapsulate the necessary getUserInfo
changes there.
Just thought I'd share my experience with y'all and get any feedback you might have.