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

Use origin default key loc for cli token creation #620

Merged
merged 1 commit into from
Jan 8, 2024
Merged
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
13 changes: 12 additions & 1 deletion cmd/origin_token.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package main

import (
"context"
"fmt"
"strings"
"time"

"github.com/pelicanplatform/pelican/utils"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/pelicanplatform/pelican/config"
"github.com/pelicanplatform/pelican/utils"
)

// Take an input slice and append its claim name
Expand Down Expand Up @@ -64,6 +67,14 @@ func parseClaimsToTokenConfig(claims []string) (*utils.TokenConfig, error) {
}

func cliTokenCreate(cmd *cobra.Command, args []string) error {
// Although we don't actually run any server stuff, we need access to the Origin's configuration
// to know where private keys live for token signing, so we still need to call InitServer()
ctx := context.Background()
err := config.InitServer(ctx, config.OriginType)
if err != nil {
return errors.Wrap(err, "Cannot create token, failed to initialize configuration")
}

// Additional claims can be passed via the --claims flag, or
// they can be passed as args. We join those two slices here
claimsSlice, err := cmd.Flags().GetStringSlice("claim")
Expand Down
Loading