mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-10 16:47:01 +02:00
* docs: input format for default_critical_options and default_extensions * s/sshca/ssh * Added default_critical_options and default_extensions to the read endpoint of role * Change default time return value to 0
41 lines
945 B
Go
41 lines
945 B
Go
package ssh
|
|
|
|
import (
|
|
"github.com/hashicorp/vault/logical"
|
|
"github.com/hashicorp/vault/logical/framework"
|
|
)
|
|
|
|
func pathFetchPublicKey(b *backend) *framework.Path {
|
|
return &framework.Path{
|
|
Pattern: `public_key`,
|
|
|
|
Callbacks: map[logical.Operation]framework.OperationFunc{
|
|
logical.ReadOperation: b.pathFetchPublicKey,
|
|
},
|
|
|
|
HelpSynopsis: `Retrieve the public key.`,
|
|
HelpDescription: `This allows the public key, that this backend has been configured with, to be fetched.`,
|
|
}
|
|
}
|
|
|
|
func (b *backend) pathFetchPublicKey(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
|
|
entry, err := req.Storage.Get("public_key")
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if entry == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
response := &logical.Response{
|
|
Data: map[string]interface{}{
|
|
logical.HTTPContentType: "text/plain",
|
|
logical.HTTPRawBody: entry.Value,
|
|
logical.HTTPStatusCode: 200,
|
|
},
|
|
}
|
|
|
|
return response, nil
|
|
}
|