Documentation
¶
Overview ¶
Package middlewares provides the following Gin middlewares:
- auth
The authentication middleware by sending the Bearer token to `sylvia-iot-auth`.
Here is an example to wrap the auth middleware and how to get token information:
import ( "github.com/gin-gonic/gin" "github.com/woofdogtw/sylvia-iot-go/sdk/middlewares" ) func main() { r := gin.Default() r.Use(middlewares.AuthMiddleware("http://localhost:1080/auth/api/v1/auth/tokeninfo")) r.GET("/", func(c *gin.Context) { c.AbortWithStatus(204) }) r.Run() }
Index ¶
Constants ¶
View Source
const (
TokenInfoKey = "FullTokenInfo"
)
Constants.
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
Generate the Gin authentication middleware.
Types ¶
type FullTokenInfo ¶
type FullTokenInfo struct { Token string Info GetTokenInfoData }
The information contains `GetTokenInfoData` and access token.
type GetTokenInfo ¶
type GetTokenInfo struct {
Data GetTokenInfoData `json:"data"`
}
The user/client information of the token.
Click to show internal directories.
Click to hide internal directories.