Hack federation resolver so TLS check passes (#7)

As per comment. I don't yet know what the right way of doing this is.
This commit is contained in:
David Baker
2023-07-11 18:28:04 +01:00
committed by GitHub
parent 9fe823ce49
commit 4c5632add4

View File

@@ -22,6 +22,7 @@ import (
"log"
"net/http"
"os"
"strings"
"time"
@@ -70,10 +71,15 @@ func exchangeOIDCToken(
return nil, errors.New("No results returned from server name resolution!")
}
// XXX: Remove trailing :443 from the hostname, otherwise the TLS cert will fail to verify
// because it will include the port number. This clearly is not the right way of doing this
// but right now I don't know what is.
hackHostName := spec.ServerName(strings.TrimSuffix(string(resolveResults[0].Host), ":443"))
client := fclient.NewClient()
// validate the openid token by getting the user's ID
userinfo, err := client.LookupUserInfo(
ctx, resolveResults[0].Host, token.AccessToken,
ctx, hackHostName, token.AccessToken,
)
if err != nil {
log.Printf("Failed to look up user info: %v", err)