change Policy.Matches to accept a URL pointer (#5360)

This commit is contained in:
Joe Kralicky 2024-11-07 14:55:44 -05:00 committed by GitHub
parent 9cd5fe4e25
commit 177f789e63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 9 additions and 9 deletions

View file

@ -83,7 +83,7 @@ func TestSignInURL(t *testing.T) {
authenticateURL := MustParseAndValidateURL("https://authenticate.example.com")
redirectURL := MustParseAndValidateURL("https://redirect.example.com")
rawSignInURL, err := SignInURL(k1, k2.PublicKey(), &authenticateURL, &redirectURL, "IDP-1")
rawSignInURL, err := SignInURL(k1, k2.PublicKey(), authenticateURL, redirectURL, "IDP-1")
require.NoError(t, err)
signInURL, err := ParseAndValidateURL(rawSignInURL)
@ -107,7 +107,7 @@ func TestSignOutURL(t *testing.T) {
}).Encode(), nil)
authenticateURL := MustParseAndValidateURL("https://authenticate.example.com")
rawSignOutURL := SignOutURL(r, &authenticateURL, []byte("TEST"))
rawSignOutURL := SignOutURL(r, authenticateURL, []byte("TEST"))
signOutURL, err := ParseAndValidateURL(rawSignOutURL)
require.NoError(t, err)

View file

@ -54,12 +54,12 @@ func ParseAndValidateURL(rawurl string) (*url.URL, error) {
// MustParseAndValidateURL parses the URL via ParseAndValidateURL but panics if there is an error.
// (useful for testing)
func MustParseAndValidateURL(rawURL string) url.URL {
func MustParseAndValidateURL(rawURL string) *url.URL {
u, err := ParseAndValidateURL(rawURL)
if err != nil {
panic(err)
}
return *u
return u
}
// ValidateURL wraps standard library's default url.Parse because
@ -187,6 +187,6 @@ func GetExternalRequest(internalURL, externalURL *url.URL, r *http.Request) *htt
}
// MatchesServerName returnes true if the url's host matches the given server name.
func MatchesServerName(u url.URL, serverName string) bool {
func MatchesServerName(u *url.URL, serverName string) bool {
return certmagic.MatchWildcard(u.Hostname(), serverName)
}