cachaca

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 30 Imported by: 0

README

Cachaça

codecov Go Reference

Cachaça (Portuguese pronunciation: kaˈʃasɐ) is a distilled spirit made from fermented sugarcane juice. Also known as pinga, caninha, and other names, it is the most popular spirit among distilled alcoholic beverages in Brazil. Outside Brazil, cachaça is used almost exclusively as an ingredient in tropical drinks, with the caipirinha being the most famous cocktail. In Brazil, caipirinha is often paired with the dish feijoada. (Source: Wikipedia).

OIDC/Oauth2 (in progress)

With this library, you can easily enable secure authentication for your applications using OAuth2/OIDC.

Supported Use Cases

The following use cases are supported:

  • Authenticate users through an identity provider (IdP) that is OpenID Connect (OIDC) compliant.
Preparing to Use an OIDC-Compliant IdP

If you are using an OIDC-compliant IdP, follow these steps:

  1. Create a new OIDC app in your IdP. The IdP's DNS must be publicly resolvable.
  2. Configure a client ID and a client secret.
  3. Obtain the following endpoints published by the IdP: authorization, token, and user info. This information can be found in the config.
  4. Ensure that the IdP endpoint certificates are issued by a trusted public certificate authority.
  5. Ensure that the DNS entries for the endpoints are publicly resolvable, even if they resolve to private IP addresses.
  6. Allow one of the following redirect URLs in your IdP app, whichever your users will use:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationMiddleware

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

func NewAuthenticationMiddleware

func NewAuthenticationMiddleware(jwtKeyFunc jwt.Keyfunc, jwtToken jwt.Claims) *AuthenticationMiddleware

func (*AuthenticationMiddleware) Middleware

func (middleware *AuthenticationMiddleware) Middleware(ctx context.Context) (context.Context, error)

func (*AuthenticationMiddleware) StreamServerInterceptor

func (middleware *AuthenticationMiddleware) StreamServerInterceptor() grpc.StreamServerInterceptor

func (*AuthenticationMiddleware) UnaryServerInterceptor

func (middleware *AuthenticationMiddleware) UnaryServerInterceptor() grpc.UnaryServerInterceptor

type Option

type Option func(*Server) error

func DisableGrpcWeb

func DisableGrpcWeb() Option

DisableGrpcWeb disables the grpc-web endpoint.

func WithEmbeddedMetricsEndpoint

func WithEmbeddedMetricsEndpoint() Option

WithEmbeddedMetricsEndpoint enables the prometheus metrics on the /metrics endpoint. Please note that when using a custom http handler this option will not be applied successfully.

func WithInsecureHealth

func WithInsecureHealth() Option

WithInsecureHealth disables authentication on the health endpoint. Otherwise, the health endpoint will be protected by the authentication middleware and requires at least a valid token or certificate.

func WithJwtKeyFunc

func WithJwtKeyFunc(keyFunc jwt.Keyfunc) Option

WithJwtKeyFunc sets the jwt key function for the authentication middleware.

func WithJwtToken

func WithJwtToken(token jwt.Claims) Option

WithJwtToken sets the jwt token for the authentication middleware.

func WithMTLSConfig

func WithMTLSConfig(pool *x509.CertPool, server *tls.Certificate) Option

WithMTLSConfig sets the mTLS configuration for the server. This requires client certificates signed by a ca from the pool and will serve with the given Certificate.

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) Option

WithReadTimeout sets the read timeout for the http server.

type Server

type Server struct {
	*gin.Engine
	// contains filtered or unexported fields
}

Server is an opinionated implementation of server providing grpc, grpc-web and rest/http endpoints on a single port.

func NewServer

func NewServer(opts ...Option) (*Server, error)

NewServer creates a new instance of the server.

func (*Server) RegisterService

func (s *Server) RegisterService(desc *grpc.ServiceDesc, impl interface{})

RegisterService implements the grpc.ServiceRegistrar interface used to register services with the grpc server. ServiceRegistrar wraps a single method that supports service registration. It enables users to pass concrete types other than grpc.Server to the service registration methods exported by the IDL generated code.

func (*Server) Serve

func (s *Server) Serve(listener net.Listener) error

Serve starts the server on the given listener. It will automatically detect if the server is configured to use TLS.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface used internally to route requests to the correct handler. This function handles the selection of the correct handler (grpc, grpc-web or http) based on the content-type header.

func (*Server) SetServingStatus

func (s *Server) SetServingStatus(service string, status healthgrpc.HealthCheckResponse_ServingStatus)

SetServingStatus is called when need to reset the serving status of a service or insert a new service entry into the statusMap.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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