gink8sauth

package module
v0.0.0-...-373d8b7 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

gin-k8s-auth

Kubernetes auth middlewares for the gin web framework. There are separate middlewares for authentication and authorization.

K8SAuthenticator

K8SAuthenticator uses Kubernetes TokenAccessReviews to authenticate an incoming connection. This middleware can be used for authentication against incoming requests to all endpoints, or a subset of endpoints.

To use the authenticator, it must be provided a Kubernetes client interface object. See the server example for details of how to create one from a local kubeconfig file.

Once the Kubernetes interface has been created, you can use the K8SAuthenticator just like any other gin middleware:

    r := gin.Default()
    // Use the authenticator for all requests
    r.Use(gink8sauth.K8SAuthenticator(client))
	r.GET("/hello", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"message": "hello world!",
		})
	})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func K8SAuthenticator

func K8SAuthenticator(client kubernetes.Interface) gin.HandlerFunc

K8SAuthenticator returns gin middleware that authenticates a request against a Kubernetes apiserver. If the authentication is successful, the middleware provides the k8s user info via the "k8s-user-info" context key.

Types

This section is empty.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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