Skip to content

Commit

Permalink
Add display attributes for OpenAPI OperationID's (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
averche committed Apr 17, 2023
1 parent 960db91 commit 79494c6
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 20 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
IMPROVEMENTS:

* Description [[GH-XXX](https://github.com/hashicorp/vault-plugin-auth-gcp)]
* enable plugin multiplexing [GH-164](https://github.com/hashicorp/vault-plugin-auth-gcp/pull/164)
* Enable plugin multiplexing [[GH-164](https://github.com/hashicorp/vault-plugin-auth-gcp/pull/164)]
* Add display attributes for OpenAPI OperationID's [[GH-172](https://github.com/hashicorp/vault-plugin-auth-gcp/pull/172)]
* update dependencies
* `github.com/hashicorp/vault/api` v1.9.0
* `github.com/hashicorp/vault/sdk` v0.8.1
* `github.com/hashicorp/vault/api` v1.9.0 [[GH-164](https://github.com/hashicorp/vault-plugin-auth-gcp/pull/164)]
* `github.com/hashicorp/vault/sdk` v0.9.0 [[GH-172](https://github.com/hashicorp/vault-plugin-auth-gcp/pull/172)]

BUG FIXES:

Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/vault/api v1.9.0
github.com/hashicorp/vault/sdk v0.8.1
github.com/hashicorp/vault/sdk v0.9.0
github.com/stretchr/testify v1.8.1
golang.org/x/oauth2 v0.4.0
google.golang.org/api v0.109.0
Expand All @@ -36,7 +36,7 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0 // indirect
github.com/hashicorp/go-kms-wrapping/v2 v2.0.7 // indirect
github.com/hashicorp/go-kms-wrapping/v2 v2.0.8 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.5 // indirect
github.com/hashicorp/go-retryablehttp v0.6.6 // indirect
Expand All @@ -61,8 +61,8 @@ require (
github.com/ryanuber/go-glob v1.0.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.6.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0 h1:pSjQfW3vPtrOTcasTUKgCTQT7OGPPTTMVRrOfU6FJD8=
github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0/go.mod h1:xvb32K2keAc+R8DSFG2IwDcydK9DBQE+fGA5fsw6hSk=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.7 h1:P+dh3M6k5aNl2wXrA9s6zquMHWPaYIkotCffiMIYt6U=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.7/go.mod h1:sDQAfwJGv25uGPZA04x87ERglCG6avnRcBT9wYoMII8=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.8 h1:9Q2lu1YbbmiAgvYZ7Pr31RdlVonUpX+mmDL7Z7qTA2U=
github.com/hashicorp/go-kms-wrapping/v2 v2.0.8/go.mod h1:qTCjxGig/kjuj3hk1z8pOUrzbse/GxB1tGfbrq8tGJg=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
Expand Down Expand Up @@ -136,8 +136,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/vault/api v1.9.0 h1:ab7dI6W8DuCY7yCU8blo0UCYl2oHre/dloCmzMWg9w8=
github.com/hashicorp/vault/api v1.9.0/go.mod h1:lloELQP4EyhjnCQhF8agKvWIVTmxbpEJj70b98959sM=
github.com/hashicorp/vault/sdk v0.8.1 h1:bdlhIpxBmJuOZ5Anumao1xeiLocR2eQrBRuJynZfTac=
github.com/hashicorp/vault/sdk v0.8.1/go.mod h1:kEpyfUU2ECGWf6XohKVFzvJ97ybSnXvxsTsBkbeVcQg=
github.com/hashicorp/vault/sdk v0.9.0 h1:Cbu9ezaZafZTXnen98QKVmufEPquhZ+r1ORZ7csNLFU=
github.com/hashicorp/vault/sdk v0.9.0/go.mod h1:VX9d+xF62YBNtiEc4l3Z2aea9HVtAS49EoniuXzHtC4=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
Expand Down Expand Up @@ -234,8 +234,8 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand All @@ -252,8 +252,8 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.6.0 h1:L4ZwwTvKW9gr0ZMS1yrHD9GZhIuVjOBBnaKH+SPQK0Q=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
Expand Down
7 changes: 6 additions & 1 deletion plugin/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ import (
"google.golang.org/api/option"
)

const userAgentPluginName = "auth-gcp"
const (
userAgentPluginName = "auth-gcp"

// operationPrefixGoogleCloud is used as a prefix for OpenAPI operation id's.
operationPrefixGoogleCloud = "google-cloud"
)

// cacheTime is the duration for which to cache clients and credentials. This
// must be less than 60 minutes.
Expand Down
24 changes: 21 additions & 3 deletions plugin/path_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ var (
func pathConfig(b *GcpAuthBackend) *framework.Path {
return &framework.Path{
Pattern: "config",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
},

Fields: map[string]*framework.FieldSchema{
"credentials": {
Type: framework.TypeString,
Expand Down Expand Up @@ -85,9 +90,22 @@ Deprecated. This field does nothing and be removed in a future release`,
Deprecated: true,
},
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ReadOperation: b.pathConfigRead,
logical.UpdateOperation: b.pathConfigWrite,

Operations: map[logical.Operation]framework.OperationHandler{
logical.ReadOperation: &framework.PathOperation{
Callback: b.pathConfigRead,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "read",
OperationSuffix: "auth-configuration",
},
},
logical.UpdateOperation: &framework.PathOperation{
Callback: b.pathConfigWrite,
DisplayAttrs: &framework.DisplayAttributes{
OperationVerb: "configure",
OperationSuffix: "auth",
},
},
},

HelpSynopsis: `Configure credentials used to query the GCP IAM API to verify authenticating service accounts`,
Expand Down
6 changes: 6 additions & 0 deletions plugin/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const (
func pathLogin(b *GcpAuthBackend) *framework.Path {
return &framework.Path{
Pattern: "login$",

DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
OperationVerb: "login",
},

Fields: map[string]*framework.FieldSchema{
"role": {
Type: framework.TypeString,
Expand Down
26 changes: 25 additions & 1 deletion plugin/path_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ func pathsRole(b *GcpAuthBackend) []*framework.Path {

paths := []*framework.Path{
{
Pattern: fmt.Sprintf("role/%s", framework.GenericNameRegex("name")),
Pattern: fmt.Sprintf("role/%s", framework.GenericNameRegex("name")),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
OperationSuffix: "role",
},
Fields: roleFieldSchema,
ExistenceCheck: b.pathRoleExistenceCheck,
Callbacks: map[logical.Operation]framework.OperationFunc{
Expand All @@ -173,6 +177,11 @@ func pathsRole(b *GcpAuthBackend) []*framework.Path {
// Paths for listing roles
{
Pattern: "role/?",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
OperationVerb: "list",
OperationSuffix: "roles",
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: b.pathRoleList,
},
Expand All @@ -182,6 +191,11 @@ func pathsRole(b *GcpAuthBackend) []*framework.Path {
},
{
Pattern: "roles/?",
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
OperationVerb: "list",
OperationSuffix: "roles2",
},
Callbacks: map[logical.Operation]framework.OperationFunc{
logical.ListOperation: b.pathRoleList,
},
Expand All @@ -193,6 +207,11 @@ func pathsRole(b *GcpAuthBackend) []*framework.Path {
// Edit service accounts on an IAM role
{
Pattern: fmt.Sprintf("role/%s/service-accounts", framework.GenericNameRegex("name")),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
OperationVerb: "edit",
OperationSuffix: "service-accounts-for-role",
},
Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
Expand All @@ -217,6 +236,11 @@ func pathsRole(b *GcpAuthBackend) []*framework.Path {
// Edit labels on an GCE role
{
Pattern: fmt.Sprintf("role/%s/labels", framework.GenericNameRegex("name")),
DisplayAttrs: &framework.DisplayAttributes{
OperationPrefix: operationPrefixGoogleCloud,
OperationVerb: "edit",
OperationSuffix: "labels-for-role",
},
Fields: map[string]*framework.FieldSchema{
"name": {
Type: framework.TypeString,
Expand Down

0 comments on commit 79494c6

Please sign in to comment.