Skip to content

stupidwebauthn/swa_sdk_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference

Stupid Webauthn Sdk GoLang

Gin example

import (
	"github.com/gin-gonic/gin"
	"github.com/stupidwebauthn/swa_sdk_go"
)

r.Use(func(c *gin.Context) {
	header := c.Writer.Header()
	res, status, err := swa.AuthMiddleware(c.Request, &header)
	if err != nil {
		c.AbortWithError(status, err)
		return
	}
	c.Set("swa", res)
	c.Next()
})
r.GET("/api/data", func(c *gin.Context) {
	rawAuth, _ := c.Get("swa")
	auth := rawAuth.(*swa_sdk_go.AuthResponse)
	...
})