bearertokenauthextension

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

Authenticator - Bearer

This extension implements configauth.GRPCClientAuthenticator and is to be used in gRPC receivers inside the auth settings as a means to embed a static token for every RPC call that will be made.

The authenticator type has to be set to bearertokenauth.

Configuration

The following is the only setting and is required:

  • token: static authorization token that needs to be sent on every gRPC client call as metadata. This token is prepended by "Bearer " before being sent as a value of "authorization" key in RPC metadata.

    Note: bearertokenauth requires transport layer security enabled on the exporter.

extensions:
  bearertokenauth:
    token: "somerandomtoken"

receivers:
  hostmetrics:
    scrapers:
      memory:
  otlp:
    protocols:
      grpc:

exporters:
  otlp/withauth:
    endpoint: 0.0.0.0:5000
    ca_file: /tmp/certs/ca.pem
    auth:
      authenticator: bearertokenauth

service:
  extensions: [bearertokenauth]
  pipelines:
    metrics:
      receivers: [hostmetrics]
      processors: []
      exporters: [otlp/withauth]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() component.ExtensionFactory

NewFactory creates a factory for the static bearer token Authenticator extension.

Types

type BearerTokenAuth

type BearerTokenAuth struct {
	// contains filtered or unexported fields
}

BearerTokenAuth is an implementation of configauth.GRPCClientAuthenticator. It embeds a static authorization "bearer" token in every rpc call.

func (*BearerTokenAuth) PerRPCCredentials

func (b *BearerTokenAuth) PerRPCCredentials() (credentials.PerRPCCredentials, error)

PerRPCCredentials returns PerRPCAuth an implementation of credentials.PerRPCCredentials that

func (*BearerTokenAuth) Shutdown

func (b *BearerTokenAuth) Shutdown(ctx context.Context) error

Shutdown of BearerTokenAuth does nothing and returns nil

func (*BearerTokenAuth) Start

func (b *BearerTokenAuth) Start(ctx context.Context, host component.Host) error

Start of BearerTokenAuth does nothing and returns nil

type Config

type Config struct {
	config.ExtensionSettings `mapstructure:",squash"`

	// BearerToken specifies the bearer token to use for every RPC.
	BearerToken string `mapstructure:"token,omitempty"`
}

Config specifies how the Per-RPC bearer token based authentication data should be obtained.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks if the extension configuration is valid

type PerRPCAuth

type PerRPCAuth struct {
	// contains filtered or unexported fields
}

PerRPCAuth is a gRPC credentials.PerRPCCredentials implementation that returns an 'authorization' header.

func (*PerRPCAuth) GetRequestMetadata

func (c *PerRPCAuth) GetRequestMetadata(context.Context, ...string) (map[string]string, error)

GetRequestMetadata returns the request metadata to be used with the RPC.

func (*PerRPCAuth) RequireTransportSecurity

func (c *PerRPCAuth) RequireTransportSecurity() bool

RequireTransportSecurity always returns true for this implementation. Passing bearer tokens in plain-text connections is a bad idea.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL