mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-16 16:26:16 +02:00
linter pass; remove context param from GetIdentityProviderForRequestURL
This commit is contained in:
parent
a5a0cf4ba8
commit
f3288974dd
5 changed files with 8 additions and 10 deletions
|
@ -1,7 +1,6 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
|
@ -58,7 +57,7 @@ func (o *Options) GetIdentityProviderForPolicy(policy *Policy) (*identity.Provid
|
|||
}
|
||||
|
||||
// GetIdentityProviderForRequestURL gets the identity provider associated with the given request URL.
|
||||
func (o *Options) GetIdentityProviderForRequestURL(ctx context.Context, requestURL string) (*identity.Provider, error) {
|
||||
func (o *Options) GetIdentityProviderForRequestURL(requestURL string) (*identity.Provider, error) {
|
||||
u, err := urlutil.ParseAndValidateURL(requestURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -109,7 +108,7 @@ func NewPolicyCache(options *Options) (*PolicyCache, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (pc *PolicyCache) GetIdentityProviderForRequestURL(ctx context.Context, o *Options, requestURL string) (*identity.Provider, error) {
|
||||
func (pc *PolicyCache) GetIdentityProviderForRequestURL(o *Options, requestURL string) (*identity.Provider, error) {
|
||||
u, err := urlutil.ParseAndValidateURL(requestURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package config_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
@ -40,7 +39,7 @@ func BenchmarkGetIdentityProviderForRequestURL_Old(b *testing.B) {
|
|||
|
||||
b.ResetTimer()
|
||||
for range b.N {
|
||||
idp, err := options.GetIdentityProviderForRequestURL(context.Background(), fmt.Sprintf(urlFormat, numPolicies-1))
|
||||
idp, err := options.GetIdentityProviderForRequestURL(fmt.Sprintf(urlFormat, numPolicies-1))
|
||||
require.NoError(b, err)
|
||||
require.Equal(b, fmt.Sprintf("client_id_%d", numPolicies-1), idp.ClientId)
|
||||
require.Equal(b, fmt.Sprintf("client_secret_%d", numPolicies-1), idp.ClientSecret)
|
||||
|
@ -85,8 +84,8 @@ var bench = func(fill func(i int, p *config.Policy) string, numPolicies int) fun
|
|||
for i := range b.N {
|
||||
// replace all *s in the url with a number, which is valid for both
|
||||
// hostname segments and ports.
|
||||
reqUrl := strings.ReplaceAll(allUrls[i%numPolicies], "*", fmt.Sprint(i))
|
||||
idp, err := cache.GetIdentityProviderForRequestURL(context.Background(), options, reqUrl)
|
||||
reqURL := strings.ReplaceAll(allUrls[i%numPolicies], "*", fmt.Sprint(i))
|
||||
idp, err := cache.GetIdentityProviderForRequestURL(options, reqURL)
|
||||
require.NoError(b, err)
|
||||
require.Equal(b, fmt.Sprintf("client_id_%d", i%numPolicies), idp.ClientId)
|
||||
require.Equal(b, fmt.Sprintf("client_secret_%d", i%numPolicies), idp.ClientSecret)
|
||||
|
|
|
@ -82,7 +82,7 @@ func (store *SessionStore) LoadSessionState(ctx context.Context, r *http.Request
|
|||
|
||||
// confirm that the identity provider id matches the state
|
||||
if state.IdentityProviderID != "" {
|
||||
idp, err := store.policyCache.GetIdentityProviderForRequestURL(ctx, store.options, urlutil.GetAbsoluteURL(r).String())
|
||||
idp, err := store.policyCache.GetIdentityProviderForRequestURL(store.options, urlutil.GetAbsoluteURL(r).String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ func getCookies(r *http.Request, name string) []*http.Cookie {
|
|||
}
|
||||
|
||||
// LoadSession returns a State from the cookie in the request.
|
||||
func (cs *Store) LoadSession(ctx context.Context, r *http.Request) (string, error) {
|
||||
func (cs *Store) LoadSession(_ context.Context, r *http.Request) (string, error) {
|
||||
opts := cs.getOptions()
|
||||
cookies := getCookies(r, opts.Name)
|
||||
if len(cookies) == 0 {
|
||||
|
|
|
@ -113,7 +113,7 @@ func (p *Proxy) ProgrammaticLogin(w http.ResponseWriter, r *http.Request) error
|
|||
return httputil.NewError(http.StatusBadRequest, errors.New("invalid redirect uri"))
|
||||
}
|
||||
|
||||
idp, err := p.policyCache.Load().GetIdentityProviderForRequestURL(r.Context(), options, urlutil.GetAbsoluteURL(r).String())
|
||||
idp, err := p.policyCache.Load().GetIdentityProviderForRequestURL(options, urlutil.GetAbsoluteURL(r).String())
|
||||
if err != nil {
|
||||
return httputil.NewError(http.StatusInternalServerError, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue