@@ -2,6 +2,7 @@ package node
2
2
3
3
import (
4
4
"context"
5
+ "time"
5
6
6
7
"github.com/filecoin-project/go-jsonrpc/auth"
7
8
)
@@ -24,17 +25,20 @@ type Module interface {
24
25
AuthVerify (ctx context.Context , token string ) ([]auth.Permission , error )
25
26
// AuthNew signs and returns a new token with the given permissions.
26
27
AuthNew (ctx context.Context , perms []auth.Permission ) (string , error )
28
+ // AuthNewWithExpiry signs and returns a new token with the given permissions and TTL.
29
+ AuthNewWithExpiry (ctx context.Context , perms []auth.Permission , ttl time.Duration ) (string , error )
27
30
}
28
31
29
32
var _ Module = (* API )(nil )
30
33
31
34
type API struct {
32
35
Internal struct {
33
- Info func (context.Context ) (Info , error ) `perm:"admin"`
34
- Ready func (context.Context ) (bool , error ) `perm:"read"`
35
- LogLevelSet func (ctx context.Context , name , level string ) error `perm:"admin"`
36
- AuthVerify func (ctx context.Context , token string ) ([]auth.Permission , error ) `perm:"admin"`
37
- AuthNew func (ctx context.Context , perms []auth.Permission ) (string , error ) `perm:"admin"`
36
+ Info func (context.Context ) (Info , error ) `perm:"admin"`
37
+ Ready func (context.Context ) (bool , error ) `perm:"read"`
38
+ LogLevelSet func (ctx context.Context , name , level string ) error `perm:"admin"`
39
+ AuthVerify func (ctx context.Context , token string ) ([]auth.Permission , error ) `perm:"admin"`
40
+ AuthNew func (ctx context.Context , perms []auth.Permission ) (string , error ) `perm:"admin"`
41
+ AuthNewWithExpiry func (ctx context.Context , perms []auth.Permission , ttl time.Duration ) (string , error ) `perm:"admin"`
38
42
}
39
43
}
40
44
@@ -57,3 +61,7 @@ func (api *API) AuthVerify(ctx context.Context, token string) ([]auth.Permission
57
61
func (api * API ) AuthNew (ctx context.Context , perms []auth.Permission ) (string , error ) {
58
62
return api .Internal .AuthNew (ctx , perms )
59
63
}
64
+
65
+ func (api * API ) AuthNewWithExpiry (ctx context.Context , perms []auth.Permission , ttl time.Duration ) (string , error ) {
66
+ return api .Internal .AuthNewWithExpiry (ctx , perms , ttl )
67
+ }
0 commit comments