Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[configauth] Fix unmarshaling of confighttp.AuthConfig #10749

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .chloggen/mx-psi_fix-106-issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: bug_fix

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: configauth

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Fix unmarshaling of authentication in HTTP servers.

# One or more tracking issues or pull requests related to the change
issues: [10750]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
2 changes: 1 addition & 1 deletion config/confighttp/confighttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func NewDefaultServerConfig() ServerConfig {

type AuthConfig struct {
// Auth for this receiver.
*configauth.Authentication `mapstructure:"-"`
configauth.Authentication `mapstructure:",squash"`

// RequestParameters is a list of parameters that should be extracted from the request and added to the context.
// When a parameter is found in both the query string and the header, the value from the query string will be used.
Expand Down
10 changes: 5 additions & 5 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func TestHttpCorsWithSettings(t *testing.T) {
AllowedOrigins: []string{"*"},
},
Auth: &AuthConfig{
Authentication: &configauth.Authentication{
Authentication: configauth.Authentication{
AuthenticatorID: mockID,
},
},
Expand Down Expand Up @@ -1171,7 +1171,7 @@ func TestServerAuth(t *testing.T) {
hss := ServerConfig{
Endpoint: "localhost:0",
Auth: &AuthConfig{
Authentication: &configauth.Authentication{
Authentication: configauth.Authentication{
AuthenticatorID: mockID,
},
},
Expand Down Expand Up @@ -1207,7 +1207,7 @@ func TestServerAuth(t *testing.T) {
func TestInvalidServerAuth(t *testing.T) {
hss := ServerConfig{
Auth: &AuthConfig{
Authentication: &configauth.Authentication{
Authentication: configauth.Authentication{
AuthenticatorID: nonExistingID,
},
},
Expand All @@ -1223,7 +1223,7 @@ func TestFailedServerAuth(t *testing.T) {
hss := ServerConfig{
Endpoint: "localhost:0",
Auth: &AuthConfig{
Authentication: &configauth.Authentication{
Authentication: configauth.Authentication{
AuthenticatorID: mockID,
},
},
Expand Down Expand Up @@ -1404,7 +1404,7 @@ func TestAuthWithQueryParams(t *testing.T) {
Endpoint: "localhost:0",
Auth: &AuthConfig{
RequestParameters: []string{"auth"},
Authentication: &configauth.Authentication{
Authentication: configauth.Authentication{
AuthenticatorID: mockID,
},
},
Expand Down
2 changes: 1 addition & 1 deletion extension/zpagesextension/zpagesextension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestZPagesExtensionBadAuthExtension(t *testing.T) {
confighttp.ServerConfig{
Endpoint: "localhost:0",
Auth: &confighttp.AuthConfig{
Authentication: &configauth.Authentication{
Authentication: configauth.Authentication{
AuthenticatorID: component.MustNewIDWithName("foo", "bar"),
},
},
Expand Down
6 changes: 6 additions & 0 deletions receiver/otlpreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/require"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configauth"
"go.opentelemetry.io/collector/config/configgrpc"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/confignet"
Expand Down Expand Up @@ -117,6 +118,11 @@ func TestUnmarshalConfig(t *testing.T) {
},
HTTP: &HTTPConfig{
ServerConfig: &confighttp.ServerConfig{
Auth: &confighttp.AuthConfig{
Authentication: configauth.Authentication{
AuthenticatorID: component.MustNewID("test"),
},
},
Endpoint: "localhost:4318",
TLSSetting: &configtls.ServerConfig{
Config: configtls.Config{
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector v0.106.0
go.opentelemetry.io/collector/component v0.106.0
go.opentelemetry.io/collector/config/configauth v0.106.0
go.opentelemetry.io/collector/config/configgrpc v0.106.0
go.opentelemetry.io/collector/config/confighttp v0.106.0
go.opentelemetry.io/collector/config/confignet v0.106.0
Expand Down Expand Up @@ -56,7 +57,6 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rs/cors v1.11.0 // indirect
go.opentelemetry.io/collector/client v0.106.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.106.0 // indirect
go.opentelemetry.io/collector/config/configcompression v1.12.0 // indirect
go.opentelemetry.io/collector/config/configopaque v1.12.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.106.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions receiver/otlpreceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ protocols:
min_time: 10s
permit_without_stream: true
http:
auth:
authenticator: test
# The following entry demonstrates how to specify TLS credentials for the server.
# Note: These files do not exist. If the receiver is started with this configuration, it will fail.
tls:
Expand Down
Loading