* feat(server): moved an http server object into a pkg subdir to be reusable for http, spots, and integrations * feat(web): isolated web module (server, router, middleware, utils) used in spots and new integrations * feat(web): removed possible panic * feat(web): split all handlers from http service into different packages for better management. * feat(web): changed router's method signature * feat(web): added missing handlers interface * feat(web): added health middleware to remove unnecessary checks * feat(web): customizable middleware set for web servers * feat(web): simplified the handler's structure * feat(web): created an unified server.Run method for all web services (http, spot, integrations) * feat(web): fixed a json size limit issue * feat(web): removed Keys and PG connection from router * feat(web): simplified integration's main file * feat(web): simplified spot's main file * feat(web): simplified http's main file (builder) * feat(web): refactored audit trail functionality * feat(web): added ee version of audit trail * feat(web): added ee version of conditions module * feat(web): moved ee version of some web session structs * feat(web): new format of web metrics * feat(web): added new web metrics to all handlers * feat(web): added justExpired feature to web ingest handler * feat(web): added small integrations improvements
27 lines
630 B
Go
27 lines
630 B
Go
package user
|
|
|
|
import "github.com/golang-jwt/jwt/v5"
|
|
|
|
type JWTClaims struct {
|
|
UserId int `json:"userId"`
|
|
TenantID int `json:"tenantId"`
|
|
jwt.RegisteredClaims
|
|
}
|
|
|
|
type User struct {
|
|
ID uint64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
TenantID uint64 `json:"tenantId"`
|
|
JwtIat int `json:"jwtIat"`
|
|
Permissions map[string]bool `json:"permissions"`
|
|
AuthMethod string
|
|
}
|
|
|
|
func (u *User) HasPermission(perm string) bool {
|
|
if u.Permissions == nil {
|
|
return true // no permissions
|
|
}
|
|
_, ok := u.Permissions[perm]
|
|
return ok
|
|
}
|