Skip to content

Commit

Permalink
address pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
efd6 committed Mar 19, 2024
1 parent 5e46064 commit cdfcfe4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion x-pack/filebeat/input/cel/config_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,10 @@ func (o *oAuth2Config) validateOktaProvider() error {
if o.OktaJWKPEM != "" {
blk, rest := pem.Decode([]byte(o.OktaJWKPEM))
if rest := bytes.TrimSpace(rest); len(rest) != 0 {
return fmt.Errorf("PEM text has trailing data: %s", rest)
return fmt.Errorf("okta validation error: PEM text has trailing data: %d bytes", len(rest))
}
if blk == nil {
return errors.New("okta validation error: no PEM data")
}
_, err := x509.ParsePKCS8PrivateKey(blk.Bytes)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion x-pack/filebeat/input/cel/config_okta_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"math/big"
"net/http"
Expand Down Expand Up @@ -162,7 +163,10 @@ func (i *base64int) UnmarshalJSON(b []byte) error {
func generateOktaJWTPEM(pemdata string, cnf *oauth2.Config) (string, error) {
blk, rest := pem.Decode([]byte(pemdata))
if rest := bytes.TrimSpace(rest); len(rest) != 0 {
return "", fmt.Errorf("PEM text has trailing data: %s", rest)
return "", fmt.Errorf("PEM text has trailing data: %d bytes", len(rest))
}
if blk == nil {
return "", errors.New("no PEM data")
}
key, err := x509.ParsePKCS8PrivateKey(blk.Bytes)
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion x-pack/filebeat/input/httpjson/config_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ func (o *oAuth2Config) validateOktaProvider() error {
if o.OktaJWKPEM != "" {
blk, rest := pem.Decode([]byte(o.OktaJWKPEM))
if rest := bytes.TrimSpace(rest); len(rest) != 0 {
return fmt.Errorf("PEM text has trailing data: %s", rest)
return fmt.Errorf("okta validation error: PEM text has trailing data: %d bytes", len(rest))
}
if blk == nil {
return errors.New("okta validation error: no PEM data")
}
_, err := x509.ParsePKCS8PrivateKey(blk.Bytes)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion x-pack/filebeat/input/httpjson/config_okta_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"encoding/base64"
"encoding/json"
"encoding/pem"
"errors"
"fmt"
"math/big"
"net/http"
Expand Down Expand Up @@ -160,7 +161,10 @@ func (i *base64int) UnmarshalJSON(b []byte) error {
func generateOktaJWTPEM(pemdata string, cnf *oauth2.Config) (string, error) {
blk, rest := pem.Decode([]byte(pemdata))
if rest := bytes.TrimSpace(rest); len(rest) != 0 {
return "", fmt.Errorf("PEM text has trailing data: %s", rest)
return "", fmt.Errorf("PEM text has trailing data: %d bytes", len(rest))
}
if blk == nil {
return "", errors.New("no PEM data")
}
key, err := x509.ParsePKCS8PrivateKey(blk.Bytes)
if err != nil {
Expand Down

0 comments on commit cdfcfe4

Please sign in to comment.