No Description

Darko Luketic 7bdfd541f1 added RoleInRoles utility function 8 months ago
ginerror af85669f1c bad copy/paste, changed ginerror.Error field 8 months ago
keycloakclaims 7bdfd541f1 added RoleInRoles utility function 8 months ago 611f911b5f dear imports in readme 8 months ago
gin.go ef64b6cff8 errors have to be an array after all 8 months ago
go.mod 0ef4602dec initial 8 months ago
go.sum 0ef4602dec initial 8 months ago


ginoidc is a package based on XenitAB's gin oidc middleware.

It features the handler being permissive and adds errors to the *gin.Context's context values under the "oidcerrors" key.

You can also extract keycloak claims from the *gin.Context via keycloakclaims.FromRequest(*gin.Context).

package main
import (
func main() {
    r := gin.Default()

    var cfg config.OIDCConfig
    oidcHandler := ginoidc.New(
    v1 := r.Group("/api/v1")

    entity := v1.Group("/entity")
    entity.GET("/", List)
    entity.GET("/:id", GetOne)
    entity.POST("/", CreateOne)
    entity.PUT("/:id", UpdateOne)
    entity.DELETE("/:id", DeleteOne)

// example handler
func List(cx *gin.Context) {
    claims := keycloakclaims.FromRequest(cx)
    cx.JSON(200, claims)