Skip to content

Commit

Permalink
[chore] combine auth files, rename old names related to authentificat…
Browse files Browse the repository at this point in the history
…or (#6666)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Dec 5, 2022
1 parent e7edb00 commit 55cc3e9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,21 @@ import (
"google.golang.org/grpc/credentials"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)

var _ Client = (*defaultClient)(nil)
// Client is an Extension that can be used as an authenticator for the configauth.Authentication option.
// Authenticators are then included as part of OpenTelemetry Collector builds and can be referenced by their
// names from the Authentication configuration.
type Client interface {
extension.Extension

// RoundTripper returns a RoundTripper that can be used to authenticate HTTP requests.
RoundTripper(base http.RoundTripper) (http.RoundTripper, error)

// PerRPCCredentials returns a PerRPCCredentials that can be used to authenticate gRPC requests.
PerRPCCredentials() (credentials.PerRPCCredentials, error)
}

// ClientOption represents the possible options for NewServerAuthenticator.
type ClientOption func(*defaultClient)
Expand Down
File renamed without changes.
36 changes: 0 additions & 36 deletions extension/auth/clientauth.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,27 @@ import (
"context"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/extension"
)

var _ Server = (*defaultServer)(nil)
// Server is an Extension that can be used as an authenticator for the configauth.Authentication option.
// Authenticators are then included as part of OpenTelemetry Collector builds and can be referenced by their
// names from the Authentication configuration. Each Server is free to define its own behavior and configuration options,
// but note that the expectations that come as part of Extensions exist here as well. For instance, multiple instances of the same
// authenticator should be possible to exist under different names.
type Server interface {
extension.Extension

// Authenticate checks whether the given headers map contains valid auth data. Successfully authenticated calls will always return a nil error.
// When the authentication fails, an error must be returned and the caller must not retry. This function is typically called from interceptors,
// on behalf of receivers, but receivers can still call this directly if the usage of interceptors isn't suitable.
// The deadline and cancellation given to this function must be respected, but note that authentication data has to be part of the map, not context.
// The resulting context should contain the authentication data, such as the principal/username, group membership (if available), and the raw
// authentication data (if possible). This will allow other components in the pipeline to make decisions based on that data, such as routing based
// on tenancy as determined by the group membership, or passing through the authentication data to the next collector/backend.
// The context keys to be used are not defined yet.
Authenticate(ctx context.Context, headers map[string][]string) (context.Context, error)
}

type defaultServer struct {
ServerAuthenticateFunc
Expand Down
File renamed without changes.
40 changes: 0 additions & 40 deletions extension/auth/serverauth.go

This file was deleted.

0 comments on commit 55cc3e9

Please sign in to comment.