[#524] cli: Add impersonate flag for bearer token creation
All checks were successful
Build / Build Components (1.20) (pull_request) Successful in 3m54s
Build / Build Components (1.19) (pull_request) Successful in 4m8s
ci/woodpecker/pr/pre-commit Pipeline was successful
Tests and linters / Tests (1.20) (pull_request) Successful in 6m12s
Tests and linters / Lint (pull_request) Successful in 11m30s
Tests and linters / Tests with -race (pull_request) Successful in 8m20s
Tests and linters / Staticcheck (pull_request) Successful in 4m24s
Tests and linters / Tests (1.19) (pull_request) Successful in 19m1s
All checks were successful
Build / Build Components (1.20) (pull_request) Successful in 3m54s
Build / Build Components (1.19) (pull_request) Successful in 4m8s
ci/woodpecker/pr/pre-commit Pipeline was successful
Tests and linters / Tests (1.20) (pull_request) Successful in 6m12s
Tests and linters / Lint (pull_request) Successful in 11m30s
Tests and linters / Tests with -race (pull_request) Successful in 8m20s
Tests and linters / Staticcheck (pull_request) Successful in 4m24s
Tests and linters / Tests (1.19) (pull_request) Successful in 19m1s
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
parent
8a9fc2c372
commit
ec8a44f73c
1 changed files with 8 additions and 1 deletions
|
@ -24,6 +24,7 @@ const (
|
||||||
ownerFlag = "owner"
|
ownerFlag = "owner"
|
||||||
outFlag = "out"
|
outFlag = "out"
|
||||||
jsonFlag = commonflags.JSON
|
jsonFlag = commonflags.JSON
|
||||||
|
impersonateFlag = "impersonate"
|
||||||
)
|
)
|
||||||
|
|
||||||
var createCmd = &cobra.Command{
|
var createCmd = &cobra.Command{
|
||||||
|
@ -39,15 +40,18 @@ is set to current epoch + n.
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
createCmd.Flags().StringP(eaclFlag, "e", "", "Path to the extended ACL table")
|
createCmd.Flags().StringP(eaclFlag, "e", "", "Path to the extended ACL table (mutually exclusive with --impersonate flag)")
|
||||||
createCmd.Flags().StringP(issuedAtFlag, "i", "", "Epoch to issue token at")
|
createCmd.Flags().StringP(issuedAtFlag, "i", "", "Epoch to issue token at")
|
||||||
createCmd.Flags().StringP(notValidBeforeFlag, "n", "", "Not valid before epoch")
|
createCmd.Flags().StringP(notValidBeforeFlag, "n", "", "Not valid before epoch")
|
||||||
createCmd.Flags().StringP(commonflags.ExpireAt, "x", "", "The last active epoch for the token")
|
createCmd.Flags().StringP(commonflags.ExpireAt, "x", "", "The last active epoch for the token")
|
||||||
createCmd.Flags().StringP(ownerFlag, "o", "", "Token owner")
|
createCmd.Flags().StringP(ownerFlag, "o", "", "Token owner")
|
||||||
createCmd.Flags().String(outFlag, "", "File to write token to")
|
createCmd.Flags().String(outFlag, "", "File to write token to")
|
||||||
createCmd.Flags().Bool(jsonFlag, false, "Output token in JSON")
|
createCmd.Flags().Bool(jsonFlag, false, "Output token in JSON")
|
||||||
|
createCmd.Flags().Bool(impersonateFlag, false, "Mark token as impersonate to consider the token signer as the request owner (mutually exclusive with --eacl flag)")
|
||||||
createCmd.Flags().StringP(commonflags.RPC, commonflags.RPCShorthand, commonflags.RPCDefault, commonflags.RPCUsage)
|
createCmd.Flags().StringP(commonflags.RPC, commonflags.RPCShorthand, commonflags.RPCDefault, commonflags.RPCUsage)
|
||||||
|
|
||||||
|
createCmd.MarkFlagsMutuallyExclusive(eaclFlag, impersonateFlag)
|
||||||
|
|
||||||
_ = cobra.MarkFlagFilename(createCmd.Flags(), eaclFlag)
|
_ = cobra.MarkFlagFilename(createCmd.Flags(), eaclFlag)
|
||||||
|
|
||||||
_ = cobra.MarkFlagRequired(createCmd.Flags(), issuedAtFlag)
|
_ = cobra.MarkFlagRequired(createCmd.Flags(), issuedAtFlag)
|
||||||
|
@ -101,6 +105,9 @@ func createToken(cmd *cobra.Command, _ []string) {
|
||||||
b.SetIat(iat)
|
b.SetIat(iat)
|
||||||
b.ForUser(ownerID)
|
b.ForUser(ownerID)
|
||||||
|
|
||||||
|
impersonate, _ := cmd.Flags().GetBool(impersonateFlag)
|
||||||
|
b.SetImpersonate(impersonate)
|
||||||
|
|
||||||
eaclPath, _ := cmd.Flags().GetString(eaclFlag)
|
eaclPath, _ := cmd.Flags().GetString(eaclFlag)
|
||||||
if eaclPath != "" {
|
if eaclPath != "" {
|
||||||
table := eaclSDK.NewTable()
|
table := eaclSDK.NewTable()
|
||||||
|
|
Loading…
Reference in a new issue