Skip to content

Commit bf8ab79

Browse files
committed
Adjust authentication method names and function names in the authentication package
1 parent 028c38e commit bf8ab79

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

authenticationhandler/auth_bearer_token.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"go.uber.org/zap"
1515
)
1616

17-
// ObtainToken fetches and sets an authentication token using the stored basic authentication credentials.
18-
func (h *AuthTokenHandler) ObtainToken(apiHandler apihandler.APIHandler, httpClient *http.Client, username string, password string) error {
17+
// BasicAuthTokenAcquisition fetches and sets an authentication token using the stored basic authentication credentials.
18+
func (h *AuthTokenHandler) BasicAuthTokenAcquisition(apiHandler apihandler.APIHandler, httpClient *http.Client, username string, password string) error {
1919

2020
// Use the APIHandler's method to get the bearer token endpoint
2121
bearerTokenEndpoint := apiHandler.GetBearerTokenEndpoint()
@@ -60,8 +60,8 @@ func (h *AuthTokenHandler) ObtainToken(apiHandler apihandler.APIHandler, httpCli
6060
return nil
6161
}
6262

63-
// RefreshToken refreshes the current authentication token.
64-
func (h *AuthTokenHandler) RefreshToken(apiHandler apihandler.APIHandler, httpClient *http.Client) error {
63+
// RefreshBearerToken refreshes the current authentication token.
64+
func (h *AuthTokenHandler) RefreshBearerToken(apiHandler apihandler.APIHandler, httpClient *http.Client) error {
6565
h.tokenLock.Lock()
6666
defer h.tokenLock.Unlock()
6767

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ type OAuthResponse struct {
3030
Error string `json:"error,omitempty"` // Error contains details if an error occurs during the token acquisition process.
3131
}
3232

33-
// ObtainOAuthToken fetches an OAuth access token using the provided client ID and client secret.
33+
// OAuth2TokenAcquisition fetches an OAuth access token using the provided client ID and client secret.
3434
// It updates the AuthTokenHandler's Token and Expires fields with the obtained values.
35-
func (h *AuthTokenHandler) ObtainOAuthToken(apiHandler apihandler.APIHandler, httpClient *http.Client, clientID, clientSecret string) error {
35+
func (h *AuthTokenHandler) OAuth2TokenAcquisition(apiHandler apihandler.APIHandler, httpClient *http.Client, clientID, clientSecret string) error {
3636
// Get the OAuth token endpoint from the APIHandler
3737
oauthTokenEndpoint := apiHandler.GetOAuthTokenEndpoint()
3838

authenticationhandler/auth_token_management.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ func (h *AuthTokenHandler) ValidAuthTokenCheck(apiHandler apihandler.APIHandler,
1616
if h.Token == "" {
1717
h.Logger.Debug("No token found, attempting to obtain a new one")
1818
var err error
19-
if h.AuthMethod == "bearer" {
19+
if h.AuthMethod == "basicauth" {
2020
h.Logger.Info("Credential Match", zap.String("AuthMethod", h.AuthMethod))
21-
err = h.ObtainToken(apiHandler, httpClient, clientCredentials.Username, clientCredentials.Password)
22-
} else if h.AuthMethod == "oauth" {
21+
err = h.BasicAuthTokenAcquisition(apiHandler, httpClient, clientCredentials.Username, clientCredentials.Password)
22+
} else if h.AuthMethod == "oauth2" {
2323
h.Logger.Info("Credential Match", zap.String("AuthMethod", h.AuthMethod))
24-
err = h.ObtainOAuthToken(apiHandler, httpClient, clientCredentials.ClientID, clientCredentials.ClientSecret)
24+
err = h.OAuth2TokenAcquisition(apiHandler, httpClient, clientCredentials.ClientID, clientCredentials.ClientSecret)
2525
} else {
2626
return false, h.Logger.Error("No valid credentials provided. Unable to obtain a token", zap.String("AuthMethod", h.AuthMethod))
2727
}
@@ -34,9 +34,9 @@ func (h *AuthTokenHandler) ValidAuthTokenCheck(apiHandler apihandler.APIHandler,
3434
if time.Until(h.Expires) < tokenRefreshBufferPeriod {
3535
var err error
3636
if clientCredentials.Username != "" && clientCredentials.Password != "" {
37-
err = h.RefreshToken(apiHandler, httpClient)
37+
err = h.RefreshBearerToken(apiHandler, httpClient)
3838
} else if clientCredentials.ClientID != "" && clientCredentials.ClientSecret != "" {
39-
err = h.ObtainOAuthToken(apiHandler, httpClient, clientCredentials.ClientID, clientCredentials.ClientSecret)
39+
err = h.OAuth2TokenAcquisition(apiHandler, httpClient, clientCredentials.ClientID, clientCredentials.ClientSecret)
4040
} else {
4141
return false, h.Logger.Error("Unknown auth method", zap.String("authMethod", h.AuthMethod))
4242
}

httpclient/auth_method.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func DetermineAuthMethod(authConfig AuthConfig) (string, error) {
3131
validClientSecret, clientSecretErrMsg = authenticationhandler.IsValidClientSecret(authConfig.ClientSecret)
3232
// If both ClientID and ClientSecret are valid, use OAuth
3333
if validClientID && validClientSecret {
34-
return "oauth", nil
34+
return "oauth2", nil
3535
}
3636
}
3737

@@ -41,7 +41,7 @@ func DetermineAuthMethod(authConfig AuthConfig) (string, error) {
4141
validPassword, passwordErrMsg = authenticationhandler.IsValidPassword(authConfig.Password)
4242
// If both Username and Password are valid, use Bearer
4343
if validUsername && validPassword {
44-
return "bearer", nil
44+
return "basicauth", nil
4545
}
4646
}
4747

0 commit comments

Comments
 (0)