Documentation
¶
Overview ¶
Copyright 2025 the k8Shell authors. SPDX-License-Identifier: AGPL-3.0-or-later
Package server implements the main server logic for the k8Shell Identity service. It initializes the server, loads configuration, sets up identity providers, and provides methods for user authentication and management.
Index ¶
- Variables
- type AnnouncementEmailConfig
- type Config
- type IdentityService
- func (s *IdentityService) AddGitUserCredential(ctx context.Context, req *identityv1.AddGitUserCredentialRequest) (*identityv1.AddGitUserCredentialResponse, error)
- func (s *IdentityService) AddKubernetesUserCredential(ctx context.Context, req *identityv1.AddKubernetesUserCredentialRequest) (*identityv1.AddKubernetesUserCredentialResponse, error)
- func (s *IdentityService) AddOrganizationEnvVar(ctx context.Context, req *identityv1.AddOrganizationEnvVarRequest) (*identityv1.EnvVar, error)
- func (s *IdentityService) AddRegistryUserCredential(ctx context.Context, req *identityv1.AddRegistryUserCredentialRequest) (*identityv1.AddRegistryUserCredentialResponse, error)
- func (s *IdentityService) AddRoleBlueprints(ctx context.Context, req *identityv1.RoleBlueprintsRequest) (*identityv1.Role, error)
- func (s *IdentityService) AddUserAuthKeys(ctx context.Context, req *identityv1.UserAuthKeysRequest) (*commonv1.User, error)
- func (s *IdentityService) AddUserEnvVar(ctx context.Context, req *identityv1.AddUserEnvVarRequest) (*identityv1.EnvVar, error)
- func (s *IdentityService) AddUserRoles(ctx context.Context, req *identityv1.UserRolesRequest) (*commonv1.User, error)
- func (s *IdentityService) ApproveOnboardRequest(ctx context.Context, req *identityv1.ApproveOnboardRuleRequest) (*commonv1.User, error)
- func (s *IdentityService) AuthUserPassword(ctx context.Context, req *identityv1.AuthUserPasswordRequest) (*identityv1.AuthUserResponse, error)
- func (s *IdentityService) AuthUserPublicKey(ctx context.Context, req *identityv1.AuthUserPublicKeyRequest) (*identityv1.AuthUserResponse, error)
- func (s *IdentityService) ClearPasswordLockout(ctx context.Context, req *identityv1.Username) (*identityv1.ClearPasswordLockoutResponse, error)
- func (s *IdentityService) CompleteUserDeviceFlow(ctx context.Context, req *identityv1.CompleteUserDeviceFlowRequest) (*identityv1.CompleteUserDeviceFlowResponse, error)
- func (s *IdentityService) CompleteUserWebFlow(ctx context.Context, req *identityv1.CompleteUserWebFlowRequest) (*identityv1.CompleteUserWebFlowResponse, error)
- func (s *IdentityService) ConfirmPasswordReset(ctx context.Context, req *identityv1.ConfirmPasswordResetRequest) (*identityv1.ConfirmPasswordResetResponse, error)
- func (s *IdentityService) CreateAccessToken(ctx context.Context, req *identityv1.CreateAccessTokenRequest) (*identityv1.CreateAccessTokenResponse, error)
- func (s *IdentityService) CreateAnnouncement(_ context.Context, req *identityv1.CreateAnnouncementRequest) (*identityv1.Announcement, error)
- func (s *IdentityService) CreateOnboardRule(ctx context.Context, req *identityv1.CreateOnboardRuleRequest) (*identityv1.OnboardRule, error)
- func (s *IdentityService) CreateOrganization(ctx context.Context, req *identityv1.CreateOrganizationRequest) (*identityv1.Organization, error)
- func (s *IdentityService) CreateRole(ctx context.Context, req *identityv1.CreateRoleRequest) (*identityv1.Role, error)
- func (s *IdentityService) CreateUser(ctx context.Context, req *identityv1.CreateUserRequest) (*commonv1.User, error)
- func (s *IdentityService) DeleteAccessToken(ctx context.Context, req *identityv1.DeleteAccessTokenRequest) (*identityv1.DeleteAccessTokenResponse, error)
- func (s *IdentityService) DeleteAnnouncement(_ context.Context, req *identityv1.DeleteAnnouncementRequest) (*identityv1.DeleteAnnouncementResponse, error)
- func (s *IdentityService) DeleteOnboardRule(ctx context.Context, req *identityv1.DeleteOnboardRuleRequest) (*identityv1.DeleteOnboardRuleResponse, error)
- func (s *IdentityService) DeleteOrganization(ctx context.Context, req *identityv1.DeleteOrganizationRequest) (*identityv1.DeleteOrganizationResponse, error)
- func (s *IdentityService) DeleteOrganizationEnvVar(ctx context.Context, req *identityv1.DeleteOrganizationEnvVarRequest) (*identityv1.DeleteOrganizationEnvVarResponse, error)
- func (s *IdentityService) DeleteRole(ctx context.Context, req *identityv1.DeleteRoleRequest) (*identityv1.DeleteRoleResponse, error)
- func (s *IdentityService) DeleteUser(ctx context.Context, req *identityv1.DeleteUserRequest) (*identityv1.DeleteUserResponse, error)
- func (s *IdentityService) DeleteUserCredential(ctx context.Context, req *identityv1.DeleteUserCredentialRequest) (*identityv1.DeleteUserCredentialResponse, error)
- func (s *IdentityService) DeleteUserEnvVar(ctx context.Context, req *identityv1.DeleteUserEnvVarRequest) (*identityv1.DeleteUserEnvVarResponse, error)
- func (s *IdentityService) FindUser(ctx context.Context, req *identityv1.FindUserRequest) (*commonv1.User, error)
- func (s *IdentityService) GetAnnouncement(_ context.Context, req *identityv1.GetAnnouncementRequest) (*identityv1.Announcement, error)
- func (s *IdentityService) GetAnnouncementsQuerySchema(_ context.Context, _ *identityv1.GetAnnouncementsQuerySchemaRequest) (*queryv1.Descriptor, error)
- func (s *IdentityService) GetAvailableIdentityProviders(ctx context.Context, req *identityv1.GetAvailableIdentityProvidersRequest) (*identityv1.GetAvailableIdentityProvidersResponse, error)
- func (s *IdentityService) GetBlueprintByUserStr(ctx context.Context, req *identityv1.UserStr) (*identityv1.Blueprint, error)
- func (s *IdentityService) GetOnboardRulesQuerySchema(ctx context.Context, req *identityv1.GetOnboardRulesQuerySchemaRequest) (*queryv1.Descriptor, error)
- func (s *IdentityService) GetOrganization(ctx context.Context, req *identityv1.GetOrganizationRequest) (*identityv1.Organization, error)
- func (s *IdentityService) GetOrganizationEnvVar(ctx context.Context, req *identityv1.GetOrganizationEnvVarRequest) (*identityv1.EnvVar, error)
- func (s *IdentityService) GetOrganizationsQuerySchema(ctx context.Context, req *identityv1.GetOrganizationsQuerySchemaRequest) (*queryv1.Descriptor, error)
- func (s *IdentityService) GetPasswordLockoutStatus(ctx context.Context, req *identityv1.Username) (*identityv1.PasswordLockoutStatus, error)
- func (s *IdentityService) GetUserCredential(ctx context.Context, req *identityv1.GetUserCredentialRequest) (*commonv1.UserCredential, error)
- func (s *IdentityService) GetUserEnvVar(ctx context.Context, req *identityv1.GetUserEnvVarRequest) (*identityv1.EnvVar, error)
- func (s *IdentityService) GetUserOnboardCapability(ctx context.Context, req *identityv1.Username) (*commonv1.UserOnboardCapability, error)
- func (s *IdentityService) GetUserSettings(ctx context.Context, req *identityv1.GetUserSettingsRequest) (*identityv1.GetUserSettingsResponse, error)
- func (s *IdentityService) GetUsers(ctx context.Context, req *identityv1.GetUsersRequest) (*identityv1.UserList, error)
- func (s *IdentityService) GetUsersQuerySchema(ctx context.Context, req *identityv1.GetUsersQuerySchemaRequest) (*queryv1.Descriptor, error)
- func (s *IdentityService) GetVersionInfo(_ context.Context, _ *commonv1.GetVersionInfoRequest) (*commonv1.GetVersionInfoResponse, error)
- func (s *IdentityService) IssueUserToken(ctx context.Context, req *identityv1.IssueUserTokenRequest) (*identityv1.IssueUserTokenResponse, error)
- func (s *IdentityService) ListAccessTokens(ctx context.Context, req *identityv1.Username) (*identityv1.ListAccessTokensResponse, error)
- func (s *IdentityService) ListAnnouncements(_ context.Context, req *identityv1.ListAnnouncementsRequest) (*identityv1.AnnouncementList, error)
- func (s *IdentityService) ListGlobalRoles(ctx context.Context, req *identityv1.ListGlobalRolesRequest) (*identityv1.RoleList, error)
- func (s *IdentityService) ListOrganizationEnvVars(ctx context.Context, req *identityv1.ListOrganizationEnvVarsRequest) (*identityv1.EnvVarList, error)
- func (s *IdentityService) ListOrganizations(ctx context.Context, req *identityv1.ListOrganizationsRequest) (*identityv1.OrganizationList, error)
- func (s *IdentityService) ListRepoOwners(ctx context.Context, req *identityv1.Username) (*identityv1.RepoOwnerList, error)
- func (s *IdentityService) ListRepos(ctx context.Context, req *identityv1.ListReposRequest) (*identityv1.RepoList, error)
- func (s *IdentityService) ListRoles(ctx context.Context, req *identityv1.ListRolesRequest) (*identityv1.RoleList, error)
- func (s *IdentityService) ListUnreadAnnouncements(_ context.Context, req *identityv1.ListUnreadAnnouncementsRequest) (*identityv1.AnnouncementList, error)
- func (s *IdentityService) ListUserAnnouncements(_ context.Context, req *identityv1.ListUserAnnouncementsRequest) (*identityv1.AnnouncementList, error)
- func (s *IdentityService) ListUserAuthKeys(ctx context.Context, req *identityv1.ListUserAuthKeysRequest) (*identityv1.ListUserAuthKeysResponse, error)
- func (s *IdentityService) ListUserCredentials(ctx context.Context, req *identityv1.ListUserCredentialsRequest) (*identityv1.ListUserCredentialsResponse, error)
- func (s *IdentityService) ListUserEnvVars(ctx context.Context, req *identityv1.ListUserEnvVarsRequest) (*identityv1.EnvVarList, error)
- func (s *IdentityService) MarkAnnouncementRead(_ context.Context, req *identityv1.MarkAnnouncementReadRequest) (*identityv1.MarkAnnouncementReadResponse, error)
- func (s *IdentityService) OnboardUserDeviceFlow(ctx context.Context, req *identityv1.OnboardUserDeviceFlowRequest) (*commonv1.OnboardUserDeviceFlow, error)
- func (s *IdentityService) OnboardUserWebFlow(ctx context.Context, req *identityv1.OnboardUserWebFlowRequest) (*commonv1.OnboardUserWebFlow, error)
- func (s *IdentityService) PutUserSettings(ctx context.Context, req *identityv1.PutUserSettingsRequest) (*identityv1.PutUserSettingsResponse, error)
- func (s *IdentityService) QueryAnnouncements(_ context.Context, req *identityv1.QueryAnnouncementsRequest) (*identityv1.AnnouncementList, error)
- func (s *IdentityService) QueryOnboardRules(ctx context.Context, req *identityv1.QueryOnboardRulesRequest) (*identityv1.OnboardRuleList, error)
- func (s *IdentityService) QueryOrganizations(ctx context.Context, req *identityv1.QueryOrganizationsRequest) (*identityv1.OrganizationList, error)
- func (s *IdentityService) QueryUsers(ctx context.Context, req *identityv1.QueryUsersRequest) (*identityv1.UserList, error)
- func (s *IdentityService) RejectOnboardRequest(ctx context.Context, req *identityv1.RejectOnboardRuleRequest) (*identityv1.OnboardRule, error)
- func (s *IdentityService) RemoveRoleBlueprints(ctx context.Context, req *identityv1.RoleBlueprintsRequest) (*identityv1.Role, error)
- func (s *IdentityService) RemoveUserAuthKey(ctx context.Context, req *identityv1.RemoveUserAuthKeyRequest) (*commonv1.User, error)
- func (s *IdentityService) RemoveUserCredential(ctx context.Context, req *identityv1.RemoveUserCredentialRequest) (*identityv1.RemoveUserCredentialResponse, error)
- func (s *IdentityService) RemoveUserRoles(ctx context.Context, req *identityv1.UserRolesRequest) (*commonv1.User, error)
- func (s *IdentityService) RequestPasswordReset(ctx context.Context, req *identityv1.RequestPasswordResetRequest) (*identityv1.RequestPasswordResetResponse, error)
- func (s *IdentityService) ResolveAccessToken(ctx context.Context, req *identityv1.ResolveAccessTokenRequest) (*identityv1.ResolveAccessTokenResponse, error)
- func (s *IdentityService) RevokeAccessToken(ctx context.Context, req *identityv1.RevokeAccessTokenRequest) (*identityv1.RevokeAccessTokenResponse, error)
- func (s *IdentityService) SetUserPassword(ctx context.Context, req *identityv1.SetUserPasswordRequest) (*commonv1.User, error)
- func (s *IdentityService) UpdateAccessToken(ctx context.Context, req *identityv1.UpdateAccessTokenRequest) (*identityv1.UpdateAccessTokenResponse, error)
- func (s *IdentityService) UpdateAnnouncement(_ context.Context, req *identityv1.UpdateAnnouncementRequest) (*identityv1.Announcement, error)
- func (s *IdentityService) UpdateOnboardRule(ctx context.Context, req *identityv1.UpdateOnboardRuleRequest) (*identityv1.OnboardRule, error)
- func (s *IdentityService) UpdateOrganization(ctx context.Context, req *identityv1.UpdateOrganizationRequest) (*identityv1.Organization, error)
- func (s *IdentityService) UpdateOrganizationEnvVar(ctx context.Context, req *identityv1.UpdateOrganizationEnvVarRequest) (*identityv1.EnvVar, error)
- func (s *IdentityService) UpdateRole(ctx context.Context, req *identityv1.UpdateRoleRequest) (*identityv1.Role, error)
- func (s *IdentityService) UpdateUser(ctx context.Context, req *identityv1.UpdateUserRequest) (*commonv1.User, error)
- func (s *IdentityService) UpdateUserCredential(ctx context.Context, req *identityv1.UpdateUserCredentialRequest) (*identityv1.UpdateUserCredentialResponse, error)
- func (s *IdentityService) UpdateUserEnvVar(ctx context.Context, req *identityv1.UpdateUserEnvVarRequest) (*identityv1.EnvVar, error)
- type KubernetesConfig
- type KubernetesSATokenConfig
- type MailRateLimitConfig
- type OnboardRuleConfig
- type PasswordLockoutConfig
- type PasswordResetConfig
- type SMTPConfig
- type Server
- func (s *Server) GetUserByAccessToken(token string) (*models.User, error)
- func (s *Server) GetUserByEmail(email string) (*models.User, error)
- func (s *Server) GetUserByUsername(username string, source string) (*models.User, error)
- func (s *Server) GetUserByUsernameWithOnboardHint(username string, source string, hint *models.OnboardUserRule) (*models.User, bool, error)
- func (s *Server) ResolveCredential(ctx context.Context, username, serviceName, serviceScope string) (*models.UserCredential, error)
- func (s *Server) Serve() error
Constants ¶
This section is empty.
Variables ¶
var ErrServiceAccountNotFound = errors.New("service account not found")
ErrServiceAccountNotFound indicates the Kubernetes service account referenced by a credential no longer exists in the cluster.
Functions ¶
This section is empty.
Types ¶
type AnnouncementEmailConfig ¶ added in v0.17.0
type AnnouncementEmailConfig struct {
// Interval is how often the sender checks for eligible announcements
// and candidates. Defaults to 1 minute when zero.
Interval time.Duration `yaml:"interval" validate:"omitempty,gt=0"`
// SendHour is the hour of day (0-23, evaluated in Timezone) at or after
// which sends are allowed to start on an announcement's activation day
// (its StartsAt, or CreatedAt when StartsAt is unset). A *int (rather
// than int) because 0 (midnight) is itself a valid explicit value,
// indistinguishable from "unset" if this were a plain int with a
// zero-defaults-to-9 rule — same reasoning as
// KubernetesSATokenConfig.Enabled. Defaults to 9 when nil.
SendHour *int `yaml:"sendHour" validate:"omitempty,gte=0,lte=23"`
// Timezone is the IANA timezone name SendHour and each announcement's
// activation day are evaluated in. Defaults to "UTC" when empty. An
// invalid value fails server startup rather than silently falling back,
// since a wrong timezone would misfire every send.
Timezone string `yaml:"timezone"`
// Subjects maps a language — the same value resolved from a candidate's
// user_settings "language" key used to pick their translation (see
// announcementUserSettings) — to the email subject line used for that
// language. A language with no entry falls back to Subjects["en"], then
// to a fixed generic subject if that's missing too. Defaults to
// {"en": "New k8Shell announcement", "cs": "Nové oznámení k8Shell"} when
// unset. Not limited to en/cs — add any language key the deployment
// needs translations for.
Subjects map[string]string `yaml:"subjects"`
}
AnnouncementEmailConfig tunes the periodic sender that emails active, email-eligible announcements to opted-in users (see Server.startAnnouncementEmailSender). It reuses SMTPConfig — there is no separate relay configuration for announcement email.
type Config ¶
type Config struct {
// GrpcConfig configures the gRPC server.
GrpcConfig gapi.ServerConfig `yaml:"grpc" validate:"required"`
// Nats configures the NATS client.
Nats natsc.NATSClientConfig `yaml:"nats"`
// DB configures the database connection.
DB db.DBConfig `yaml:"db"`
// LocalProviders configures local file-based identity providers.
LocalProviders file.FileUserProviderConfig `yaml:"localProviders"`
// RemoteProviders configures remote identity provider clients.
RemoteProviders []gapi.ClientConfig `yaml:"remoteProviders" validate:"omitempty,dive"`
// JWTIssuer configures JWT token issuance.
JWTIssuer authz.JWTIssuerConfig `yaml:"jwtIssuer" validate:"required"`
// Kubernetes configures Kubernetes secret management and distributed
// leader election for the token refresh loop.
Kubernetes KubernetesConfig `yaml:"kubernetes" validate:"required"`
// Authz configures the authorization gRPC client used for policy evaluation.
Authz gapi.ClientConfig `yaml:"authz"`
// PasswordLockout configures brute-force protection for AuthUserPassword.
PasswordLockout PasswordLockoutConfig `yaml:"passwordLockout"`
// SMTP configures the outbound mail relay used to send password-reset email.
SMTP SMTPConfig `yaml:"smtp"`
// PasswordReset tunes the password-reset token/cooldown lifecycle.
PasswordReset PasswordResetConfig `yaml:"passwordReset"`
// AnnouncementEmail tunes the periodic sender that emails active,
// email-eligible announcements to opted-in users.
AnnouncementEmail AnnouncementEmailConfig `yaml:"announcementEmail"`
// MailRateLimit caps total outbound email volume (summed across every
// mail kind identity sends) in a trailing 24h window.
MailRateLimit MailRateLimitConfig `yaml:"mailRateLimit"`
// OnboardRules declares default identity.onboard_rules rows to insert
// once at startup — see Server.seedOnboardRules. Without at least a
// catch-all rule per (idp, org) a fresh deployment's onboard_rules table
// is empty and ResolveOnboardDecision fails closed, rejecting everyone.
OnboardRules []OnboardRuleConfig `yaml:"onboardRules" validate:"omitempty,dive"`
// contains filtered or unexported fields
}
Config contains server configuration loaded from YAML.
func LoadConfig ¶
LoadConfig loads server configuration from configFile and validates it.
type IdentityService ¶
type IdentityService struct {
identityv1.UnimplementedIdentityServiceServer
// contains filtered or unexported fields
}
IdentityService implements the identity gRPC service.
func NewIdentityService ¶
func NewIdentityService(server *Server) *IdentityService
NewIdentityService returns a new IdentityService.
func (*IdentityService) AddGitUserCredential ¶ added in v0.16.0
func (s *IdentityService) AddGitUserCredential(ctx context.Context, req *identityv1.AddGitUserCredentialRequest) (*identityv1.AddGitUserCredentialResponse, error)
AddGitUserCredential stores a Git credential for a user. req.Scope maps to the credential's service_scope and req.Subject maps to its subject; req.Secret is stored as given.
func (*IdentityService) AddKubernetesUserCredential ¶ added in v0.16.0
func (s *IdentityService) AddKubernetesUserCredential(ctx context.Context, req *identityv1.AddKubernetesUserCredentialRequest) (*identityv1.AddKubernetesUserCredentialResponse, error)
AddKubernetesUserCredential provisions a Kubernetes service-account credential for a user. req.Scope maps to the credential's service_scope and req.Subject maps to its subject.
func (*IdentityService) AddOrganizationEnvVar ¶ added in v0.16.0
func (s *IdentityService) AddOrganizationEnvVar(ctx context.Context, req *identityv1.AddOrganizationEnvVarRequest) (*identityv1.EnvVar, error)
AddOrganizationEnvVar creates a new environment variable on an organization.
func (*IdentityService) AddRegistryUserCredential ¶ added in v0.16.0
func (s *IdentityService) AddRegistryUserCredential(ctx context.Context, req *identityv1.AddRegistryUserCredentialRequest) (*identityv1.AddRegistryUserCredentialResponse, error)
AddRegistryUserCredential stores a container registry credential for a user. req.Scope maps to the credential's service_scope and req.Subject maps to its subject; req.Secret is stored as given.
func (*IdentityService) AddRoleBlueprints ¶ added in v0.16.0
func (s *IdentityService) AddRoleBlueprints(ctx context.Context, req *identityv1.RoleBlueprintsRequest) (*identityv1.Role, error)
AddRoleBlueprints grants a role one or more blueprints; every user holding the role gains access to them. org is required; global roles are not supported through this RPC.
func (*IdentityService) AddUserAuthKeys ¶ added in v0.16.0
func (s *IdentityService) AddUserAuthKeys(ctx context.Context, req *identityv1.UserAuthKeysRequest) (*commonv1.User, error)
AddUserAuthKeys registers one or more SSH public keys for a user.
func (*IdentityService) AddUserEnvVar ¶ added in v0.16.0
func (s *IdentityService) AddUserEnvVar(ctx context.Context, req *identityv1.AddUserEnvVarRequest) (*identityv1.EnvVar, error)
AddUserEnvVar creates a new environment variable owned by the user, overriding any organization value with the same key.
func (*IdentityService) AddUserRoles ¶ added in v0.16.0
func (s *IdentityService) AddUserRoles(ctx context.Context, req *identityv1.UserRolesRequest) (*commonv1.User, error)
AddUserRoles adds one or more roles to a user without affecting existing roles.
func (*IdentityService) ApproveOnboardRequest ¶ added in v0.16.0
func (s *IdentityService) ApproveOnboardRequest(ctx context.Context, req *identityv1.ApproveOnboardRuleRequest) (*commonv1.User, error)
ApproveOnboardRequest approves a pending ("waitlist") onboard rule, flipping its action to "allow". It deliberately does not onboard the user itself — that happens lazily on their next login/web-flow attempt via the normal refreshUser/ResolveOnboardDecision path, same as any other allow rule. Onboarding eagerly here, at approval time, would pre-empt that: e.g. CompleteUserWebFlow's freshly-onboarded signal (used to deliver a provider's follow-up action exactly once) is derived from the user record being created during that call, which never happens if approval already created it out of band.
func (*IdentityService) AuthUserPassword ¶ added in v0.16.0
func (s *IdentityService) AuthUserPassword(ctx context.Context, req *identityv1.AuthUserPasswordRequest) (*identityv1.AuthUserResponse, error)
AuthUserPassword checks a password against the bcrypt password hash stored locally in the database. Unlike AuthUserPublicKey, this is never delegated to an identity provider — passwords are a k8Shell-local credential, resolved the same way as PATs and stored credentials.
This RPC does not evaluate the user:auth authz policy itself: it is called by both SSH and web login surfaces, each of which evaluates user:auth with its own surface context before (or instead of) calling here — identity has no way to know which surface is calling. Callers that need to verify a password outside of login (e.g. requiring the current password before a change) can also call this RPC directly, since it carries no login-specific authorization of its own.
Repeated failed attempts against an existing account lock it out of password auth for a configurable window (see PasswordLockoutConfig), tracked by username in identity's own storage so the lockout applies no matter which caller invokes this RPC. Unknown usernames are never tracked, to avoid growing the lockout store from arbitrary attempted names. The response's Locked field distinguishes a lockout from an ordinary invalid-credentials result so callers can show a consistent "account temporarily locked" message.
func (*IdentityService) AuthUserPublicKey ¶
func (s *IdentityService) AuthUserPublicKey(ctx context.Context, req *identityv1.AuthUserPublicKeyRequest) (*identityv1.AuthUserResponse, error)
AuthUserPublicKey authenticates a user using an SSH public key. The key is always checked against identity.users.auth_keys first, regardless of the user's source — a provider-onboarded user may still have locally-added keys (see AddUserAuthKeys), and local users (source="local") have no backing identity provider at all. The upstream provider is only consulted when the DB has no matching key, and is skipped entirely for local users since they have no provider to fall back to. If the DB isn't configured, the local check is skipped and auth goes straight to the provider.
func (*IdentityService) ClearPasswordLockout ¶ added in v0.16.0
func (s *IdentityService) ClearPasswordLockout(ctx context.Context, req *identityv1.Username) (*identityv1.ClearPasswordLockoutResponse, error)
ClearPasswordLockout resets a username's password-lockout state immediately, letting an admin (or the user) unstick a legitimate lockout without waiting for it to expire naturally.
func (*IdentityService) CompleteUserDeviceFlow ¶
func (s *IdentityService) CompleteUserDeviceFlow(ctx context.Context, req *identityv1.CompleteUserDeviceFlowRequest) (*identityv1.CompleteUserDeviceFlowResponse, error)
CompleteUserDeviceFlow is called by the client after the user has completed device-flow authorization on the provider side. It provisions the dynamic git credential for the user and returns an empty response.
func (*IdentityService) CompleteUserWebFlow ¶
func (s *IdentityService) CompleteUserWebFlow(ctx context.Context, req *identityv1.CompleteUserWebFlowRequest) (*identityv1.CompleteUserWebFlowResponse, error)
CompleteUserWebFlow completes web-flow onboarding and returns the resolved user.
func (*IdentityService) ConfirmPasswordReset ¶ added in v0.17.0
func (s *IdentityService) ConfirmPasswordReset(ctx context.Context, req *identityv1.ConfirmPasswordResetRequest) (*identityv1.ConfirmPasswordResetResponse, error)
ConfirmPasswordReset redeems a token issued by RequestPasswordReset, folding "consume token" + "set new password" + "clear login lockout" into one RPC. The token is deleted only after the password update succeeds, so a transient failure setting the password never wastes an otherwise-valid token. Clearing the lockout is best-effort after that point: the password change is the operation the caller/user actually cares about, so a failure clearing it is logged rather than turned into an error response that would incorrectly suggest the password wasn't changed.
func (*IdentityService) CreateAccessToken ¶
func (s *IdentityService) CreateAccessToken(ctx context.Context, req *identityv1.CreateAccessTokenRequest) (*identityv1.CreateAccessTokenResponse, error)
CreateAccessToken issues a new Personal Access Token for a user. The raw token is returned once in the response and is not recoverable after that.
func (*IdentityService) CreateAnnouncement ¶ added in v0.16.0
func (s *IdentityService) CreateAnnouncement(_ context.Context, req *identityv1.CreateAnnouncementRequest) (*identityv1.Announcement, error)
CreateAnnouncement creates a new announcement. It is global when orgs is empty, otherwise scoped to the listed organizations, further scoped to roles when non-empty. active defaults to true when omitted.
func (*IdentityService) CreateOnboardRule ¶ added in v0.16.0
func (s *IdentityService) CreateOnboardRule(ctx context.Context, req *identityv1.CreateOnboardRuleRequest) (*identityv1.OnboardRule, error)
CreateOnboardRule registers a new onboard rule: a standing wildcard policy (username_pattern='*'), a standing list policy (a comma-delimited list of usernames), or a one-off decision for a specific username.
func (*IdentityService) CreateOrganization ¶ added in v0.16.0
func (s *IdentityService) CreateOrganization(ctx context.Context, req *identityv1.CreateOrganizationRequest) (*identityv1.Organization, error)
CreateOrganization registers a new organization.
func (*IdentityService) CreateRole ¶ added in v0.16.0
func (s *IdentityService) CreateRole(ctx context.Context, req *identityv1.CreateRoleRequest) (*identityv1.Role, error)
CreateRole registers a new assignable role scoped to org. Global roles cannot be created through this RPC — only listed, via ListGlobalRoles.
func (*IdentityService) CreateUser ¶ added in v0.16.0
func (s *IdentityService) CreateUser(ctx context.Context, req *identityv1.CreateUserRequest) (*commonv1.User, error)
CreateUser creates a new local user record (source="local"), i.e. one with no backing identity provider. Username and email must both be unique; unlike username, email has no DB-level uniqueness constraint so it is checked here. When not supplied: uid defaults to the next free value at or above db.localUserUIDFloor; gid defaults to the resolved uid, giving the user their own private group; shell defaults to /bin/sh; sudo and locked default to false; fullname may be left empty.
Unlike user:onboard/user:auth/token:create, this RPC has no per-call authz check here: those evaluate policy for a self-service subject (the caller and the acted-on user are the same person), but CreateUser is admin-on- behalf-of-someone-else and this service has no way to identify the calling admin (no per-caller JWT is verified from incoming gRPC context anywhere in this service, only the gapi service-account allowlist). Authorizing which admins may call CreateUser is the API server's responsibility, enforced before it reaches this RPC — same as every other admin mutation here (UpdateUser, AddUserRoles, SetUserPassword, etc.).
func (*IdentityService) DeleteAccessToken ¶ added in v0.16.0
func (s *IdentityService) DeleteAccessToken(ctx context.Context, req *identityv1.DeleteAccessTokenRequest) (*identityv1.DeleteAccessTokenResponse, error)
DeleteAccessToken permanently deletes an access token by ID.
func (*IdentityService) DeleteAnnouncement ¶ added in v0.16.0
func (s *IdentityService) DeleteAnnouncement(_ context.Context, req *identityv1.DeleteAnnouncementRequest) (*identityv1.DeleteAnnouncementResponse, error)
DeleteAnnouncement permanently removes an announcement, along with its read tracking.
func (*IdentityService) DeleteOnboardRule ¶ added in v0.16.0
func (s *IdentityService) DeleteOnboardRule(ctx context.Context, req *identityv1.DeleteOnboardRuleRequest) (*identityv1.DeleteOnboardRuleResponse, error)
DeleteOnboardRule removes an onboard rule from the registry.
func (*IdentityService) DeleteOrganization ¶ added in v0.16.0
func (s *IdentityService) DeleteOrganization(ctx context.Context, req *identityv1.DeleteOrganizationRequest) (*identityv1.DeleteOrganizationResponse, error)
DeleteOrganization removes an organization from the registry, cascading its org-scoped roles. Fails if any user still belongs to it, or if it's the built-in "default" organization, which is read-only.
func (*IdentityService) DeleteOrganizationEnvVar ¶ added in v0.16.0
func (s *IdentityService) DeleteOrganizationEnvVar(ctx context.Context, req *identityv1.DeleteOrganizationEnvVarRequest) (*identityv1.DeleteOrganizationEnvVarResponse, error)
DeleteOrganizationEnvVar removes an environment variable from an organization.
func (*IdentityService) DeleteRole ¶ added in v0.16.0
func (s *IdentityService) DeleteRole(ctx context.Context, req *identityv1.DeleteRoleRequest) (*identityv1.DeleteRoleResponse, error)
DeleteRole removes a role from the registry. Fails if any user still holds the role, since cascading the role off every user would be a silent privilege change. org is required; global roles cannot be removed through this RPC.
func (*IdentityService) DeleteUser ¶ added in v0.16.0
func (s *IdentityService) DeleteUser(ctx context.Context, req *identityv1.DeleteUserRequest) (*identityv1.DeleteUserResponse, error)
DeleteUser permanently removes a user record by username. Credentials and access tokens owned by the user are removed along with it (ON DELETE CASCADE at the DB level).
Like CreateUser, this RPC has no per-call authz check here: the acted-on user cannot authorize their own deletion, and this service has no way to identify the calling admin. Authorizing which admins may call DeleteUser against the user:delete contract is the API server's responsibility, enforced before it reaches this RPC.
func (*IdentityService) DeleteUserCredential ¶
func (s *IdentityService) DeleteUserCredential(ctx context.Context, req *identityv1.DeleteUserCredentialRequest) (*identityv1.DeleteUserCredentialResponse, error)
DeleteUserCredential deletes an external credential by ID.
func (*IdentityService) DeleteUserEnvVar ¶ added in v0.16.0
func (s *IdentityService) DeleteUserEnvVar(ctx context.Context, req *identityv1.DeleteUserEnvVarRequest) (*identityv1.DeleteUserEnvVarResponse, error)
DeleteUserEnvVar removes a user-owned environment variable, restoring the organization's value (if any) as the effective value.
func (*IdentityService) FindUser ¶
func (s *IdentityService) FindUser(ctx context.Context, req *identityv1.FindUserRequest) (*commonv1.User, error)
FindUser looks up a user by username or access token.
func (*IdentityService) GetAnnouncement ¶ added in v0.16.0
func (s *IdentityService) GetAnnouncement(_ context.Context, req *identityv1.GetAnnouncementRequest) (*identityv1.Announcement, error)
GetAnnouncement retrieves a single announcement by id, including its read_count (the number of distinct users who have read it).
func (*IdentityService) GetAnnouncementsQuerySchema ¶ added in v0.16.0
func (s *IdentityService) GetAnnouncementsQuerySchema(_ context.Context, _ *identityv1.GetAnnouncementsQuerySchemaRequest) (*queryv1.Descriptor, error)
GetAnnouncementsQuerySchema returns the descriptor advertising which announcement fields are queryable/sortable via QueryAnnouncements, and which operators are valid on each.
func (*IdentityService) GetAvailableIdentityProviders ¶
func (s *IdentityService) GetAvailableIdentityProviders( ctx context.Context, req *identityv1.GetAvailableIdentityProvidersRequest, ) (*identityv1.GetAvailableIdentityProvidersResponse, error)
func (*IdentityService) GetBlueprintByUserStr ¶
func (s *IdentityService) GetBlueprintByUserStr(ctx context.Context, req *identityv1.UserStr) (*identityv1.Blueprint, error)
GetBlueprintByUserStr resolves and returns a blueprint for the provided user string.
func (*IdentityService) GetOnboardRulesQuerySchema ¶ added in v0.16.0
func (s *IdentityService) GetOnboardRulesQuerySchema(ctx context.Context, req *identityv1.GetOnboardRulesQuerySchemaRequest) (*queryv1.Descriptor, error)
GetOnboardRulesQuerySchema returns the descriptor advertising which onboard rule fields are queryable/sortable via QueryOnboardRules, and which operators are valid on each.
func (*IdentityService) GetOrganization ¶ added in v0.16.0
func (s *IdentityService) GetOrganization(ctx context.Context, req *identityv1.GetOrganizationRequest) (*identityv1.Organization, error)
GetOrganization retrieves a single organization by name.
func (*IdentityService) GetOrganizationEnvVar ¶ added in v0.16.0
func (s *IdentityService) GetOrganizationEnvVar(ctx context.Context, req *identityv1.GetOrganizationEnvVarRequest) (*identityv1.EnvVar, error)
GetOrganizationEnvVar retrieves a single organization environment variable in full, including its value even when is_secret is true.
func (*IdentityService) GetOrganizationsQuerySchema ¶ added in v0.16.0
func (s *IdentityService) GetOrganizationsQuerySchema(ctx context.Context, req *identityv1.GetOrganizationsQuerySchemaRequest) (*queryv1.Descriptor, error)
GetOrganizationsQuerySchema returns the descriptor advertising which organization fields are queryable/sortable via QueryOrganizations, and which operators are valid on each.
func (*IdentityService) GetPasswordLockoutStatus ¶ added in v0.16.0
func (s *IdentityService) GetPasswordLockoutStatus(ctx context.Context, req *identityv1.Username) (*identityv1.PasswordLockoutStatus, error)
GetPasswordLockoutStatus returns the current password-lockout state for a username. It lets api-server populate UserProfile.PasswordLocked/ PasswordLockedUntil without tracking lockout state itself — identity remains the sole owner of that state.
func (*IdentityService) GetUserCredential ¶
func (s *IdentityService) GetUserCredential(ctx context.Context, req *identityv1.GetUserCredentialRequest) (*commonv1.UserCredential, error)
GetUserCredential resolves a single credential for a user by service name and scope. For kubernetes credentials a fresh service account token is issued on the fly.
func (*IdentityService) GetUserEnvVar ¶ added in v0.16.0
func (s *IdentityService) GetUserEnvVar(ctx context.Context, req *identityv1.GetUserEnvVarRequest) (*identityv1.EnvVar, error)
GetUserEnvVar retrieves a single effective environment variable for a user, in full, including its value even when is_secret is true.
func (*IdentityService) GetUserOnboardCapability ¶
func (s *IdentityService) GetUserOnboardCapability(ctx context.Context, req *identityv1.Username) (*commonv1.UserOnboardCapability, error)
GetUserOnboardCapability returns onboarding capability information for a user.
func (*IdentityService) GetUserSettings ¶ added in v0.16.2
func (s *IdentityService) GetUserSettings(ctx context.Context, req *identityv1.GetUserSettingsRequest) (*identityv1.GetUserSettingsResponse, error)
GetUserSettings retrieves a user's stored settings. A user with no settings row returns the zero-value response, not a NotFound error.
func (*IdentityService) GetUsers ¶
func (s *IdentityService) GetUsers(ctx context.Context, req *identityv1.GetUsersRequest) (*identityv1.UserList, error)
GetUsers retrieves users with pagination support, optionally filtered by role, blueprint, or organization.
func (*IdentityService) GetUsersQuerySchema ¶ added in v0.16.0
func (s *IdentityService) GetUsersQuerySchema(ctx context.Context, req *identityv1.GetUsersQuerySchemaRequest) (*queryv1.Descriptor, error)
GetUsersQuerySchema returns the descriptor advertising which user fields are queryable/sortable via QueryUsers, and which operators are valid on each.
func (*IdentityService) GetVersionInfo ¶ added in v0.16.0
func (s *IdentityService) GetVersionInfo(_ context.Context, _ *commonv1.GetVersionInfoRequest) (*commonv1.GetVersionInfoResponse, error)
GetVersionInfo returns build and version metadata for this service: the released semantic version and git commit injected at link time, plus a short description of what the service does.
func (*IdentityService) IssueUserToken ¶
func (s *IdentityService) IssueUserToken(ctx context.Context, req *identityv1.IssueUserTokenRequest) (*identityv1.IssueUserTokenResponse, error)
GetUserAccessToken returns the current JWT for the requested user. Kubernetes must be configured; the Secret is the source of truth for the token.
func (*IdentityService) ListAccessTokens ¶
func (s *IdentityService) ListAccessTokens(ctx context.Context, req *identityv1.Username) (*identityv1.ListAccessTokensResponse, error)
ListAccessTokens returns access token metadata (no raw tokens or hashes) for a user.
func (*IdentityService) ListAnnouncements ¶ added in v0.16.0
func (s *IdentityService) ListAnnouncements(_ context.Context, req *identityv1.ListAnnouncementsRequest) (*identityv1.AnnouncementList, error)
ListAnnouncements returns announcements for administration: every announcement, optionally filtered to those that apply to org, each with its read_count populated. Unlike ListUnreadAnnouncements/ ListUserAnnouncements it is not scoped to a requesting user's roles and is not filtered by active or validity period.
func (*IdentityService) ListGlobalRoles ¶ added in v0.16.0
func (s *IdentityService) ListGlobalRoles(ctx context.Context, req *identityv1.ListGlobalRolesRequest) (*identityv1.RoleList, error)
ListGlobalRoles returns the roles assignable across every organization. Global roles can only be listed, never created, updated, or deleted.
func (*IdentityService) ListOrganizationEnvVars ¶ added in v0.16.0
func (s *IdentityService) ListOrganizationEnvVars(ctx context.Context, req *identityv1.ListOrganizationEnvVarsRequest) (*identityv1.EnvVarList, error)
ListOrganizationEnvVars returns the environment variables defined directly on an organization, with secret values redacted.
func (*IdentityService) ListOrganizations ¶ added in v0.16.0
func (s *IdentityService) ListOrganizations(ctx context.Context, req *identityv1.ListOrganizationsRequest) (*identityv1.OrganizationList, error)
ListOrganizations returns the registered organizations.
func (*IdentityService) ListRepoOwners ¶ added in v0.16.0
func (s *IdentityService) ListRepoOwners(ctx context.Context, req *identityv1.Username) (*identityv1.RepoOwnerList, error)
ListRepoOwners returns the repository owners — the user's own account plus any organizations they belong to — available on the identity provider that sourced the user. The login of a returned owner is passed back as ListReposRequest.repo_owner to enumerate its repositories.
Providers that don't implement repo browsing (the file provider, for instance) surface as Unimplemented rather than being masked as an internal error, so callers can hide the repo browser for those users.
func (*IdentityService) ListRepos ¶ added in v0.16.0
func (s *IdentityService) ListRepos(ctx context.Context, req *identityv1.ListReposRequest) (*identityv1.RepoList, error)
ListRepos returns the repositories under req.RepoOwner that the user can access on the identity provider that sourced them. The owner must be a login returned by ListRepoOwners.
func (*IdentityService) ListRoles ¶ added in v0.16.0
func (s *IdentityService) ListRoles(ctx context.Context, req *identityv1.ListRolesRequest) (*identityv1.RoleList, error)
ListRoles returns the roles assignable within req.Org: those scoped to it plus all global roles.
func (*IdentityService) ListUnreadAnnouncements ¶ added in v0.16.0
func (s *IdentityService) ListUnreadAnnouncements(_ context.Context, req *identityv1.ListUnreadAnnouncementsRequest) (*identityv1.AnnouncementList, error)
ListUnreadAnnouncements returns active announcements that apply to username's organization and roles (global/every-role or scoped to them), currently fall within their validity period, and that username has not yet read.
func (*IdentityService) ListUserAnnouncements ¶ added in v0.16.0
func (s *IdentityService) ListUserAnnouncements(_ context.Context, req *identityv1.ListUserAnnouncementsRequest) (*identityv1.AnnouncementList, error)
ListUserAnnouncements returns every active announcement that applies to username's organization and roles (global/every-role or scoped to them), regardless of validity period or read status, with is_read/read_at populated per announcement so a client can distinguish ones already seen.
func (*IdentityService) ListUserAuthKeys ¶ added in v0.16.0
func (s *IdentityService) ListUserAuthKeys(ctx context.Context, req *identityv1.ListUserAuthKeysRequest) (*identityv1.ListUserAuthKeysResponse, error)
ListUserAuthKeys returns all SSH public keys registered for a user, either as full key material or as SHA256 fingerprints depending on req.Format.
Keys stored locally (via AddUserAuthKeys) are reported with source "local". The user's upstream identity provider is also consulted via its ListUserAuthKeys RPC; those keys are reported with the source it returns, falling back to the provider's name. A provider that doesn't support the call (or is unavailable) is skipped rather than failing the request. Upstream provider keys are always ordered before local keys.
func (*IdentityService) ListUserCredentials ¶
func (s *IdentityService) ListUserCredentials(ctx context.Context, req *identityv1.ListUserCredentialsRequest) (*identityv1.ListUserCredentialsResponse, error)
ListUserCredentials returns stored credentials for a user, or a single credential when req.Id is set.
func (*IdentityService) ListUserEnvVars ¶ added in v0.16.0
func (s *IdentityService) ListUserEnvVars(ctx context.Context, req *identityv1.ListUserEnvVarsRequest) (*identityv1.EnvVarList, error)
ListUserEnvVars returns the effective environment variables for a user: their organization's variables, overridden by any of the user's own, with secret values redacted.
func (*IdentityService) MarkAnnouncementRead ¶ added in v0.16.0
func (s *IdentityService) MarkAnnouncementRead(_ context.Context, req *identityv1.MarkAnnouncementReadRequest) (*identityv1.MarkAnnouncementReadResponse, error)
MarkAnnouncementRead records that username has read an announcement. Idempotent — marking an already-read announcement again does not change its original read_at.
func (*IdentityService) OnboardUserDeviceFlow ¶
func (s *IdentityService) OnboardUserDeviceFlow(ctx context.Context, req *identityv1.OnboardUserDeviceFlowRequest) (*commonv1.OnboardUserDeviceFlow, error)
OnboardUserDeviceFlow starts device-flow onboarding for a user.
func (*IdentityService) OnboardUserWebFlow ¶
func (s *IdentityService) OnboardUserWebFlow(ctx context.Context, req *identityv1.OnboardUserWebFlowRequest) (*commonv1.OnboardUserWebFlow, error)
OnboardUserWebFlow starts web-flow onboarding for the requested provider.
func (*IdentityService) PutUserSettings ¶ added in v0.16.2
func (s *IdentityService) PutUserSettings(ctx context.Context, req *identityv1.PutUserSettingsRequest) (*identityv1.PutUserSettingsResponse, error)
PutUserSettings replaces a user's settings (last-write-wins UPSERT, no version-conflict check).
func (*IdentityService) QueryAnnouncements ¶ added in v0.16.0
func (s *IdentityService) QueryAnnouncements(_ context.Context, req *identityv1.QueryAnnouncementsRequest) (*identityv1.AnnouncementList, error)
QueryAnnouncements retrieves announcements matching a generic query.v1.Payload, as advertised by GetAnnouncementsQuerySchema — the administration-facing search/filter surface, complementing ListAnnouncements.
func (*IdentityService) QueryOnboardRules ¶ added in v0.16.0
func (s *IdentityService) QueryOnboardRules(ctx context.Context, req *identityv1.QueryOnboardRulesRequest) (*identityv1.OnboardRuleList, error)
QueryOnboardRules retrieves onboard rules matching a generic query.v1.Payload, as advertised by GetOnboardRulesQuerySchema. A frontend renders the pending approval queue by filtering action = "waitlist", and manages standing rules with any other filter — there is no separate "list waitlist" RPC.
func (*IdentityService) QueryOrganizations ¶ added in v0.16.0
func (s *IdentityService) QueryOrganizations(ctx context.Context, req *identityv1.QueryOrganizationsRequest) (*identityv1.OrganizationList, error)
QueryOrganizations retrieves organizations matching a generic query.v1.Payload, as advertised by GetOrganizationsQuerySchema. req.Query.Obligations carries the authz obligations map from the gateway's policy evaluation (never client-supplied — see the field's doc in query.proto) and is enforced as a mandatory scoping constraint, independent of the caller's own Filters, the same way QueryUsers already enforces its obligations. org:list reuses the same "org" key as user:list/session:list (see authz.ParseOrgObligation) — a subject belongs to exactly one organization, so this is a single value, not a list.
func (*IdentityService) QueryUsers ¶ added in v0.16.0
func (s *IdentityService) QueryUsers(ctx context.Context, req *identityv1.QueryUsersRequest) (*identityv1.UserList, error)
QueryUsers retrieves users matching a generic query.v1.Payload, as advertised by GetUsersQuerySchema. req.Query.Obligations carries the authz obligations map from the gateway's policy evaluation (never client-supplied — see the field's doc in query.proto) and is enforced as a mandatory scoping constraint independent of the caller's own Filters, the same way GetUsersRequest's typed Roles/Blueprints/Org fields already are.
func (*IdentityService) RejectOnboardRequest ¶ added in v0.16.0
func (s *IdentityService) RejectOnboardRequest(ctx context.Context, req *identityv1.RejectOnboardRuleRequest) (*identityv1.OnboardRule, error)
RejectOnboardRequest rejects a pending ("waitlist") onboard rule, flipping its action to "reject" so the same user can't immediately re-trigger a fresh waitlist entry by retrying onboarding.
func (*IdentityService) RemoveRoleBlueprints ¶ added in v0.16.0
func (s *IdentityService) RemoveRoleBlueprints(ctx context.Context, req *identityv1.RoleBlueprintsRequest) (*identityv1.Role, error)
RemoveRoleBlueprints revokes one or more blueprints from a role. org is required; global roles are not supported through this RPC.
func (*IdentityService) RemoveUserAuthKey ¶ added in v0.16.0
func (s *IdentityService) RemoveUserAuthKey(ctx context.Context, req *identityv1.RemoveUserAuthKeyRequest) (*commonv1.User, error)
RemoveUserAuthKey removes a single SSH public key from a user, identified by its index in the list returned by ListUserAuthKeys. Only keys with source "local" can be removed this way; keys reported under any other source are managed by their identity provider, not this service.
func (*IdentityService) RemoveUserCredential ¶ added in v0.16.0
func (s *IdentityService) RemoveUserCredential(ctx context.Context, req *identityv1.RemoveUserCredentialRequest) (*identityv1.RemoveUserCredentialResponse, error)
RemoveUserCredential removes a single credential owned by a user, by ID.
func (*IdentityService) RemoveUserRoles ¶ added in v0.16.0
func (s *IdentityService) RemoveUserRoles(ctx context.Context, req *identityv1.UserRolesRequest) (*commonv1.User, error)
RemoveUserRoles removes one or more roles from a user.
func (*IdentityService) RequestPasswordReset ¶ added in v0.17.0
func (s *IdentityService) RequestPasswordReset(ctx context.Context, req *identityv1.RequestPasswordResetRequest) (*identityv1.RequestPasswordResetResponse, error)
RequestPasswordReset issues and emails a single-use password-reset link for a username, if the user has an on-file email address, SMTP is configured, and the shared daily recipient budget (MailRateLimitConfig, checked jointly with announcement email via identity.mail_sends) isn't exhausted. api-server discards this RPC's outcome either way (its HTTP response is already sent by the time it's called), so failures past basic request validation are logged and swallowed — this always returns success.
func (*IdentityService) ResolveAccessToken ¶
func (s *IdentityService) ResolveAccessToken(ctx context.Context, req *identityv1.ResolveAccessTokenRequest) (*identityv1.ResolveAccessTokenResponse, error)
ResolveAccessToken looks up a raw k8sh_ token, updates last_used_at, and returns the owning user and the token's scopes. Called by API gateways on every k8sh_ request.
func (*IdentityService) RevokeAccessToken ¶
func (s *IdentityService) RevokeAccessToken(ctx context.Context, req *identityv1.RevokeAccessTokenRequest) (*identityv1.RevokeAccessTokenResponse, error)
RevokeAccessToken soft-deletes an access token by ID, enforcing username ownership.
func (*IdentityService) SetUserPassword ¶ added in v0.16.0
func (s *IdentityService) SetUserPassword(ctx context.Context, req *identityv1.SetUserPasswordRequest) (*commonv1.User, error)
SetUserPassword sets or clears a user's local password. The password is bcrypt-hashed before being persisted; the raw value is never stored or returned. Pass an empty password to clear it, disabling password auth.
func (*IdentityService) UpdateAccessToken ¶ added in v0.16.0
func (s *IdentityService) UpdateAccessToken(ctx context.Context, req *identityv1.UpdateAccessTokenRequest) (*identityv1.UpdateAccessTokenResponse, error)
UpdateAccessToken partially updates an access token's active state and/or scopes, enforcing username ownership. Only fields set (non-nil) in req are applied.
func (*IdentityService) UpdateAnnouncement ¶ added in v0.16.0
func (s *IdentityService) UpdateAnnouncement(_ context.Context, req *identityv1.UpdateAnnouncementRequest) (*identityv1.Announcement, error)
UpdateAnnouncement partially updates an announcement's name, translations, org/role scope, active state, and/or validity period.
func (*IdentityService) UpdateOnboardRule ¶ added in v0.16.0
func (s *IdentityService) UpdateOnboardRule(ctx context.Context, req *identityv1.UpdateOnboardRuleRequest) (*identityv1.OnboardRule, error)
UpdateOnboardRule fully replaces the mutable fields of an onboard rule, including username_pattern. idp/org are immutable — delete and recreate the rule to change them.
func (*IdentityService) UpdateOrganization ¶ added in v0.16.0
func (s *IdentityService) UpdateOrganization(ctx context.Context, req *identityv1.UpdateOrganizationRequest) (*identityv1.Organization, error)
UpdateOrganization updates an organization's description. The name is immutable and used only to identify the organization. Fails for the built-in "default" organization, which is read-only.
func (*IdentityService) UpdateOrganizationEnvVar ¶ added in v0.16.0
func (s *IdentityService) UpdateOrganizationEnvVar(ctx context.Context, req *identityv1.UpdateOrganizationEnvVarRequest) (*identityv1.EnvVar, error)
UpdateOrganizationEnvVar partially updates an existing organization environment variable's value and/or is_secret flag.
func (*IdentityService) UpdateRole ¶ added in v0.16.0
func (s *IdentityService) UpdateRole(ctx context.Context, req *identityv1.UpdateRoleRequest) (*identityv1.Role, error)
UpdateRole updates a role's description. Name and org are immutable and cannot be changed. org is required; global roles cannot be updated through this RPC.
func (*IdentityService) UpdateUser ¶ added in v0.16.0
func (s *IdentityService) UpdateUser(ctx context.Context, req *identityv1.UpdateUserRequest) (*commonv1.User, error)
UpdateUser applies a partial update to a user record. Only non-nil wrapper fields and non-empty repeated fields in the request are applied.
func (*IdentityService) UpdateUserCredential ¶
func (s *IdentityService) UpdateUserCredential(ctx context.Context, req *identityv1.UpdateUserCredentialRequest) (*identityv1.UpdateUserCredentialResponse, error)
UpdateUserCredential partially updates a credential by ID. Only fields set (non-nil) in req are applied. Credentials provisioned by the onboarding flow (credential_source matching "idp.k8shell.io/*") may only have Active updated.
func (*IdentityService) UpdateUserEnvVar ¶ added in v0.16.0
func (s *IdentityService) UpdateUserEnvVar(ctx context.Context, req *identityv1.UpdateUserEnvVarRequest) (*identityv1.EnvVar, error)
UpdateUserEnvVar partially updates an existing user-owned environment variable override. Returns NotFound if the user has no override for key — AddUserEnvVar must be used to create one first.
type KubernetesConfig ¶
type KubernetesConfig struct {
// SAToken configures on-demand service-account token issuance.
SAToken KubernetesSATokenConfig `yaml:"saToken"`
}
KubernetesConfig contains configuration for Kubernetes secret management and distributed leader election.
type KubernetesSATokenConfig ¶
type KubernetesSATokenConfig struct {
// Enabled controls whether SA token issuance is enabled. Defaults to true.
Enabled *bool `yaml:"enabled"`
// TTL is the requested token lifetime. Must be >= 10 minutes (Kubernetes
// enforced minimum). Defaults to 1 hour when unset or zero.
TTL time.Duration `yaml:"ttl" validate:"omitempty,gt=0"`
// Audiences lists the audiences embedded in issued tokens.
// Defaults to ["https://kubernetes.default.svc.cluster.local"] when empty.
Audiences []string `yaml:"audiences" validate:"omitempty,dive,uri"`
}
KubernetesSATokenConfig controls on-demand service-account token issuance via the Kubernetes TokenRequest API.
type MailRateLimitConfig ¶ added in v0.17.0
type MailRateLimitConfig struct {
// DailyRecipientCap is the maximum number of recipients emailed across
// all mail kinds in any trailing 24h window. 0 (the default) disables
// the cap.
DailyRecipientCap int `yaml:"dailyRecipientCap" validate:"omitempty,gte=0"`
}
MailRateLimitConfig caps total outbound email volume (summed across every mail kind identity sends — see identity.mail_sends) in a trailing 24h window. Exists to respect a rate-limited relay's send cap, e.g. a personal Gmail account's undocumented ~500-recipients/24h limit.
type OnboardRuleConfig ¶ added in v0.16.0
type OnboardRuleConfig struct {
// IDP is the identity provider name this rule applies to, "local", or
// "*" for any provider.
IDP string `yaml:"idp" validate:"required"`
// UsernamePattern is '*' (any username), a comma-delimited list of
// usernames, or a single exact username.
UsernamePattern string `yaml:"usernamePattern" validate:"required"`
// Org is the organization matching users are placed into.
Org string `yaml:"org" validate:"required"`
// Action is the onboarding decision this rule resolves to.
Action string `yaml:"action" validate:"required,oneof=allow reject waitlist"`
// Priority ranks this rule among other matching rules of the same
// specificity (exact-username vs. pattern) — lower wins. Defaults to 0.
Priority int32 `yaml:"priority"`
// Roles are granted to the user when Action is "allow". Must be valid
// within Org (org-scoped-or-global).
Roles []string `yaml:"roles"`
// Sudo grants sudo access when Action is "allow".
Sudo bool `yaml:"sudo"`
// Note is an optional admin comment recorded on the rule.
Note string `yaml:"note"`
}
OnboardRuleConfig declares a default identity.onboard_rules row, inserted once at startup by Server.seedOnboardRules if no row already exists for the same (IDP, UsernamePattern, Org) — from a prior seed, an admin-authored rule, or a system-inserted waitlist/rejection row. Config changes here therefore never clobber a rule an admin has since edited via the API, and it's safe for multiple service instances to seed the same config concurrently at startup.
type PasswordLockoutConfig ¶ added in v0.16.0
type PasswordLockoutConfig struct {
// MaxAttempts is the number of consecutive failed password attempts
// before an account is locked. Defaults to 5 when zero.
MaxAttempts int `yaml:"maxAttempts" validate:"omitempty,gt=0"`
// LockDuration is how long an account stays locked once MaxAttempts is
// reached. Defaults to 15 minutes when zero.
LockDuration time.Duration `yaml:"lockDuration" validate:"omitempty,gt=0"`
}
PasswordLockoutConfig configures brute-force protection for AuthUserPassword. Tracking is keyed by username in identity's own NATS KV storage, so it applies consistently regardless of which caller (SSH, web login, or any other gRPC client) invokes AuthUserPassword. It has no effect when NATS is disabled.
type PasswordResetConfig ¶ added in v0.17.0
type PasswordResetConfig struct {
// TokenTTL bounds how long an issued reset link stays valid. Defaults to
// 1 hour when zero. Only takes effect the first time the underlying KV
// bucket is created — see Server.NewServer.
TokenTTL time.Duration `yaml:"tokenTTL" validate:"omitempty,gt=0"`
// CooldownDuration is how long a username must wait between
// RequestPasswordReset calls before a new one actually sends email.
// Defaults to 60 seconds when zero. Same first-creation-only caveat as
// TokenTTL.
CooldownDuration time.Duration `yaml:"cooldownDuration" validate:"omitempty,gt=0"`
}
PasswordResetConfig tunes the password-reset token lifecycle. Tracking is stored in identity's own NATS KV storage and has no effect when NATS is disabled.
type SMTPConfig ¶ added in v0.17.0
type SMTPConfig struct {
// Enabled turns on SMTP sending. Defaults to false.
Enabled bool `yaml:"enabled"`
// Host and Port address the SMTP relay. Required when Enabled.
Host string `yaml:"host" validate:"required_if=Enabled true"`
Port int `yaml:"port" validate:"required_if=Enabled true"`
// Username and Password authenticate to the relay via PLAIN auth. Leave
// both empty for an unauthenticated relay.
Username string `yaml:"username"`
Password string `yaml:"password"`
// From is the envelope/header From address on outgoing mail. Required
// when Enabled.
From string `yaml:"from" validate:"required_if=Enabled true"`
}
SMTPConfig configures the outbound mail relay identity uses to send password-reset email. When Enabled is false (the default), or the relay is unreachable, RequestPasswordReset logs and swallows the send failure rather than returning an error to the caller.
type Server ¶
type Server struct {
// DB provides persistent user storage.
DB *backend.DB
// IdentityProviders maps provider name to provider client.
IdentityProviders map[string]identity.IdpClient
// JWT issues signed JWT tokens for authenticated users.
// It is nil when JWT issuance is disabled in config.
JWT *authz.JWTIssuer
// Verifier parses and validates JWT tokens for GetUserByAccessToken.
// It is nil when JWT verification could not be initialized.
Verifier *authz.JWTVerifier
// contains filtered or unexported fields
}
Server represents the identity service runtime and its dependencies.
func NewServer ¶
NewServer initializes a new Server from the provided configuration file. It loads configuration, initializes the database connection, and sets up identity providers.
func (*Server) GetUserByAccessToken ¶
GetUserByAccessToken retrieves a user by verifying the provided JWT access token. In the DB path the verified subject and source claims are used to look up the user. In the file-provider path the subject claim is used directly.
func (*Server) GetUserByEmail ¶ added in v0.16.0
GetUserByEmail retrieves a user by email from the database. Unlike GetUserByUsername it does not query identity providers directly (they have no email-based lookup), but if the cached record is expired or invalid it is refreshed from providers by username, same as GetUserByUsername.
func (*Server) GetUserByUsername ¶
GetUserByUsername retrieves a user by username from the database. It refreshes the user data when needed by querying configured identity providers.
func (*Server) GetUserByUsernameWithOnboardHint ¶ added in v0.16.0
func (s *Server) GetUserByUsernameWithOnboardHint(username string, source string, hint *models.OnboardUserRule) (*models.User, bool, error)
GetUserByUsernameWithOnboardHint behaves like GetUserByUsername, but additionally takes an onboarding decision an identity provider computed for this specific user (e.g. from IdentityProviderService.CompleteUserWebFlow) and, when the user doesn't already exist, folds it into the onboarding decision otherwise resolved purely from identity.onboard_rules (see refreshUser). The second return value reports whether this call actually created the user (as opposed to finding an existing one) — used by callers that must only act on a fresh onboarding once, such as recording a provider-supplied manage_info link on the user's profile.
func (*Server) ResolveCredential ¶
func (s *Server) ResolveCredential(ctx context.Context, username, serviceName, serviceScope string) (*models.UserCredential, error)
ResolveCredential looks up the stored credential for the given user, service_name and service_scope, then resolves it according to credential_source:
- "stored": secret returned as-is (registry, static git).
- "kubernetes": fresh bound SA token issued via the TokenRequest API.
- any other value: treated as an IDP name; token fetched live via GetUserGitToken (dynamic git provisioned by CompleteUserWebFlow / CompleteUserDeviceFlow).
Returns models.ErrUserNotFound when no active credential exists.
Source Files
¶
- announcement.go
- announcement_mailer.go
- announcement_query.go
- config.go
- credentials.go
- env_var.go
- identity.go
- kubernetes.go
- onboard_rule.go
- onboard_rule_query.go
- organization.go
- organization_query.go
- password_lockout.go
- password_reset.go
- providers.go
- repos.go
- role.go
- server.go
- token_janitor.go
- user_query.go
- user_settings.go