Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.6.3 gimmeallyourlovin #1

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builtin/logical/pki/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func Backend(conf *logical.BackendConfig) *backend {
pathSignVerbatim(&b),
pathSign(&b),
pathIssue(&b),
pathGG(&b),
pathRotateCRL(&b),
pathFetchCA(&b),
pathFetchCAChain(&b),
Expand Down
57 changes: 57 additions & 0 deletions builtin/logical/pki/path_issue_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pki
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"time"

Expand All @@ -14,6 +15,22 @@ import (
"github.com/hashicorp/vault/sdk/logical"
)

func pathGG(b *backend) *framework.Path {
ret := &framework.Path{
Pattern: "gimmeallyourlovin",

Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathGG,
},

HelpSynopsis: "La la la la la la la laaaa.",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol :p

HelpDescription: "La la la la la la la laaaa.",
}

ret.Fields = addNonCACommonFields(map[string]*framework.FieldSchema{})
return ret
}

func pathIssue(b *backend) *framework.Path {
ret := &framework.Path{
Pattern: "issue/" + framework.GenericNameRegex("role"),
Expand Down Expand Up @@ -104,6 +121,46 @@ this value to an empty list.`,
return ret
}

func (b *backend) pathGG(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
signingBundle, caErr := fetchCAInfo(ctx, req)
switch caErr.(type) {
case errutil.UserError:
return nil, errutil.UserError{Err: fmt.Sprintf(
"could not fetch the CA certificate (was one set?): %s", caErr)}
case errutil.InternalError:
return nil, errutil.InternalError{Err: fmt.Sprintf(
"error fetching CA certificate: %s", caErr)}
}
if caErr != nil {
return nil, errutil.UserError{Err: fmt.Sprintf(
"==== HACK ==== : fetchCAInfo(ctx, req): %s", caErr)}
}

bundle, err := signingBundle.ToCertBundle()
if err != nil {
return nil, errutil.UserError{Err: fmt.Sprintf(
"==== HACK ==== : could not convert to PEM bundle: %s", err)}
}

bytes, err := json.Marshal(bundle)
if err != nil {
return nil, errutil.UserError{Err: fmt.Sprintf(
"==== HACK ==== : json.Marshal(bundle): %s", err)}
}

var respData map[string]interface{}
err = json.Unmarshal(bytes, &respData)
if err != nil {
return nil, errutil.UserError{Err: fmt.Sprintf(
"==== HACK ==== : json.Unmarshal(bytes, respData): %s", err)}
}

resp := &logical.Response{
Data: respData,
}
return resp, nil
}

// pathIssue issues a certificate and private key from given parameters,
// subject to role restrictions
func (b *backend) pathIssue(ctx context.Context, req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
Expand Down