add auth for future https srever and cfgHandler to load configuration
This commit is contained in:
15
auth/auth.go
Normal file
15
auth/auth.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func GetIDFromAuth(c *gin.Context) (string, error) {
|
||||
auth := c.GetHeader("Authorization")
|
||||
if len(auth) > 7 && auth[:7] == "Bearer " {
|
||||
return auth[7:], nil
|
||||
}
|
||||
return "", errors.New("authorization token missing")
|
||||
}
|
Reference in New Issue
Block a user