f6ded84f07
- When the upstream IDP is an LDAP IDP and the user's LDAP username and password are received as new custom headers, then authenticate the user and, if authentication was successful, return a redirect with an authcode. Handle errors according to the OAuth/OIDC specs. - Still does not support having multiple upstream IDPs defined at the same time, which was an existing limitation of this endpoint. - Does not yet include the actual LDAP authentication, which is hidden behind an interface from the point of view of auth_handler.go - Move the oidctestutil package to the testutil directory. - Add an interface for Fosite storage to avoid a cyclical test dependency. - Add GetURL() to the UpstreamLDAPIdentityProviderI interface. - Extract test helpers to be shared between callback_handler_test.go and auth_handler_test.go because the authcode and fosite storage assertions should be identical. - Backfill Content-Type assertions in callback_handler_test.go. Signed-off-by: Andrew Keesler <akeesler@vmware.com>
105 lines
3.2 KiB
Go
105 lines
3.2 KiB
Go
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package oidc
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/ory/fosite"
|
|
|
|
"go.pinniped.dev/internal/constable"
|
|
"go.pinniped.dev/internal/fositestoragei"
|
|
)
|
|
|
|
const errNullStorageNotImplemented = constable.Error("NullStorage does not implement this method. It should not have been called.")
|
|
|
|
type NullStorage struct{}
|
|
|
|
var _ fositestoragei.AllFositeStorage = &NullStorage{}
|
|
|
|
func (NullStorage) RevokeRefreshToken(_ context.Context, _ string) error {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) RevokeAccessToken(_ context.Context, _ string) error {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) CreateRefreshTokenSession(_ context.Context, _ string, _ fosite.Requester) (err error) {
|
|
return nil
|
|
}
|
|
|
|
func (NullStorage) GetRefreshTokenSession(_ context.Context, _ string, _ fosite.Session) (request fosite.Requester, err error) {
|
|
return nil, errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) DeleteRefreshTokenSession(_ context.Context, _ string) (err error) {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) CreateAccessTokenSession(_ context.Context, _ string, _ fosite.Requester) (err error) {
|
|
return nil
|
|
}
|
|
|
|
func (NullStorage) GetAccessTokenSession(_ context.Context, _ string, _ fosite.Session) (request fosite.Requester, err error) {
|
|
return nil, errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) DeleteAccessTokenSession(_ context.Context, _ string) (err error) {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) CreateOpenIDConnectSession(_ context.Context, _ string, _ fosite.Requester) error {
|
|
return nil
|
|
}
|
|
|
|
func (NullStorage) GetOpenIDConnectSession(_ context.Context, _ string, _ fosite.Requester) (fosite.Requester, error) {
|
|
return nil, errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) DeleteOpenIDConnectSession(_ context.Context, _ string) error {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) GetPKCERequestSession(_ context.Context, _ string, _ fosite.Session) (fosite.Requester, error) {
|
|
return nil, errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) CreatePKCERequestSession(_ context.Context, _ string, _ fosite.Requester) error {
|
|
return nil
|
|
}
|
|
|
|
func (NullStorage) DeletePKCERequestSession(_ context.Context, _ string) error {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) CreateAuthorizeCodeSession(_ context.Context, _ string, _ fosite.Requester) (err error) {
|
|
return nil
|
|
}
|
|
|
|
func (NullStorage) GetAuthorizeCodeSession(_ context.Context, _ string, _ fosite.Session) (request fosite.Requester, err error) {
|
|
return nil, errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) InvalidateAuthorizeCodeSession(_ context.Context, _ string) (err error) {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) GetClient(_ context.Context, id string) (fosite.Client, error) {
|
|
client := PinnipedCLIOIDCClient()
|
|
if client.ID == id {
|
|
return client, nil
|
|
}
|
|
return nil, fosite.ErrNotFound
|
|
}
|
|
|
|
func (NullStorage) ClientAssertionJWTValid(_ context.Context, _ string) error {
|
|
return errNullStorageNotImplemented
|
|
}
|
|
|
|
func (NullStorage) SetClientAssertionJWT(_ context.Context, _ string, _ time.Time) error {
|
|
return errNullStorageNotImplemented
|
|
}
|