Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Mar 13, 2023
1 parent 48fdb62 commit f71b0c5
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 60 deletions.
6 changes: 1 addition & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ linters-settings:
capital: true
goimports:
local-prefixes: "github.com/auth0/go-auth0"
revive:
rules:
- name: package-comments
severity: warning
disabled: true

issues:
exclude-use-default: false
exclude:
- "Error return value of `response.Body.Close` is not checked"
- "Error return value of `w.Write` is not checked"
- "G307: Deferring unsafe method \"Close\" on type \"io.ReadCloser\""
- "should have a package comment"
exclude-rules:
- path: "(.+)_test.go"
linters:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $(GO_BIN)/govulncheck:

lint: $(GO_BIN)/golangci-lint ## Run linting on the go files
@echo "==> Running linting on the library with golangci-lint..."
@golangci-lint run -v --fix -c .golangci.yaml ./...
@golangci-lint run -v --fix -c .golangci.yml ./...

check-vuln: $(GO_BIN)/govulncheck ## Check for vulnerabilities
@echo "==> Checking for vulnerabilities..."
Expand Down
9 changes: 4 additions & 5 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package client

import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"log"
"net/http"
Expand All @@ -15,9 +17,6 @@ import (
"golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"

"encoding/base64"
"encoding/json"

"github.com/auth0/go-auth0"
)

Expand Down Expand Up @@ -104,12 +103,12 @@ func Auth0ClientInfoTransport(base http.RoundTripper, auth0ClientInfo *Auth0Clie
base = http.DefaultTransport
}

auth0ClientJson, err := json.Marshal(auth0ClientInfo)
auth0ClientJSON, err := json.Marshal(auth0ClientInfo)
if err != nil {
return nil, err
}

auth0ClientEncoded := base64.StdEncoding.EncodeToString(auth0ClientJson)
auth0ClientEncoded := base64.StdEncoding.EncodeToString(auth0ClientJSON)

