From c6e711cd85b9ee706285074106ada2b1cb3a6d38 Mon Sep 17 00:00:00 2001 From: Trong Huu Nguyen Date: Tue, 28 Jul 2026 09:04:42 +0200 Subject: [PATCH] refactor: drop redundant embedded field selectors Satisfies staticcheck QF1008. --- pkg/cookie/cookie.go | 6 +++--- pkg/mock/client.go | 22 +++++++++++----------- pkg/openid/tokens.go | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/cookie/cookie.go b/pkg/cookie/cookie.go index 55c2774..728f82b 100644 --- a/pkg/cookie/cookie.go +++ b/pkg/cookie/cookie.go @@ -29,14 +29,14 @@ type Cookie struct { } func (in *Cookie) Encrypt(crypter crypto.Crypter) (*Cookie, error) { - plaintext := []byte(in.Cookie.Value) + plaintext := []byte(in.Value) ciphertext, err := crypter.Encrypt(plaintext) if err != nil { - return nil, fmt.Errorf("unable to encrypt cookie '%s': %w", in.Cookie.Name, err) + return nil, fmt.Errorf("unable to encrypt cookie '%s': %w", in.Name, err) } value := base64.RawURLEncoding.EncodeToString(ciphertext) - in.Cookie.Value = value + in.Value = value return in, nil } diff --git a/pkg/mock/client.go b/pkg/mock/client.go index c0a1699..bc74259 100644 --- a/pkg/mock/client.go +++ b/pkg/mock/client.go @@ -17,7 +17,7 @@ type TestClientConfiguration struct { var _ openidconfig.Client = (*TestClientConfiguration)(nil) func (c *TestClientConfiguration) ACRValues() string { - return c.Config.OpenID.ACRValues + return c.OpenID.ACRValues } func (c *TestClientConfiguration) Audiences() map[string]bool { @@ -29,7 +29,7 @@ func (c *TestClientConfiguration) AuthMethod() openidconfig.AuthMethod { } func (c *TestClientConfiguration) ClientID() string { - return c.Config.OpenID.ClientID + return c.OpenID.ClientID } func (c *TestClientConfiguration) ClientJWK() jwk.Key { @@ -37,39 +37,39 @@ func (c *TestClientConfiguration) ClientJWK() jwk.Key { } func (c *TestClientConfiguration) ClientSecret() string { - return c.Config.OpenID.ClientSecret + return c.OpenID.ClientSecret } func (c *TestClientConfiguration) DomainHint() string { - return c.Config.OpenID.DomainHint + return c.OpenID.DomainHint } func (c *TestClientConfiguration) NewClientAuthJWTType() bool { - return c.Config.OpenID.NewClientAuthJWTType + return c.OpenID.NewClientAuthJWTType } func (c *TestClientConfiguration) SetPostLogoutRedirectURI(uri string) { - c.Config.OpenID.PostLogoutRedirectURI = uri + c.OpenID.PostLogoutRedirectURI = uri } func (c *TestClientConfiguration) PostLogoutRedirectURI() string { - return c.Config.OpenID.PostLogoutRedirectURI + return c.OpenID.PostLogoutRedirectURI } func (c *TestClientConfiguration) ResourceIndicator() string { - return c.Config.OpenID.ResourceIndicator + return c.OpenID.ResourceIndicator } func (c *TestClientConfiguration) Scopes() scopes.Scopes { - return scopes.DefaultScopes().WithAdditional(c.Config.OpenID.Scopes...) + return scopes.DefaultScopes().WithAdditional(c.OpenID.Scopes...) } func (c *TestClientConfiguration) UILocales() string { - return c.Config.OpenID.UILocales + return c.OpenID.UILocales } func (c *TestClientConfiguration) WellKnownURL() string { - return c.Config.OpenID.WellKnownURL + return c.OpenID.WellKnownURL } func clientConfiguration(cfg *config.Config) *TestClientConfiguration { diff --git a/pkg/openid/tokens.go b/pkg/openid/tokens.go index 43b5073..d0e7789 100644 --- a/pkg/openid/tokens.go +++ b/pkg/openid/tokens.go @@ -212,7 +212,7 @@ func (in *IDToken) Claim(claim string) (any, error) { } var gotClaim any - if err := in.Token.Get(claim, &gotClaim); err != nil { + if err := in.Get(claim, &gotClaim); err != nil { return nil, fmt.Errorf("missing required '%s' claim in id_token: %w", claim, err) }