package storage import ( "context" "fmt" "time" "git.faercol.me/faercol/polyculeconnect/polyculeconnect/internal/db" "github.com/go-jose/go-jose/v4" "github.com/zitadel/oidc/v3/pkg/oidc" "github.com/zitadel/oidc/v3/pkg/op" ) func ErrNotImplemented(name string) error { return fmt.Errorf("%s is not implemented", name) } // Storage implements the Storage interface from zitadel/oidc/op type Storage struct { LocalStorage db.ClientDB } /* Auth storage interface */ func (s *Storage) CreateAuthRequest(ctx context.Context, req *oidc.AuthRequest, userID string) (op.AuthRequest, error) { return nil, ErrNotImplemented("CreateAuthRequest") } func (s *Storage) AuthRequestByID(ctx context.Context, requestID string) (op.AuthRequest, error) { return nil, ErrNotImplemented("AuthRequestByID") } func (s *Storage) AuthRequestByCode(ctx context.Context, requestCode string) (op.AuthRequest, error) { return nil, ErrNotImplemented("AuthRequestByCode") } func (s *Storage) SaveAuthCode(ctx context.Context, id string, code string) error { return ErrNotImplemented("SaveAuthCode") } func (s *Storage) DeleteAuthRequest(ctx context.Context, id string) error { return ErrNotImplemented("DeleteAuthRequest") } func (s *Storage) CreateAccessToken(ctx context.Context, req op.TokenRequest) (accessTokenID string, expiration time.Time, err error) { return "", time.Time{}, ErrNotImplemented("CreateAccessToken") } func (s *Storage) CreateAccessAndRefreshTokens(ctx context.Context, request op.TokenRequest, currentRefreshToken string) (accessTokenID string, newRefreshTokenID string, expiration time.Time, err error) { return "", "", time.Time{}, ErrNotImplemented("CreateAccessAndRefreshTokens") } func (s *Storage) TokenRequestByRefreshToken(ctx context.Context, refreshTokenID string) (op.RefreshTokenRequest, error) { return nil, ErrNotImplemented("TokenRequestByRefreshToken") } func (s *Storage) TerminateSession(ctx context.Context, userID string, clientID string) error { return ErrNotImplemented("TerminateSession") } func (s *Storage) RevokeToken(ctx context.Context, tokenOrTokenID string, userID string, clientID string) *oidc.Error { return nil } func (s *Storage) GetRefreshTokenInfo(ctx context.Context, clientID string, stoken string) (string, string, error) { return "", "", ErrNotImplemented("GetRefreshTokenInfo") } func (s *Storage) SigningKey(ctx context.Context) (op.SigningKey, error) { return nil, ErrNotImplemented("SigningKey") } func (s *Storage) SignatureAlgorithms(ctx context.Context) ([]jose.SignatureAlgorithm, error) { return nil, ErrNotImplemented("SignatureAlgorithms") } func (s *Storage) KeySet(ctx context.Context) ([]op.Key, error) { return nil, ErrNotImplemented("KeySet") } /* OP storage */ func (s *Storage) GetClientByClientID(ctx context.Context, clientID string) (op.Client, error) { clt, err := s.LocalStorage.GetClientByID(ctx, clientID) if err != nil { return nil, fmt.Errorf("failed to get client from local storage: %w", err) } return clt, nil } func (s *Storage) AuthorizeClientIDSecret(ctx context.Context, clientID, clientSecret string) error { return ErrNotImplemented("AuthorizeClientIDSecret") } func (s *Storage) SetUserinfoFromScopes(ctx context.Context, userinfo *oidc.UserInfo, userID, clientID string, scopes []string) error { return ErrNotImplemented("SetUserinfoFromScopes") } func (s *Storage) SetUserinfoFromToken(ctx context.Context, userinfo *oidc.UserInfo, tokenID, subject, origin string) error { return ErrNotImplemented("SetUserinfoFromToken") } func (s *Storage) SetIntrospectionFromToken(ctx context.Context, userinfo *oidc.IntrospectionResponse, tokenID, subject, clientID string) error { return ErrNotImplemented("SetIntrospectionFromToken") } func (s *Storage) GetPrivateClaimsFromScopes(ctx context.Context, userID, clientID string, scopes []string) (map[string]interface{}, error) { return nil, ErrNotImplemented("GetPrivateClaimsFromScopes") } func (s *Storage) GetKeyByIDAndClientID(ctx context.Context, keyID, clientID string) (*jose.JSONWebKey, error) { return nil, ErrNotImplemented("GetKeyByIDAndClientID") } func (s *Storage) ValidateJWTProfileScopes(ctx context.Context, userID string, scopes []string) ([]string, error) { return nil, ErrNotImplemented("ValidateJWTProfileScopes") } func (s *Storage) Health(ctx context.Context) error { return ErrNotImplemented("Health") }