-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_ui.go
37 lines (30 loc) · 811 Bytes
/
path_ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// A minimal UI for simple testing via a UI without Vault
package jwtauth
import (
"context"
"io/ioutil"
"github.com/hashicorp/vault/sdk/framework"
"github.com/hashicorp/vault/sdk/logical"
)
func pathUI(b *jwtAuthBackend) *framework.Path {
return &framework.Path{
Pattern: `ui$`,
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathUI,
},
}
}
func (b *jwtAuthBackend) pathUI(ctx context.Context, req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
data, err := ioutil.ReadFile("test_ui.html")
if err != nil {
panic(err)
}
resp := &logical.Response{
Data: map[string]interface{}{
logical.HTTPStatusCode: 200,
logical.HTTPRawBody: string(data),
logical.HTTPContentType: "text/html",
},
}
return resp, nil
}