use MD5 hash to get reliable 16-byte key (#404)

This commit is contained in:
Michael Quigley
2023-09-28 14:39:31 -04:00
parent 27fcf98fbd
commit 483c599c93
4 changed files with 42 additions and 8 deletions

View File

@ -1,7 +1,9 @@
package publicProxy
import (
"crypto/md5"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@ -27,7 +29,7 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
providerCfg := cfg.GetProvider("github")
if providerCfg == nil {
logrus.Info("unable to find provider config for github. Skipping.")
logrus.Info("unable to find provider config for github; skipping")
return nil
}
clientID := providerCfg.ClientId
@ -42,7 +44,15 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
Endpoint: githubOAuth.Endpoint,
}
key := []byte(cfg.HashKeyRaw)
hash := md5.New()
n, err := hash.Write([]byte(cfg.HashKeyRaw))
if err != nil {
return err
}
if n != len(cfg.HashKeyRaw) {
return errors.New("short hash")
}
key := hash.Sum(nil)
u, err := url.Parse(redirectUrl)
if err != nil {