This repository has been archived by the owner on Feb 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from secrethub/release/v0.31.0
Release v0.31.0
- Loading branch information
Showing
15 changed files
with
287 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package credentials | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
httpclient "github.com/secrethub/secrethub-go/pkg/secrethub/internals/http" | ||
|
||
"github.com/secrethub/secrethub-go/internals/auth" | ||
) | ||
|
||
type SetupCode struct { | ||
code string | ||
} | ||
|
||
// Provide implements the Provider interface for the setup code. | ||
// Note that no decrypter is ever returned as setup codes cannot be used to decrypt secrets. | ||
func (s *SetupCode) Provide(client *httpclient.Client) (auth.Authenticator, Decrypter, error) { | ||
return s, nil, nil | ||
} | ||
|
||
func NewSetupCode(code string) *SetupCode { | ||
return &SetupCode{ | ||
code: code, | ||
} | ||
} | ||
|
||
// Authenticate authenticates the given request with a setup code, by providing the "SetupCode" tag and the setup code | ||
// in the "Authorization" header. | ||
func (s *SetupCode) Authenticate(r *http.Request) error { | ||
r.Header.Set("Authorization", fmt.Sprintf("%s-%s %s", auth.AuthHeaderVersionV1, "SetupCode", s.code)) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package fakeclient | ||
|
||
import ( | ||
"github.com/secrethub/secrethub-go/internals/api" | ||
"github.com/secrethub/secrethub-go/pkg/secrethub" | ||
"github.com/secrethub/secrethub-go/pkg/secrethub/credentials" | ||
"github.com/secrethub/secrethub-go/pkg/secrethub/iterator" | ||
) | ||
|
||
type CredentialService struct { | ||
CreateFunc func(credentials.Creator, string) (*api.Credential, error) | ||
DisableFunc func(fingerprint string) error | ||
ListFunc func(_ *secrethub.CredentialListParams) secrethub.CredentialIterator | ||
} | ||
|
||
func (c *CredentialService) Create(creator credentials.Creator, description string) (*api.Credential, error) { | ||
return c.CreateFunc(creator, description) | ||
} | ||
|
||
func (c *CredentialService) Disable(fingerprint string) error { | ||
return c.DisableFunc(fingerprint) | ||
} | ||
|
||
func (c *CredentialService) List(credentialListParams *secrethub.CredentialListParams) secrethub.CredentialIterator { | ||
return c.ListFunc(credentialListParams) | ||
} | ||
|
||
type CredentialIterator struct { | ||
Credentials []*api.Credential | ||
CurrentIndex int | ||
Err error | ||
} | ||
|
||
func (c *CredentialIterator) Next() (api.Credential, error) { | ||
if c.Err != nil { | ||
return api.Credential{}, c.Err | ||
} | ||
|
||
currentIndex := c.CurrentIndex | ||
if currentIndex >= len(c.Credentials) { | ||
return api.Credential{}, iterator.Done | ||
} | ||
c.CurrentIndex++ | ||
return *c.Credentials[currentIndex], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package fakeclient | ||
|
||
import ( | ||
"github.com/secrethub/secrethub-go/internals/api" | ||
"github.com/secrethub/secrethub-go/internals/oauthorizer" | ||
"github.com/secrethub/secrethub-go/pkg/secrethub" | ||
"github.com/secrethub/secrethub-go/pkg/secrethub/iterator" | ||
) | ||
|
||
type IDPLinkService struct { | ||
GCPService secrethub.IDPLinkGCPService | ||
} | ||
|
||
func (i IDPLinkService) GCP() secrethub.IDPLinkGCPService { | ||
return i.GCPService | ||
} | ||
|
||
type IDPLinkGCPService struct { | ||
CreateFunc func(namespace string, projectID string, authorizationCode string, redirectURI string) (*api.IdentityProviderLink, error) | ||
ListFunc func(namespace string, params *secrethub.IdpLinkIteratorParams) secrethub.IdpLinkIterator | ||
GetFunc func(namespace string, projectID string) (*api.IdentityProviderLink, error) | ||
ExistsFunc func(namespace string, projectID string) (bool, error) | ||
DeleteFunc func(namespace string, projectID string) error | ||
AuthorizationCodeListenerFunc func(namespace string, projectID string) (oauthorizer.CallbackHandler, error) | ||
} | ||
|
||
func (i IDPLinkGCPService) Create(namespace string, projectID string, authorizationCode, redirectURI string) (*api.IdentityProviderLink, error) { | ||
return i.CreateFunc(namespace, projectID, authorizationCode, redirectURI) | ||
} | ||
|
||
func (i IDPLinkGCPService) List(namespace string, params *secrethub.IdpLinkIteratorParams) secrethub.IdpLinkIterator { | ||
return i.ListFunc(namespace, params) | ||
} | ||
|
||
func (i IDPLinkGCPService) Get(namespace string, projectID string) (*api.IdentityProviderLink, error) { | ||
return i.GetFunc(namespace, projectID) | ||
} | ||
|
||
func (i IDPLinkGCPService) Exists(namespace string, projectID string) (bool, error) { | ||
return i.ExistsFunc(namespace, projectID) | ||
} | ||
|
||
func (i IDPLinkGCPService) Delete(namespace string, projectID string) error { | ||
return i.DeleteFunc(namespace, projectID) | ||
} | ||
|
||
func (i IDPLinkGCPService) AuthorizationCodeListener(namespace string, projectID string) (oauthorizer.CallbackHandler, error) { | ||
return i.AuthorizationCodeListenerFunc(namespace, projectID) | ||
} | ||
|
||
type IDPLinkIterator struct { | ||
IDPLinks []*api.IdentityProviderLink | ||
CurrentIndex int | ||
Err error | ||
} | ||
|
||
func (c *IDPLinkIterator) Next() (api.IdentityProviderLink, error) { | ||
if c.Err != nil { | ||
return api.IdentityProviderLink{}, c.Err | ||
} | ||
|
||
currentIndex := c.CurrentIndex | ||
if currentIndex >= len(c.IDPLinks) { | ||
return api.IdentityProviderLink{}, iterator.Done | ||
} | ||
c.CurrentIndex++ | ||
return *c.IDPLinks[currentIndex], nil | ||
} |
Oops, something went wrong.