mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-04-27 03:25:38 +00:00
WIP towards revoking upstream refresh tokens during GC
- Discover the revocation endpoint of the upstream provider in oidc_upstream_watcher.go and save it into the cache for future use by the garbage collector controller - Adds RevokeRefreshToken to UpstreamOIDCIdentityProviderI - Implements the production version of RevokeRefreshToken - Implements test doubles for RevokeRefreshToken for future use in garbage collector's unit tests - Prefactors the crud and session storage types for future use in the garbage collector controller - See remaining TODOs in garbage_collector.go
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/ory/fosite"
|
||||
"github.com/ory/fosite/handler/oauth2"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
|
||||
@@ -48,6 +49,23 @@ func New(secrets corev1client.SecretInterface, clock func() time.Time, sessionSt
|
||||
return &authorizeCodeStorage{storage: crud.New(TypeLabelValue, secrets, clock, sessionStorageLifetime)}
|
||||
}
|
||||
|
||||
// ReadFromSecret reads the contents of a Secret as an AuthorizeCodeSession.
|
||||
func ReadFromSecret(secret *v1.Secret) (*AuthorizeCodeSession, error) {
|
||||
session := NewValidEmptyAuthorizeCodeSession()
|
||||
err := crud.FromSecret(TypeLabelValue, secret, session)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if session.Version != authorizeCodeStorageVersion {
|
||||
return nil, fmt.Errorf("%w: authorization code session has version %s instead of %s",
|
||||
ErrInvalidAuthorizeRequestVersion, session.Version, authorizeCodeStorageVersion)
|
||||
}
|
||||
if session.Request.ID == "" {
|
||||
return nil, fmt.Errorf("malformed authorization code session: %w", ErrInvalidAuthorizeRequestData)
|
||||
}
|
||||
return session, nil
|
||||
}
|
||||
|
||||
func (a *authorizeCodeStorage) CreateAuthorizeCodeSession(ctx context.Context, signature string, requester fosite.Requester) error {
|
||||
// This conversion assumes that we do not wrap the default type in any way
|
||||
// i.e. we use the default fosite.OAuth2Provider.NewAuthorizeRequest implementation
|
||||
|
||||
Reference in New Issue
Block a user