return RoundTripFunc(func(req *http.Request) (*http.Response, error) {
req.Header.Set("Auth0-Client", auth0ClientEncoded)
Expand Down
8 changes: 4 additions & 4 deletions management/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,11 @@ type ConnectionOptionsADFS struct {
// ConnectionOptionsPingFederate is used to configure a Ping Federate Connection.
type ConnectionOptionsPingFederate struct {
// SigningCert should be used when creating or updating the public key for the Ping Federate server, it will not be
// present when reading a connection and instead you should use the Cert field to check the value.
// present when reading a connection, and instead you should use the Cert field to check the value.
SigningCert *string `json:"signingCert,omitempty"`

// Cert should only be used when reading the connection. It should not be set on creation or update of a connection, instead
// SigningCert should be used to update the public key for the Ping Federate server.
// Cert should only be used when reading the connection. It should not be set on creation or update of a connection,
// instead SigningCert should be used to update the public key for the Ping Federate server.
Cert *string `json:"cert,omitempty"`

LogoURL *string `json:"icon_url,omitempty"`
Expand All @@ -965,7 +965,7 @@ type ConnectionOptionsPingFederate struct {
DigestAlgorithm *string `json:"digestAlgorithm,omitempty"`
SignSAMLRequest *bool `json:"signSAMLRequest,omitempty"`
SignatureAlgorithm *string `json:"signatureAlgorithm,omitempty"`
PingFederateBaseUrl *string `json:"pingFederateBaseUrl,omitempty"`
PingFederateBaseURL *string `json:"pingFederateBaseUrl,omitempty"`
NonPersistentAttrs *[]string `json:"non_persistent_attrs,omitempty"`
UpstreamParams map[string]interface{} `json:"upstream_params,omitempty"`
SetUserAttributes *string `json:"set_user_root_attributes,omitempty"`
Expand Down
2 changes: 1 addition & 1 deletion management/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ ZsUkLw2I7zI/dNlWdB8Xp7v+3w9sX5N3J/WuJ1KOO5m26kRlHQo7EzT3974g
Strategy: auth0.String("pingfederate"),
},
options: &ConnectionOptionsPingFederate{
PingFederateBaseUrl: auth0.String("https://ping.example.com"),
PingFederateBaseURL: auth0.String("https://ping.example.com"),
SigningCert: auth0.String(`-----BEGIN CERTIFICATE-----
MIID6TCCA1ICAQEwDQYJKoZIhvcNAQEFBQAwgYsxCzAJBgNVBAYTAlVTMRMwEQYD
VQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRQwEgYDVQQK
Expand Down
16 changes: 8 additions & 8 deletions management/management.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions management/management.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 46 additions & 24 deletions management/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,47 +305,69 @@ type UserList struct {
Users []*User `json:"users"`
}

// AuthenticationMethod belonging to a user.
//
// See: https://auth0.com/docs/secure/multi-factor-authentication/manage-mfa-auth0-apis/manage-authentication-methods-with-management-api
type AuthenticationMethod struct {
// The ID of the authentication method (auto generated).
ID *string `json:"id,omitempty"`

// The type of the authentication method. Should be one of "phone", "email", "totp" or "webauthn-roaming".
Type *string `json:"type,omitempty"`

// The authentication method status.
Confirmed *bool `json:"confirmed,omitempty"`

// A human-readable label to identify the authentication method.
Name *string `json:"name,omitempty"`

// The ID of a linked authentication method. Linked authentication methods will be deleted together.
LinkID *string `json:"link_id,omitempty"`

// Applies to phone authentication methods only. The destination phone number used to send verification codes via text and voice.
PhoneNumber *string `json:"phone_number,omitempty"`

// Applies to email authentication method only. The email address used to send verification messages.
Email *string `json:"email,omitempty"`

// Applies to webauthn authentication methods only. The ID of the generated credential.
KeyId *string `json:"key_id,omitempty"`
KeyID *string `json:"key_id,omitempty"`

// Applies to webauthn authentication methods only. The public key.
PublicKey *string `json:"public_key,omitempty"`

// Authenticator creation date.
CreatedAt *time.Time `json:"created_at,omitempty"`

// Enrollment date.
EnrolledAt *time.Time `json:"enrolled_at,omitempty"`

// Last authentication.
LastAuthedAt *time.Time `json:"last_auth_at,omitempty"`

// Base32 encoded secret for TOTP generation.
TOTPSecret *string `json:"totp_secret,omitempty"`

// The authentication method preferred for phone authenticators.
PreferredAuthenticationMethod *string `json:"preferred_authentication_method,omitempty"`

// Applies to email webauthn authenticators only. The relying party identifier.
RelyingPartyIdentifier *string `json:"relying_party_identifier,omitempty"`
AuthenticationMethods *[]AuthenticationMethodReference `json:"authentication_methods,omitempty"`
RelyingPartyIdentifier *string `json:"relying_party_identifier,omitempty"`

AuthenticationMethods *[]AuthenticationMethodReference `json:"authentication_methods,omitempty"`
}

// AuthenticationMethodReference used within the AuthenticationMethod.
type AuthenticationMethodReference struct {
// The ID of the authentication method (auto generated).
ID *string `json:"id,omitempty"`
// The type of the authentication method.
Type *string `json:"type,omitempty"`
}

// AuthenticationMethodList is an envelope struct which is used when calling GetAuthenticationMethods().
//
// It holds metadata such as the total result count, starting offset and limit.
type AuthenticationMethodList struct {
List
Authenticators []*AuthenticationMethod `json:"authenticators,omitempty"`
Expand Down Expand Up @@ -627,58 +649,58 @@ func (m *UserManager) Organizations(id string, opts ...RequestOption) (p *Organi
return
}

// Gets a list of authentication methods.
// GetAuthenticationMethods retrieves a list of authentication methods.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods
func (m *UserManager) GetAuthenticationMethods(userId string, opts ...RequestOption) (a *AuthenticationMethodList, err error) {
err = m.Request("GET", m.URI("users", userId, "authentication-methods"), &a, applyListDefaults(opts))
func (m *UserManager) GetAuthenticationMethods(userID string, opts ...RequestOption) (a *AuthenticationMethodList, err error) {
err = m.Request("GET", m.URI("users", userID, "authentication-methods"), &a, applyListDefaults(opts))
return
}

// Gets a specific authentication method for a user.
// GetAuthenticationMethodByID gets a specific authentication method for a user.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/get_authentication_methods_by_authentication_method_id
func (m *UserManager) GetAuthenticationMethodById(userId string, id string, opts ...RequestOption) (a *AuthenticationMethod, err error) {
err = m.Request("GET", m.URI("users", userId, "authentication-methods", id), &a, applyListDefaults(opts))
func (m *UserManager) GetAuthenticationMethodByID(userID string, id string, opts ...RequestOption) (a *AuthenticationMethod, err error) {
err = m.Request("GET", m.URI("users", userID, "authentication-methods", id), &a, applyListDefaults(opts))
return
}

// Creates an authentication method for a user.
// CreateAuthenticationMethod creates an authentication method for a user.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/post_authentication_methods
func (m *UserManager) CreateAuthenticationMethod(userId string, a *AuthenticationMethod, opts ...RequestOption) (err error) {
err = m.Request("POST", m.URI("users", userId, "authentication-methods"), &a, opts...)
func (m *UserManager) CreateAuthenticationMethod(userID string, a *AuthenticationMethod, opts ...RequestOption) (err error) {
err = m.Request("POST", m.URI("users", userID, "authentication-methods"), &a, opts...)
return
}

// Updates all authentication methods by replacing them with the given ones..
// UpdateAllAuthenticationMethods updates all authentication methods by replacing them with the given ones.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/put_authentication_methods
func (m *UserManager) UpdateAllAuthenticationMethods(userId string, a *[]AuthenticationMethod, opts ...RequestOption) (err error) {
err = m.Request("PUT", m.URI("users", userId, "authentication-methods"), &a, opts...)
func (m *UserManager) UpdateAllAuthenticationMethods(userID string, a *[]AuthenticationMethod, opts ...RequestOption) (err error) {
err = m.Request("PUT", m.URI("users", userID, "authentication-methods"), &a, opts...)
return
}

// Updates an authentication method by ID.
// UpdateAuthenticationMethod updates an authentication method by ID.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/patch_authentication_methods_by_authentication_method_id
func (m *UserManager) UpdateAuthenticationMethod(userId string, id string, a *AuthenticationMethod, opts ...RequestOption) (err error) {
err = m.Request("PATCH", m.URI("users", userId, "authentication-methods", id), &a, opts...)
func (m *UserManager) UpdateAuthenticationMethod(userID string, id string, a *AuthenticationMethod, opts ...RequestOption) (err error) {
err = m.Request("PATCH", m.URI("users", userID, "authentication-methods", id), &a, opts...)
return
}

// Deletes an authentication method by ID
// DeleteAuthenticationMethod deletes an authentication method by ID.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods_by_authentication_method_id
func (m *UserManager) DeleteAuthenticationMethod(userId string, id string, opts ...RequestOption) (err error) {
err = m.Request("DELETE", m.URI("users", userId, "authentication-methods", id), nil, opts...)
func (m *UserManager) DeleteAuthenticationMethod(userID string, id string, opts ...RequestOption) (err error) {
err = m.Request("DELETE", m.URI("users", userID, "authentication-methods", id), nil, opts...)
return
}

// Deletes all authentication methods for the given user.
// DeleteAllAuthenticationMethods deletes all authentication methods for the given user.
//
// See: https://auth0.com/docs/api/management/v2#!/Users/delete_authentication_methods
func (m *UserManager) DeleteAllAuthenticationMethods(userId string, opts ...RequestOption) (err error) {
err = m.Request("DELETE", m.URI("users", userId, "authentication-methods"), nil, opts...)
func (m *UserManager) DeleteAllAuthenticationMethods(userID string, opts ...RequestOption) (err error) {
err = m.Request("DELETE", m.URI("users", userID, "authentication-methods"), nil, opts...)
return
}
4 changes: 2 additions & 2 deletions management/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func TestUserManager_AuthenticationMethods(t *testing.T) {
assert.Len(t, methods.Authenticators, 1)
assert.Equal(t, method.GetID(), methods.Authenticators[0].GetID())

methodInfo, err := api.User.GetAuthenticationMethodById(user.GetID(), method.GetID())
methodInfo, err := api.User.GetAuthenticationMethodByID(user.GetID(), method.GetID())
assert.NoError(t, err)
assert.Equal(t, method.GetID(), methodInfo.GetID())

Expand All @@ -380,7 +380,7 @@ func TestUserManager_AuthenticationMethods(t *testing.T) {
})
assert.NoError(t, err)

methodInfo, err = api.User.GetAuthenticationMethodById(user.GetID(), method.GetID())
methodInfo, err = api.User.GetAuthenticationMethodByID(user.GetID(), method.GetID())
assert.NoError(t, err)
assert.Equal(t, "Test2", methodInfo.GetName())

Expand Down

0 comments on commit f71b0c5

Please sign in to comment.