forked from hashicorp/vault-plugin-auth-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
path_ui.go
45 lines (36 loc) · 999 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
38
39
40
41
42
43
44
45
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
// 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$`,
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixJWT,
OperationVerb: "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
}