diff --git a/README.md b/README.md index d9c5c82..f602045 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,10 @@ with(out) blazingly fast cloud-native web3 memory-safe blockchain reactive AI This should be done by **October 17th 2024**. Or, at the very least, in a state that proves I am competent Go developer. -Note: **JSON** is used for storage at proof-of-concept stage for ease of use \ No newline at end of file +Note: **JSON** is used for storage at proof-of-concept stage for ease of use + +## Current functionality + +* `POST /register` - register a user with Basic Auth +* `POST /login` - get a JWT token by Basic Auth +* `GET /public-key` - get PEM-encoded public HS256 key \ No newline at end of file diff --git a/jwt.go b/jwt.go index 7c87649..e219f93 100644 --- a/jwt.go +++ b/jwt.go @@ -10,6 +10,7 @@ import ( "log/slog" "net/http" "os" + "time" "github.com/golang-jwt/jwt/v5" ) @@ -18,7 +19,6 @@ var KeyFile = "key" var ( key *ecdsa.PrivateKey - // t *jwt.Token ) // LoadKey attempts to load a private key from KeyFile. @@ -76,8 +76,10 @@ func CreateJWT(usr User) (string, error) { t := jwt.NewWithClaims(jwt.SigningMethodES256, jwt.MapClaims{ "iss": "pye", - "sub": "john", - "foo": 2, + "uid": usr.Uuid, + "sub": usr.Email, + "iat": time.Now(), + "exp": time.Now().Add(time.Hour * 24 * 7), }) s, err := t.SignedString(key) if err != nil {