Add back auth.PrivateKey

This commit is contained in:
Ben Toogood 2020-04-01 17:17:40 +01:00
parent 365dfe9df5
commit d577c32563
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,8 @@ type Options struct {
Token *Token Token *Token
// PublicKey for decoding JWTs // PublicKey for decoding JWTs
PublicKey string PublicKey string
// PrivateKey for encoding JWTs
PrivateKey string
// Provider is an auth provider // Provider is an auth provider
Provider provider.Provider Provider provider.Provider
// LoginURL is the relative url path where a user can login // LoginURL is the relative url path where a user can login
@ -40,6 +42,13 @@ func PublicKey(key string) Option {
} }
} }
// PrivateKey is the JWT private key
func PrivateKey(key string) Option {
return func(o *Options) {
o.PrivateKey = key
}
}
// Credentials sets the auth credentials // Credentials sets the auth credentials
func Credentials(id, secret string) Option { func Credentials(id, secret string) Option {
return func(o *Options) { return func(o *Options) {

View File

@ -670,6 +670,9 @@ func (c *cmd) Before(ctx *cli.Context) error {
if len(ctx.String("auth_public_key")) > 0 { if len(ctx.String("auth_public_key")) > 0 {
authOpts = append(authOpts, auth.PublicKey(ctx.String("auth_public_key"))) authOpts = append(authOpts, auth.PublicKey(ctx.String("auth_public_key")))
} }
if len(ctx.String("auth_private_key")) > 0 {
authOpts = append(authOpts, auth.PrivateKey(ctx.String("auth_private_key")))
}
if name := ctx.String("auth_provider"); len(name) > 0 { if name := ctx.String("auth_provider"); len(name) > 0 {
p, ok := DefaultAuthProviders[name] p, ok := DefaultAuthProviders[name]