auth

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// HmacDefaultKey is a exported constant for convenience
	// FIXME where is this used ?
	HmacDefaultKey = "4Rahs0WnJ4rJE8ZiwiLec62z" //nolint:gosec

)

Variables

View Source
var (
	// Edit Groupname
	EditGroups = []security.ResourceAccess{
		security.ResourceAccess("tmdm-all-all-edit"),
	}

	EditAccess = sec.MergeResourceAccess(EditGroups)

	// Edit User
	EditUser = security.User{
		EMail:  "tmdm@metal-stack.io",
		Name:   "tmdm",
		Groups: sec.MergeResourceAccess(EditGroups),
		Tenant: "tmdm",
	}
)

Functions

func GetUser

func GetUser(ctx context.Context) *security.User

GetUser gets the authenticated user from the given context. Note that it is necessary to call Auth() in an interceptor to put the user in the context.

May return nil if no user is authenticated or not of the correct type.

Used on the service/server-side.

Types

type HMACAuther

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

HMACAuther provides means for generation/encoding and decoding/validation for grpc. This code is potentially re-usable for all grpc-based clients/services that want to use hmac-Authentication.

func NewHMACAuther

func NewHMACAuther(hmacKey string, user security.User) (*HMACAuther, error)

NewHMACAuther creates a new HMACAuther with the given hmac-pre-shared-key and user.

func (*HMACAuther) Auth

func (a *HMACAuther) Auth(ctx context.Context) (context.Context, error)

Auth returns a new Context with the authenticated "user" from the current request. If there is no authentication info in the request, or the verification of the HMAC fails an Status-Error is returned with Code Unauthenticated.

see GetUser()

Used on the service/server-side.

func (*HMACAuther) GetRequestMetadata

func (a *HMACAuther) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata gets the current request metadata, refreshing tokens if required. This should be called by the transport layer on each request, and the data should be populated in headers or other context.

Used on the client-side.

func (*HMACAuther) RequireTransportSecurity

func (a *HMACAuther) RequireTransportSecurity() bool

RequireTransportSecurity indicates whether the credentials requires transport security.

Used on the client-side.

Jump to

Keyboard shortcuts

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