ogrpc

package
v0.0.0-...-5f133c6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractCookie

func ExtractCookie(lines []string, name string) *string

ExtractCookie returns the value of the first cookie by the specified name.

lines is a list of cookie header lines, as extracted from the HTTP or gRPC request. name is the name of a cookie.

The value of the cookie is returned, or nil if no cookie by the specified name was found.

func GetCookieValue

func GetCookieValue(line, desired string) *string

GetCookieValue extracts the value of a cookie, formatted as per HTTP standard.

This function does not implement the full HTTP standard, just enough to extract the cookie value for validation.

func ProcessMetdata

func ProcessMetdata(auth *oauth.Authenticator, ctx context.Context) (context.Context, error)

ProcessMetadata extracts the grpc metadata from a grpc provided context.Context, and verifies that the request was effectively authenticated.

There is no authorization at this layer, just sets the credentials of the user.

func StreamInterceptor

func StreamInterceptor(auth *oauth.Authenticator, unauthenticated ...string) grpc.StreamServerInterceptor

func UnaryInterceptor

func UnaryInterceptor(auth *oauth.Authenticator, unauthenticated ...string) grpc.UnaryServerInterceptor

Types

type ContextStream

type ContextStream struct {
	grpc.ServerStream
	// contains filtered or unexported fields
}

ContextStream is a grpc.ServerStream with a different context attached.

This is necessary as grpc.ServerStream has no mechanism to change the context attached with the stream. So, we replace the stream instead.

func SetContextStream

func SetContextStream(stream grpc.ServerStream, ctx context.Context) *ContextStream

func (*ContextStream) Context

func (c *ContextStream) Context() context.Context

type GrpcInterceptor

type GrpcInterceptor func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

Jump to

Keyboard shortcuts

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