add auth to /uploads

This commit is contained in:
grngxd 2025-05-06 21:50:06 +01:00
parent fbd23fe2cf
commit a3312ef6f8
4 changed files with 31 additions and 6 deletions

View file

@ -11,9 +11,9 @@ import (
)
func GenerateJWT(key string, user User, expiryTimestamp uint64) (string, error) {
claims := jwt.MapClaims{
"user": user,
"exp": expiryTimestamp,
claims := Claims{
User: user,
Exp: expiryTimestamp,
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)

View file

@ -1,6 +1,10 @@
package auth
import "time"
import (
"time"
"github.com/golang-jwt/jwt/v5"
)
type TokenResponse struct {
AccessToken string `json:"access_token"`
@ -28,3 +32,9 @@ type ExchangeCodeRequest struct {
Code string `json:"code"`
RedirectUri string `json:"redirect_uri"`
}
type Claims struct {
User User `json:"user"`
Exp uint64 `json:"exp"`
jwt.RegisteredClaims
}