38 lines
785 B
Go
38 lines
785 B
Go
package consul
|
|
|
|
import (
|
|
"github.com/hashicorp/vault/logical"
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
)
|
|
|
|
const SecretTokenType = "token"
|
|
|
|
func secretToken() *framework.Secret {
|
|
return &framework.Secret{
|
|
Type: SecretTokenType,
|
|
Fields: map[string]*framework.FieldSchema{
|
|
"token": &framework.FieldSchema{
|
|
Type: framework.TypeString,
|
|
Description: "Request token",
|
|
},
|
|
},
|
|
|
|
Revoke: secretTokenRevoke,
|
|
}
|
|
}
|
|
|
|
func secretTokenRevoke(
|
|
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
|
c, err := client(req.Storage)
|
|
if err != nil {
|
|
return logical.ErrorResponse(err.Error()), nil
|
|
}
|
|
|
|
_, err = c.ACL().Destroy(d.Get("token").(string), nil)
|
|
if err != nil {
|
|
return logical.ErrorResponse(err.Error()), nil
|
|
}
|
|
|
|
return nil, nil
|
|
}
|