Skip to content

Commit d01808a

Browse files
authored
CLOUDP-280943: remove not used template references to OAuth (#460)
1 parent fcb7a12 commit d01808a

File tree

3 files changed

+0
-90
lines changed

3 files changed

+0
-90
lines changed

admin/client.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,6 @@ func (c *APIClient) prepareRequest(
477477
if ctx != nil {
478478
// add context to the request
479479
localVarRequest = localVarRequest.WithContext(ctx)
480-
481-
// Walk through any authentication.
482-
483480
}
484481

485482
for header, value := range c.cfg.DefaultHeader {

tools/config/go-templates/client.mustache

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ import (
2222
"strings"
2323
"time"
2424

25-
{{#hasOAuthMethods}}
26-
"golang.org/x/oauth2"
27-
{{/hasOAuthMethods}}
2825
{{#withAWSV4Signature}}
2926
awsv4 "github.com/aws/aws-sdk-go/aws/signer/v4"
3027
awscredentials "github.com/aws/aws-sdk-go/aws/credentials"
@@ -363,65 +360,6 @@ func (c *APIClient) prepareRequest(
363360
if ctx != nil {
364361
// add context to the request
365362
localVarRequest = localVarRequest.WithContext(ctx)
366-
367-
// Walk through any authentication.
368-
369-
{{#hasOAuthMethods}}
370-
// OAuth2 authentication
371-
if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok {
372-
// We were able to grab an oauth2 token from the context
373-
var latestToken *oauth2.Token
374-
if latestToken, err = tok.Token(); err != nil {
375-
return nil, err
376-
}
377-
378-
latestToken.SetAuthHeader(localVarRequest)
379-
}
380-
381-
{{/hasOAuthMethods}}
382-
{{#hasHttpBasicMethods}}
383-
// Basic HTTP Authentication
384-
if auth, ok := ctx.Value(ContextBasicAuth).(BasicAuth); ok {
385-
localVarRequest.SetBasicAuth(auth.UserName, auth.Password)
386-
}
387-
388-
{{/hasHttpBasicMethods}}
389-
{{#hasHttpBearerMethods}}
390-
// AccessToken Authentication
391-
if auth, ok := ctx.Value(ContextAccessToken).(string); ok {
392-
localVarRequest.Header.Add("Authorization", "Bearer "+auth)
393-
}
394-
395-
{{/hasHttpBearerMethods}}
396-
{{#withAWSV4Signature}}
397-
// AWS Signature v4 Authentication
398-
if auth, ok := ctx.Value(ContextAWSv4).(AWSv4); ok {
399-
creds := awscredentials.NewStaticCredentials(auth.AccessKey, auth.SecretKey, auth.SessionToken)
400-
signer := awsv4.NewSigner(creds)
401-
var reader *strings.Reader
402-
if body == nil {
403-
reader = strings.NewReader("")
404-
} else {
405-
reader = strings.NewReader(body.String())
406-
}
407-
408-
// Define default values for region and service to maintain backward compatibility
409-
region := auth.Region
410-
if region == "" {
411-
region = "eu-west-2"
412-
}
413-
service := auth.Service
414-
if service == "" {
415-
service = "oapi"
416-
}
417-
418-
timestamp := time.Now()
419-
_, err := signer.Sign(localVarRequest, reader, service, region, timestamp)
420-
if err != nil {
421-
return nil, err
422-
}
423-
}
424-
{{/withAWSV4Signature}}
425363
}
426364
427365
for header, value := range c.cfg.DefaultHeader {

tools/config/go-templates/configuration.mustache

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,6 @@ func (c contextKey) String() string {
1919
}
2020

2121
var (
22-
{{#hasOAuthMethods}}
23-
// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
24-
ContextOAuth2 = contextKey("token")
25-
26-
{{/hasOAuthMethods}}
27-
{{#hasHttpBasicMethods}}
28-
// ContextBasicAuth takes BasicAuth as authentication for the request.
29-
ContextBasicAuth = contextKey("basic")
30-
31-
{{/hasHttpBasicMethods}}
32-
{{#hasHttpBearerMethods}}
33-
// ContextAccessToken takes a string oauth2 access token as authentication for the request.
34-
ContextAccessToken = contextKey("accesstoken")
35-
36-
{{/hasHttpBearerMethods}}
37-
{{#hasApiKeyMethods}}
38-
// ContextAPIKeys takes a string apikey as authentication for the request
39-
ContextAPIKeys = contextKey("apiKeys")
40-
41-
{{/hasApiKeyMethods}}
42-
{{#withAWSV4Signature}}
43-
// ContextAWSv4 takes an Access Key and a Secret Key for signing AWS Signature v4
44-
ContextAWSv4 = contextKey("awsv4")
45-
46-
{{/withAWSV4Signature}}
4722
{{#hasHttpSignatureMethods}}
4823
// ContextHttpSignatureAuth takes HttpSignatureAuth as authentication for the request.
4924
ContextHttpSignatureAuth = contextKey("httpsignature")

0 commit comments

Comments
 (0)