Changeset 0.5.0 (#35)
This commit is contained in:
@@ -31,6 +31,13 @@ func Auth(cfg *config.Config) gin.HandlerFunc {
|
||||
}
|
||||
|
||||
header := c.GetHeader("Authorization")
|
||||
if header == "" {
|
||||
// WebSocket connections can't set headers from browser.
|
||||
// Fall back to ?token= query parameter.
|
||||
if qToken := c.Query("token"); qToken != "" {
|
||||
header = "Bearer " + qToken
|
||||
}
|
||||
}
|
||||
if header == "" {
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{
|
||||
"error": "missing authorization header",
|
||||
|
||||
Reference in New Issue
Block a user