b20047b3eb
* feat(plugins): add auth capability for plugin-provided OIDC/SAML login Plugins can now authenticate a visitor against an external IdP (OIDC/SAML) and contribute a login button to the pre-auth screen: - new `auth` manifest capability + a capability-gated X-Kandev-Auth-Login webhook-response directive; the host mints the kandev_session (ADR 0050), the plugin never receives the raw token. Plugin-set Set-Cookie is dropped. - auth.Service.AuthenticateExternal: existing-identity / link-by-email / JIT member provisioning; refuses to auto-link to an admin; verified-email is the plugin's contract. - auth_providers manifest block + plugins.SSOProviders() populate the anonymous boot payload (auth.ssoProviders); the login page renders a "Continue with <provider>" button per provider. - ADR 0050 + plugin-manifest / plugin-authoring / auth spec docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: exclude publish_review_findings_kandev from public-docs coverage The native code-review agent (#1957) added the publish_review_findings_kandev MCP tool but did not update docs/public/coverage.json; that PR did not touch docs/public so the path-filtered validator never ran. It's an internal review reporting tool, not a user-facing feature, so record it as an exclusion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(plugins,auth): address review on SSO directive and JIT provisioning - takeAuthLoginDirective strips every case variant of X-Kandev-Auth-Login and rejects (403) when a plugin sends more than one, so no variant leaks to the browser and login never uses a nondeterministically-picked assertion. - provisionExternalUser rolls back the just-created user when the identity insert fails (transient error or a lost UNIQUE(provider,subject) race) and resolves to the winning identity, so no account is left without a login and no email is reserved by an unusable row. Adds userstore.DeleteUser. - auth spec: mark the login-page SSO buttons + provider discovery as landed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs: drop redundant coverage exclusion; main now covers publish_review_findings_kandev Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Kandev Agent <agent@kandev.dev> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.7 KiB
Go
37 lines
1.7 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kandev/kandev/internal/user/models"
|
|
)
|
|
|
|
type Repository interface {
|
|
GetUser(ctx context.Context, id string) (*models.User, error)
|
|
GetDefaultUser(ctx context.Context) (*models.User, error)
|
|
GetUserSettings(ctx context.Context, userID string) (*models.UserSettings, error)
|
|
UpsertUserSettingsPreservingTaskCreateLastUsed(ctx context.Context, settings *models.UserSettings, patch *models.TaskCreateLastUsed) (*models.UserSettings, error)
|
|
UpdateTaskCreateLastUsed(ctx context.Context, userID string, patch models.TaskCreateLastUsed) (*models.UserSettings, error)
|
|
Close() error
|
|
}
|
|
|
|
// AccountRepository is the account-management surface consumed by
|
|
// internal/auth. It is intentionally separate from Repository so existing
|
|
// Repository fakes/tests are unaffected by the auth feature; *sqliteRepository
|
|
// implements both.
|
|
type AccountRepository interface {
|
|
GetUser(ctx context.Context, id string) (*models.User, error)
|
|
GetUserByEmail(ctx context.Context, email string) (*models.User, error)
|
|
ListUsers(ctx context.Context) ([]*models.User, error)
|
|
CreateUser(ctx context.Context, user *models.User) error
|
|
UpdateUserProfile(ctx context.Context, id, email, displayName, role string) (*models.User, error)
|
|
UpdateUserRoleStatus(ctx context.Context, id, role, status string) (*models.User, error)
|
|
// DeleteUser removes a user row by id. Used to roll back a just-created
|
|
// account when a follow-up step (e.g. linking its login identity) fails, so
|
|
// no account is left without a usable login. Deleting a missing id is not an
|
|
// error.
|
|
DeleteUser(ctx context.Context, id string) error
|
|
}
|
|
|
|
var _ AccountRepository = (*sqliteRepository)(nil)
|