Skip to content

Commit 3c2ab91

Browse files
committedNov 22, 2024·
Make the authorizer and registry authorizer configurable
Fixes: #12584 This change makes the authorizer and registryAuthorizer of the registry client configurable via options. This allows Go SDK users to override the authentication behavior of the client. This PR makes both the authorizer and registryAuthorizer configurable because depending on the exact scenario that may be needed. The default registryAuthorizer only supports a specific implementation of the authorizer. Signed-off-by: Ryan Nowak <nowakra@gmail.com>

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎pkg/registry/client.go

+20
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ func ClientOptWriter(out io.Writer) ClientOption {
175175
}
176176
}
177177

178+
// ClientOptAuthorizer returns a function that sets the authorizer setting on a client options set. This
179+
// can be used to override the default authorization mechanism.
180+
//
181+
// Depending on the use-case you may need to set both ClientOptAuthorizer and ClientOptRegistryAuthorizer.
182+
func ClientOptAuthorizer(authorizer auth.Client) ClientOption {
183+
return func(client *Client) {
184+
client.authorizer = authorizer
185+
}
186+
}
187+
188+
// ClientOptRegistryAuthorizer returns a function that sets the registry authorizer setting on a client options set. This
189+
// can be used to override the default authorization mechanism.
190+
//
191+
// Depending on the use-case you may need to set both ClientOptAuthorizer and ClientOptRegistryAuthorizer.
192+
func ClientOptRegistryAuthorizer(registryAuthorizer *registryauth.Client) ClientOption {
193+
return func(client *Client) {
194+
client.registryAuthorizer = registryAuthorizer
195+
}
196+
}
197+
178198
// ClientOptCredentialsFile returns a function that sets the credentialsFile setting on a client options set
179199
func ClientOptCredentialsFile(credentialsFile string) ClientOption {
180200
return func(client *Client) {

0 commit comments

Comments
 (0)
Please sign in to comment.