Skip to content

Commit

Permalink
Misc review responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisberkhout committed Mar 3, 2025
1 parent b72aff6 commit 3e2cbbc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
11 changes: 4 additions & 7 deletions x-pack/filebeat/input/o365audit/auth/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package auth

import (
"crypto"
"crypto/rsa"
"crypto/x509"
"fmt"
Expand All @@ -17,9 +16,7 @@ import (

// NewProviderFromCertificate returns a TokenProvider that uses certificate-based
// authentication.
func NewProviderFromCertificate(
endpoint, resource, applicationID, tenantID string,
conf tlscommon.CertificateConfig) (sptp TokenProvider, err error) {
func NewProviderFromCertificate(resource, applicationID, tenantID string, conf tlscommon.CertificateConfig) (sptp TokenProvider, err error) {
cert, privKey, err := loadConfigCerts(conf)
if err != nil {
return nil, fmt.Errorf("failed loading certificates: %w", err)
Expand All @@ -33,7 +30,7 @@ func NewProviderFromCertificate(
return (*credentialTokenProvider)(cred), nil
}

func loadConfigCerts(cfg tlscommon.CertificateConfig) (cert *x509.Certificate, key crypto.PrivateKey, err error) {
func loadConfigCerts(cfg tlscommon.CertificateConfig) (cert *x509.Certificate, key *rsa.PrivateKey, err error) {
tlsCert, err := tlscommon.LoadCertificate(&cfg)
if err != nil {
return nil, nil, fmt.Errorf("error loading X509 certificate from '%s': %w", cfg.Certificate, err)
Expand All @@ -48,9 +45,9 @@ func loadConfigCerts(cfg tlscommon.CertificateConfig) (cert *x509.Certificate, k
if tlsCert.PrivateKey == nil {
return nil, nil, fmt.Errorf("failed loading private key from '%s'", cfg.Key)
}
_, ok := tlsCert.PrivateKey.(*rsa.PrivateKey)
key, ok := tlsCert.PrivateKey.(*rsa.PrivateKey)
if !ok {
return nil, nil, fmt.Errorf("private key at '%s' is not an RSA private key", cfg.Key)
}
return cert, tlsCert.PrivateKey, nil
return cert, key, nil
}
1 change: 0 additions & 1 deletion x-pack/filebeat/input/o365audit/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ func (c *Config) NewTokenProvider(tenantID string) (auth.TokenProvider, error) {
)
}
return auth.NewProviderFromCertificate(
c.API.AuthenticationEndpoint,
c.API.Resource,
c.ApplicationID,
tenantID,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/o365audit/contentblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (c contentBlob) handleError(response *http.Response) (actions []poll.Action
}

switch response.StatusCode {
case 401: // Authentication error. Renew oauth token and repeat this op.
case 401: // Authentication error. Repeat this op.
return []poll.Action{
poll.Fetch(withDelay{contentBlob: c, delay: c.env.Config.PollInterval}),
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/o365audit/listblobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (l listBlob) handleError(response *http.Response) (actions []poll.Action) {

switch response.StatusCode {
case 401:
// Authentication error. Renew oauth token and repeat this op.
// Authentication error. Repeat this op.
l.delay = l.env.Config.PollInterval
return []poll.Action{
poll.Fetch(l),
Expand Down

0 comments on commit 3e2cbbc

Please sign in to comment.