mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-01 23:55:44 +02:00
feature: add setup key HTTP api response fields
This commit is contained in:
parent
3c47a3c408
commit
dcc9dcacdc
@ -5,6 +5,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/wiretrustee/wiretrustee/management/server"
|
"github.com/wiretrustee/wiretrustee/management/server"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SetupKeys is a handler that returns a list of setup keys of the account
|
// SetupKeys is a handler that returns a list of setup keys of the account
|
||||||
@ -14,7 +15,10 @@ type SetupKeys struct {
|
|||||||
|
|
||||||
// SetupKeyResponse is a response sent to the client
|
// SetupKeyResponse is a response sent to the client
|
||||||
type SetupKeyResponse struct {
|
type SetupKeyResponse struct {
|
||||||
Key string
|
Key string
|
||||||
|
Name string
|
||||||
|
Expires time.Time
|
||||||
|
Type string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSetupKeysHandler(accountManager *server.AccountManager) *SetupKeys {
|
func NewSetupKeysHandler(accountManager *server.AccountManager) *SetupKeys {
|
||||||
@ -41,7 +45,10 @@ func (h *SetupKeys) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
respBody := []*SetupKeyResponse{}
|
respBody := []*SetupKeyResponse{}
|
||||||
for _, key := range account.SetupKeys {
|
for _, key := range account.SetupKeys {
|
||||||
respBody = append(respBody, &SetupKeyResponse{
|
respBody = append(respBody, &SetupKeyResponse{
|
||||||
Key: key.Key,
|
Key: key.Key,
|
||||||
|
Name: key.Key,
|
||||||
|
Expires: time.Now().Add(30 * (time.Second * 60 * 60 * 24)),
|
||||||
|
Type: "reusable",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user