@rivascva/dt-idl 1.1.100 → 1.1.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/go/auth/jwt.go +9 -0
- package/go/models/interfaces.go +13 -0
- package/package.json +1 -1
package/go/auth/jwt.go
CHANGED
|
@@ -18,6 +18,15 @@ func ValidateToken(token string, secret string) (*jwt.Token, error) {
|
|
|
18
18
|
return nil, fmt.Errorf("unable to validate the JWT token: %w", err)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
// validate the token expiration
|
|
22
|
+
e, err := parsedToken.Claims.GetExpirationTime()
|
|
23
|
+
if err != nil {
|
|
24
|
+
return nil, fmt.Errorf("failed to get the expiration time from the token: %w", err)
|
|
25
|
+
}
|
|
26
|
+
if time.Now().After(e.Time) {
|
|
27
|
+
return nil, fmt.Errorf("the JWT token has expired")
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
return parsedToken, nil
|
|
22
31
|
}
|
|
23
32
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package models
|
|
2
|
+
|
|
3
|
+
import "context"
|
|
4
|
+
|
|
5
|
+
// Flow defines a special type of handler that is intended to run a set operations independent of the caller.
|
|
6
|
+
// A flow should perform its own validation, logging, and error handling.
|
|
7
|
+
// The flow can have getters to certain results of the flow if needed.
|
|
8
|
+
// The flow can return generic errors to the caller if needed.
|
|
9
|
+
type Flow[E error] interface {
|
|
10
|
+
// Run is the entry point to the flow.
|
|
11
|
+
// The method can only return an error to the caller.
|
|
12
|
+
Run(ctx context.Context) E
|
|
13
|
+
}
|