accesshttp

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 39 Imported by: 0

Documentation

Overview

Package accesshttp is the access module's HTTP adapter: the authentication middleware, the access spec's server and the artifactory spec's security partial, with every access handler, the API restriction middleware and the access contributions to the router's request handling.

Role

access module, HTTP adapter layer. The composition root mounts what this package exports; nothing else in the module serves HTTP. It reaches the artifacts module only through artifacts/api, and it imports no server or router package: the router hands it what it needs from other modules as options and functions.

Inputs

  • Driving: the router, which installs Authenticate with AuthnOptions, PlusAsSpace, APIRecoveryContext and Server.CheckAPIRestriction, mounts Server.RegisterRoutes, and embeds Server.Access and Server.Security in the generated strict servers beside the generated stubs.
  • Deps, from the composition root: the access API, the Store (the access ports, the settings and the configuration documents), the authenticator, the token service, the OIDC verifier, the settings, the password cost, the compatibility version, the logger and the artifacts module's Repositories, through which the handlers read every repository.
  • From the router, as functions: the health predicate and limit error writer of CheckAPIRestriction, and the skips, registry predicates and credential keepers of AuthnOptions.

Outputs

  • Authenticate and AuthnOptions: the request's principal and its decider on the context (kernel.Principal, authn.WithAuthorized).
  • Server, built by New over Deps: AccessService and SecurityAPI, the partial strict servers, and RegisterRoutes for the legacy token routes.
  • The router's contributions: PublicRoutes, SlashCollections, DetailRules with RequestDetails, PlusAsSpace, APIRecoveryRequest, APIRecoveryContext and Server.CheckAPIRestriction.

Invariants

  • Authenticate decides in the order its comment lists (decision 0005): self-authenticated routes and skips, then credentials, which answer 401 at once when they do not verify, then anonymous access, and only then the public routes. An API key (X-JFrog-Art-Api, or X-Api-Key after a blank one) is read first and alone, whatever the Authorization header says, as 7.x's props filter reads it. A refused key that is not blank answers 403, as does a NuGet client's refused password, a locked account, an expired password and a suspended login, each with the Basic challenge, as 7.x's entry point answers them; the entry point's answers to its UI's requests carry no challenge. An Authorization value 7.x reads no credential from, such as "Basic Og==", "Bearer" without a token or another scheme, counts as no credential at all, as do a blank X-JFrog-Art-Api and Basic credentials naming the anonymous user while anonymous access is off.
  • Every principal it lets through is authorised once, and handlers ask that decider (decision 0006).
  • A key pair delete clears the repositories' references to the pair and deletes it in one store transaction: a failure at any step leaves both as they were.
  • Statuses, envelopes and error and log text are what JFrog's clients and the operators' logs read, so they stay byte-identical.
  • accessState, which both partials embed, defines no method named after an operation, so the composite's depth-2 stubs never collide with it.

References

  • Decision 0005: docs/research/decisions/0005-authentication-and-tokens.md (credential forms, the expired token refresh, the compatibility version).
  • Decision 0006: docs/research/decisions/0006-authorization-native-permission-model.md (the once-per-request decider and the permission APIs).
  • Decision 0043: docs/research/decisions/0043-api-reliability.md (API restrictions and the recovery requests, bounded as before).
  • Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Dependency rules": a module reaches another only through its api).
  • Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 290 to 295 and 553 (the access module's HTTP adapter), and the mapping at lines 395 and 396.
  • https://github.com/weaveplatform/artifactweave/issues/1072

Status

Implemented P4 as the server root's access handlers: the legacy security and Access APIs, permissions, tokens and the OIDC exchange; API restrictions came with retry safety and bounded API execution (pull request 905). P9d split them into partial strict servers (WEB-07) and moved them here (WEB-09) and narrowed Deps.Store to the adapter's own Store (ACC-14).

Testing

The unit tests here call the middleware and the partials directly over in-memory stores, without the router; TestUnitDeleteKeyPairIsOneTransaction checks the key pair transaction. The route suites under test/server/access and the router's guards in app (its status, principal and ledger tables) reach the handlers through the router.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIRecoveryContext

func APIRecoveryContext(next http.Handler) http.Handler

APIRecoveryContext marks a recovery request (APIRecoveryRequest) so that the authenticator verifies its credentials even while the caller's API restriction is in force, and bounds the request to five seconds. The flag grants no authority: the handlers still require an administrator.

func APIRecoveryRequest

func APIRecoveryRequest(r *http.Request) bool

APIRecoveryRequest reports the administrator's recovery requests: reading, setting and lifting a user's API restriction and reading the audit. They pass the restriction check (CheckAPIRestriction), and the request limiter serves them from a reserve of their own, so that a restriction can always be lifted.

func Authenticate

func Authenticate(o AuthnOptions) func(http.Handler) http.Handler

Authenticate puts the request's principal in its context. It decides in this order, and the order matters:

  1. A self-authenticated route passes untouched.
  2. So does a request a skip reports, credentials or not, the skips asked in order. npm's login and logout come first (npmUserPath): they check the password and the token they carry themselves, and a stale credential read there could suspend the very login that replaces it. Then a protocol's absent path, such as Go's checksum database, which its router answers 404 whoever asks, a host route served to anyone, such as Terraform's discovery document, and a signed URL, such as Terraform's downloads, whose handler checks the signature (pkgroute.Protocol.SkipsAuthentication).
  3. Credentials that do not verify answer 401 at once, even on a public route, as Artifactory does: a client with a wrong password learns it on its first call. A refused API key (refusedAPIKey) and a NuGet client's refused password (refusedNuGetPassword) answer 403 instead, and so do a locked account, an expired password and a suspended login, each with the challenge (entryPoint). An expired password may still change itself (ownPasswordChange), and a registry token is good for the registry alone (decision 0005).
  4. The exception is an expired Bearer access token on refreshRoute (expiredRefresh).
  5. A principal that verified is authorised once (authn.Authorize): its permissions are evaluated for the request, and the principal is stored with that evaluator (authn.WithAuthorized), which handlers ask every question through authn.DeciderFrom. The credential keepers add to its context first, in order. The principal's name goes to the access log (httpkit.NoteUser).
  6. Without credentials, a path that challenges anonymous requests answers 401 even while anonymous access is on (decision 0031).
  7. Otherwise the request acts as anonymous, authorised the same way, when anonymous access is on.
  8. With anonymous access off, only public routes answer.

func PlusAsSpace

func PlusAsSpace(next http.Handler) http.Handler

PlusAsSpace rewrites an unescaped "+" in those paths to an escaped space before chi routes the request, so the generated binders decode it as one. A plus sent as %2B is not a "+" in the escaped path and stays a plus, which keeps names that contain one reachable. It must run before routing: chi takes the path parameters from the escaped path as it matches.

func PublicRoutes

func PublicRoutes() map[string]bool

PublicRoutes returns "METHOD path" of Access's routes that answer without credentials while anonymous access is off (accessPublicRoutes), in a new map to which the router adds the routes of its other modules (AuthnOptions.PublicRoutes).

func SlashCollections

func SlashCollections() map[string]string

SlashCollections returns the access collection that the Terraform provider calls with a trailing slash, mapped to its path without one, for the router's rewrite of collection paths: the provider creates key pairs with POST /api/security/keypair/ (its KeypairEndPoint), which chi would otherwise read as a key pair with an empty name.

Types

type AccessService

type AccessService struct {
	// contains filtered or unexported fields
}

AccessService implements the access spec's operations. It is the access spec's partial strict server: the composition root embeds it beside the generated stubs, which answer 501 for every operation it leaves out.

func (AccessService) ChangeUserPassword

ChangeUserPassword sets a user's password (PUT /access/api/v2/users/{username}/password): an administrator sets anyone's, and a user its own, even once it has expired, but not through a narrowed token.

func (AccessService) ConfigureAccessUserLockPolicy

ConfigureAccessUserLockPolicy replaces the policy. An omitted field is stored as 0 or false, not as its default: Access's request model has plain numbers and booleans, and JFrog documents the consequences (omitting attempts turns locking off).

func (AccessService) CreateGlobalEnvironment

CreateGlobalEnvironment creates a global environment for an administrator (POST /access/api/v1/environments); a taken name is a 409.

func (AccessService) CreateGlobalRole

CreateGlobalRole answers 201 with {"code":"OK","message":"Role '<name>' created"}, as JFrog's spec documents; the platform provider then reads the role back.

func (AccessService) CreateGroup

CreateGroup creates a group for an administrator (POST /access/api/v2/groups).

func (AccessService) CreateOidcConfiguration

CreateOidcConfiguration answers 200, not 201: the jfrog/platform provider expects exactly 200.

func (AccessService) CreateOidcIdentityMapping

CreateOidcIdentityMapping creates an identity mapping of a provider for an administrator (POST /access/api/v1/oidc/{provider_name}/identity_mappings).

func (AccessService) CreatePasswordPolicy

CreatePasswordPolicy replaces the whole policy: an omitted field returns to its default, as JFrog documents for this PUT.

func (AccessService) CreatePermission

CreatePermission creates a permission and returns it as stored, 201.

func (AccessService) CreateToken

CreateToken mints or refreshes a token. The body may be JSON (the Terraform provider) or a form (the JFrog CLI); both carry the same fields.

func (AccessService) CreateUser

CreateUser creates a user for an administrator (POST /access/api/v2/users).

func (AccessService) DeleteGlobalEnvironment

DeleteGlobalEnvironment refuses DEV, PROD and environments still in use with 400, as the operation's description says; its declared responses do not list the 400, so the error carries it.

func (AccessService) DeleteGlobalRole

DeleteGlobalRole deletes a global role for an administrator (DELETE /access/api/v1/roles/{role}); a built-in role or one in use is a 400.

func (AccessService) DeleteGroup

DeleteGroup deletes a group for an administrator (DELETE /access/api/v2/groups/{name}).

func (AccessService) DeleteOidcConfiguration

DeleteOidcConfiguration deletes an OIDC provider for an administrator (DELETE /access/api/v1/oidc/{name}).

func (AccessService) DeleteOidcIdentityMapping

DeleteOidcIdentityMapping deletes an identity mapping for an administrator (DELETE /access/api/v1/oidc/{provider_name}/identity_mappings/{mapping_name}).

func (AccessService) DeletePermission

DeletePermission removes a permission, 204.

func (AccessService) DeletePermissionResource

DeletePermissionResource removes one section, 204.

func (AccessService) DeleteUser

DeleteUser deletes a user for an administrator (DELETE /access/api/v2/users/{username}).

func (AccessService) ExpirePasswordForAllUsers

ExpirePasswordForAllUsers expires every internal user's password for an administrator (POST /access/api/v2/users/expire_password_for_all_users).

func (AccessService) ExpireUserPassword

ExpireUserPassword expires a user's password for an administrator (POST /access/api/v2/users/{username}/password/expire).

func (AccessService) GetAccessUserLockPolicy

GetAccessUserLockPolicy returns the Access view of the state that /artifactory/api/security/userLockPolicy and the password expiration policy also read.

func (AccessService) GetAccessVersion

GetAccessVersion answers with the compatibility version as Access's name and version, because clients compare it to decide what Access supports (decision 0005).

func (AccessService) GetAllGlobalRoles

GetAllGlobalRoles lists the global roles for an administrator (GET /access/api/v1/roles).

func (AccessService) GetAllOidcConfigurations

GetAllOidcConfigurations lists the OIDC providers for an administrator (GET /access/api/v1/oidc).

func (AccessService) GetBasicAuthenticationStatus

GetBasicAuthenticationStatus answers an administrator whether Basic authentication with a password is on (GET /access/api/v1/config/security/authentication/basic_authentication_enabled).

func (AccessService) GetGlobalEnvironments

GetGlobalEnvironments lists the global environments for an administrator (GET /access/api/v1/environments).

func (AccessService) GetGlobalRole

GetGlobalRole returns a global role to an administrator (GET /access/api/v1/roles/{role}).

func (AccessService) GetGroupDetails

GetGroupDetails returns a group to a caller that may read identities (GET /access/api/v2/groups/{name}).

func (AccessService) GetGroupList

GetGroupList lists groups a page at a time for a caller that may read identities: an administrator, or a token whose scope covers identities:r (GET /access/api/v2/groups).

func (AccessService) GetOidcConfiguration

GetOidcConfiguration returns an OIDC provider to an administrator (GET /access/api/v1/oidc/{name}).

func (AccessService) GetOidcIdentityMappingByName

GetOidcIdentityMappingByName returns an identity mapping to an administrator (GET /access/api/v1/oidc/{provider_name}/identity_mappings/{mapping_name}).

func (AccessService) GetOidcIdentityMappings

GetOidcIdentityMappings lists a provider's identity mappings, of one project when the query names it, for an administrator (GET /access/api/v1/oidc/{provider_name}/identity_mappings).

func (AccessService) GetPermissionDetails

GetPermissionDetails returns one permission to an administrator, a Manage Resources holder or a system:permissions:r token (getpermissiondetails.json).

func (AccessService) GetPermissionResource

GetPermissionResource returns one section. It is admin only, as getpermissionresource documents, but for Manage Resources holders, who see every permission whole: a system:permissions:r token, which reads the whole permission, is refused here (#382).

func (AccessService) GetPermissions

GetPermissions pages through the permissions, optionally only those granting given users or groups, as name and uri pairs or, with expand, documents narrowed to those principals' grants. getpermissions.json documents the cursor as the name of the previous page's last permission, passed back as the next call's cursor, so a page starts after that name rather than at it, which would repeat it. The store reads only the page and one row past it, which says whether a next cursor is due, so a late page costs what the first does (#1408).

func (AccessService) GetTokenById

GetTokenById returns one token's metadata. A non-revocable token is still found by its id: the artifactory_scoped_token resource reads its token back after creating it, and drops it from state on a 404.

func (AccessService) GetTokenDefaultExpiry

GetTokenDefaultExpiry answers the default lifetime in seconds. Admin only.

func (AccessService) GetTokens

GetTokens lists the caller's tokens, or every token for an administrator, keeping only those with the scope the scope parameter names.

func (AccessService) GetUserDetails

GetUserDetails returns a user to a caller that may read identities, and to the user itself (GET /access/api/v2/users/{username}).

func (AccessService) GetUserList

GetUserList lists users a page at a time for a caller that may read identities (GET /access/api/v2/users).

func (AccessService) OidcTokenExchange

OidcTokenExchange issues an access token for a provider's ID token (RFC 8693). It answers without credentials; the token service must be configured, as for the token API.

func (AccessService) RenameGlobalEnvironment

RenameGlobalEnvironment renames a global environment for an administrator (POST /access/api/v1/environments/{environmentName}/rename); a taken name is a 400, because the spec lists no 409 there.

func (AccessService) ReplaceGroup

ReplaceGroup creates the group, or replaces it, for an administrator (PUT /access/api/v2/groups/{name}): 201 with the group it created, 200 with the group it replaced. The body is Create a Group's, so a replacement resets every field it leaves out to the create default and replaces the members, as JFrog's Replace or Create a Group page says.

func (AccessService) ReplacePermissionResource

ReplacePermissionResource replaces one section whole, creating it when the permission had none.

func (AccessService) RevokeTokenById

RevokeTokenById revokes a token. A non-revocable one is 400, as 7.x answers it (JFrog KB 000005622, which shows the UI's DELETE of such a token failing with 400); revoketokenbyid lists 403 only for a caller without the permission.

func (AccessService) RevokeTokenByValue

RevokeTokenByValue revokes the token whose JWT or reference token is given. Admin only. An unknown token and a non-revocable one both answer 404, which revoketokenbyvalue documents as "Token not found or not revocable", so the answer does not tell which.

func (AccessService) SetBasicAuthenticationStatus

SetBasicAuthenticationStatus switches passwords over HTTP Basic on or off. Tokens keep working either way, which is how an administrator turns it back on.

func (AccessService) SetTokenDefaultExpiry

SetTokenDefaultExpiry sets the default lifetime, in seconds as the token service reads it. Admin only; it applies to tokens created afterwards.

func (AccessService) UnexpirePasswordForAllUsers

UnexpirePasswordForAllUsers clears the expired flag on every password for an administrator (POST /access/api/v2/users/unexpire_password_for_all_users).

func (AccessService) UnlockUser

UnlockUser lifts a user's lockout for an administrator (POST /access/api/v2/users/{username}/unlock); unlocking a user that is not locked succeeds.

func (AccessService) UpdateGlobalRole

UpdateGlobalRole replaces a global role for an administrator (PUT /access/api/v1/roles/{role}).

func (AccessService) UpdateGroup

UpdateGroup changes the fields a patch sends for an administrator (PATCH /access/api/v2/groups/{name}). The raw body (keepsGroupUpdateBody) tells a field left out from one sent with its stored value.

func (AccessService) UpdateGroupMembers

UpdateGroupMembers adds and removes a group's members for an administrator (PATCH /access/api/v2/groups/{name}/members).

func (AccessService) UpdateOidcConfiguration

UpdateOidcConfiguration replaces an OIDC provider for an administrator (PUT /access/api/v1/oidc/{name}).

func (AccessService) UpdateOidcIdentityMapping

UpdateOidcIdentityMapping replaces an identity mapping for an administrator (PUT /access/api/v1/oidc/{provider_name}/identity_mappings/{mapping_name}).

func (AccessService) UpdatePasswordPolicy

UpdatePasswordPolicy merges the fields sent into the stored policy.

func (AccessService) UpdatePermissionResource

UpdatePermissionResource merges the body into an existing section.

func (AccessService) UpdateUser

UpdateUser changes the fields a patch sends for an administrator (PATCH /access/api/v2/users/{username}).

func (AccessService) UpdateUserGroups

UpdateUserGroups adds and removes a user's group memberships for an administrator (PATCH /access/api/v2/users/{username}/groups).

type AuthnOptions

type AuthnOptions struct {
	// Auth verifies credentials and answers whether anonymous access is on.
	Auth *authn.Authenticator
	// Store holds the permissions each principal is authorised with.
	Store Store
	// SelfAuthenticated holds "METHOD path" of the routes that verify their
	// own credential, which pass untouched.
	SelfAuthenticated map[string]bool
	// Skip reports the requests that pass untouched, credentials or not,
	// asked in order.
	Skip []func(*http.Request) bool
	// RegistryPath reports whether path is the registry's, the only place a
	// registry token is good.
	RegistryPath func(path string) bool
	// ChallengeAnonymous reports whether a request to path without
	// credentials is challenged even while anonymous access is on.
	ChallengeAnonymous func(path string) bool
	// CredentialKeepers each return the context an authenticated request
	// goes on with, in order: the hook for the operations that need the
	// credential itself, which no other request carries further than here.
	CredentialKeepers []func(context.Context, *http.Request, kernel.Principal) context.Context
	// PublicRoutes holds "METHOD path" of the routes that answer without
	// credentials while anonymous access is off.
	PublicRoutes map[string]bool
}

AuthnOptions are the values Authenticate takes from the modules, which the router composes. Credential parsing (credentials) is not among them: every credential form is accepted the same way on every route. RegistryPath and ChallengeAnonymous must be set, because Authenticate calls them without a nil check; the maps and lists may be empty.

type Deps

type Deps struct {
	// API is the access module's API. The handlers evaluate a principal the
	// middleware did not authorise through its Authorizer.
	API accessapi.API
	// Store holds the users, groups, permissions, key pairs, certificates,
	// tokens, API restrictions, settings and OIDC documents the handlers
	// read and write. The router's store is an interface, so a nil one
	// converts to a nil Store; a typed nil pointer would not, and the
	// operations would call it instead of answering 501.
	Store Store
	// Authenticator forgets its cached password policies when the security
	// API changes them, and recognises the expired access token a legacy
	// refresh presents. Nil skips both.
	Authenticator *authn.Authenticator
	// Tokens issues, refreshes and revokes access tokens; nil answers the
	// token APIs and the OIDC exchange 501.
	Tokens *token.Service
	// IDTokens verifies the subject tokens of the OIDC token exchange and
	// caches each provider's signing keys. Nil makes New build one.
	IDTokens *idtoken.Verifier
	// Settings holds token.allow_basic_auth, which lets a password sent with
	// Basic create tokens, and the global environment limit of the roles API.
	Settings accessapi.Settings
	// PasswordHash is the cost of the passwords the security API sets; the
	// zero value is production's.
	PasswordHash authn.HashParams
	// CompatVersion is the Artifactory version Access reports as its own
	// name and version (GetAccessVersion).
	CompatVersion string
	// Log receives the handlers' internal errors; nil means slog.Default.
	Log *slog.Logger
	// Repositories is the artifacts module's binding over Store. A key pair
	// delete clears the repositories' references to the pair through it in
	// the delete's own transaction, so it must take part in the transaction
	// its context carries, as the binding over the same store does. The
	// permission and role services read the repositories a section names.
	Repositories artifactsapi.Repositories
}

Deps is what the access handlers need, which the composition root supplies. A nil Store leaves every operation that reads one answering 501, as a router built to test routing alone answers.

type RequestDetails

type RequestDetails struct {
	// Rewrite each rewrite a request's body in place, or leave it unchanged.
	Rewrite []func(*http.Request) error
	// RawBody each report requests whose raw body a handler reads.
	RawBody []func(*http.Request) bool
}

RequestDetails are the access handlers' contributions to the request details the router keeps before a generated server decodes the body.

func DetailRules

func DetailRules() RequestDetails

DetailRules returns the access contributions: the policy writes, whose string-spelled booleans and numbers become JSON types (rewritePolicyBody), and the raw bodies of Access v2 permission creates (keepsPermissionBody) and group updates (keepsGroupUpdateBody).

type SecurityAPI

type SecurityAPI struct {
	// contains filtered or unexported fields
}

SecurityAPI implements the artifactory spec's security operations: users, groups, permission targets, key pairs and certificates, API restrictions, passwords and policies, and the legacy tokens. It is a partial strict server of the artifactory spec, which the composition root embeds beside the other partials and the generated stubs.

func (SecurityAPI) ActivateArtifactoryKeyEncryption

ActivateArtifactoryKeyEncryption answers an administrator DONE and changes nothing: secrets are sealed at all times (decision 0017), the state 7.x's encrypt puts the configuration in. A user who is not an administrator gets 403 and an anonymous caller 401, as SystemResource's @RolesAllowed(ROLE_ADMIN) refuses them.

func (SecurityAPI) AddCertificate

AddCertificate stores a PEM bundle of a certificate and its private key under the alias, replacing any certificate already there.

func (SecurityAPI) ChangePassword

ChangePassword is the deprecated password change, which names its user in the body and proves the change with the current password. An administrator may name anyone, with the current password all the same; anyone else only itself, and not through a narrowed token (narrowedToken), as the Access v2 change refuses one. An expired password reaches here (ownPasswordChange) with its administrator rights intact, so it is held to its own name.

func (SecurityAPI) ClearAPIRestriction

ClearAPIRestriction lifts a user's temporary API restriction for an administrator, recording who lifted it (DELETE /artifactory/api/artifactweave/api-restrictions/{userName}).

func (SecurityAPI) ConfigureUserLockPolicy

ConfigureUserLockPolicy replaces the lockout settings; omitted fields take their defaults. Disabling the policy also clears every lock.

func (SecurityAPI) CreateApiKey

CreateApiKey refuses: API keys are retired (decision 0005).

func (SecurityAPI) CreateKeyPair

CreateKeyPair stores a pair, replacing one of the same name as 7.x does (createkeypair). Repositories refer to a pair by name, so those using a replaced pair sign with the new material from the next request. The Terraform provider requires 201 with an empty object either way.

func (SecurityAPI) CreateOrReplaceGroup

CreateOrReplaceGroup creates the group or replaces its fields. It answers 201 either way, which the artifactory_group resource requires.

func (SecurityAPI) CreateOrReplacePermissionTarget

CreateOrReplacePermissionTarget creates the permission or replaces its repository section; build and release bundle sections set through v2 or Access stay.

func (SecurityAPI) CreateOrReplacePermissionTargetV2

CreateOrReplacePermissionTargetV2 creates the permission or replaces its v2 sections whole. Administrators may create; holders of MANAGE may replace the actions of one that exists, granting or revoking only the actions they hold and never MANAGE, and leaving their own entries and their groups' as they are (createorreplacepermissiontargetv2.json, decision 0006).

func (SecurityAPI) CreateOrReplaceUser

CreateOrReplaceUser creates the user or replaces its fields. It answers 201 either way, which the artifactory_user resource relies on.

func (SecurityAPI) CreatePermissionTargetV2

CreatePermissionTargetV2 creates the permission; 409 when the name is taken, which jfrog-client-go reads as "already exists".

func (SecurityAPI) DeactivateArtifactoryKeyEncryption

DeactivateArtifactoryKeyEncryption answers an administrator DONE and changes nothing, so secrets stay sealed (decision 0017). 7.x's decrypt answers 409 "Cannot decrypt without artifactory key file" only before any key exists and 405 only on SaaS; a server whose secrets are always sealed is never in the first state, and artifactweave is self-managed. 7.x's own decrypted state lasts only until the next configuration change (the reference page), so a client cannot rely on it either.

func (SecurityAPI) DeleteCertificate

DeleteCertificate removes a certificate no remote repository presents.

func (SecurityAPI) DeleteGroup

DeleteGroup removes the group and its memberships.

func (SecurityAPI) DeleteKeyPair

DeleteKeyPair removes a pair, in use or not: 7.x documents no refusal (deletekeypair answers 200, 401, 403, 404 and 500 alone), and the Terraform provider may destroy a pair before the repositories that name it. Those repositories lose their reference in the same transaction. Left behind, it would name a pair that does not exist, which every later update of the repository would then be refused for (repos.CheckKeypairs).

func (SecurityAPI) DeletePermissionTarget

DeletePermissionTarget removes the whole permission.

func (SecurityAPI) DeletePermissionTargetV2

DeletePermissionTargetV2 removes the permission. Unlike a read or a replace, it needs an administrator (deletepermissiontargetv2.json) or a Manage Resources holder.

func (SecurityAPI) DeleteUser

DeleteUser removes the user, its memberships and its tokens.

func (SecurityAPI) ExpirePasswordForAllUsers

ExpirePasswordForAllUsers expires every internal password, the caller's included.

func (SecurityAPI) ExpirePasswordForMultipleUsers

ExpirePasswordForMultipleUsers forces the named users to change their passwords; unknown names are reported, not refused.

func (SecurityAPI) ExpirePasswordForSingleUser

ExpirePasswordForSingleUser is the deprecated path form of the expiry, for one user; an unknown user is 404, as the unexpire form answers.

func (SecurityAPI) GetAPIRestriction

GetAPIRestriction returns a user's temporary API restriction to an administrator, an inactive one when none was ever set (GET /artifactory/api/artifactweave/api-restrictions/{userName}).

func (SecurityAPI) GetAPIRestrictionAudit

GetAPIRestrictionAudit lists the changes to temporary API restrictions, newest first and a page at a time, for an administrator (GET /artifactory/api/artifactweave/api-restriction-audit).

func (SecurityAPI) GetAllKeyPairs

GetAllKeyPairs lists every key pair without private material.

func (SecurityAPI) GetApiKey

GetApiKey answers 404, the documented answer when no key exists; the JFrog CLI reads it as "no key".

func (SecurityAPI) GetCertificates

GetCertificates lists the client certificates remote repositories may present to upstreams.

func (SecurityAPI) GetGroupDetails

GetGroupDetails returns the legacy group document; members only with includeUsers=true.

func (SecurityAPI) GetGroups

GetGroups lists groups with their detail URLs, written as the store's pages are read.

func (SecurityAPI) GetKeyPair

GetKeyPair returns one pair's readable projection, which the Terraform provider reads after every create. Any caller the middleware lets through may read it, as 7.x lets any authenticated user, and anonymous while anonymous access is on (getkeypair). That is safe only because the projection carries the public half alone: keypairSummary must never gain the private key or the passphrase.

func (SecurityAPI) GetKeyPairPublicKeyPerRepository

GetKeyPairPublicKeyPerRepository returns the public half of the repository's signing pair, including Alpine, Debian and RPM virtual repositories' keyPair, which clients fetch to verify signed metadata. 7.x asks only for an authenticated user, or anonymous while anonymous access is on (getkeypairpublickeyperrepository), and no read permission on the repository, so a caller that may not read a repository still learns whether it exists and which key signs it.

func (SecurityAPI) GetLegacyTokens

GetLegacyTokens lists every token in the legacy shape. Unlike GET /access/api/v1/tokens, which shows a user their own, it is admin only, as the deprecated legacy API documents (#382).

func (SecurityAPI) GetLockedOutUsers

GetLockedOutUsers lists the users the lock policy locked, written as the store's pages are read.

func (SecurityAPI) GetPasswordExpirationPolicy

GetPasswordExpirationPolicy returns the password expiry settings.

func (SecurityAPI) GetPermissionTargetDetails

GetPermissionTargetDetails returns the v1 view: the repository section with action letters.

func (SecurityAPI) GetPermissionTargetDetailsV2

GetPermissionTargetDetailsV2 returns every v2 section.

func (SecurityAPI) GetPermissionTargets

GetPermissionTargets lists every permission with its v1 detail URL.

func (SecurityAPI) GetPermissionTargetsByGroupV2

GetPermissionTargetsByGroupV2 returns the permissions granting the group.

func (SecurityAPI) GetPermissionTargetsByUserV2

GetPermissionTargetsByUserV2 returns the permissions granting the user directly; grants through its groups are not expanded.

func (SecurityAPI) GetPermissionTargetsV2

GetPermissionTargetsV2 lists what the caller may manage: every permission for an administrator or a Manage Resources holder, otherwise those it holds MANAGE on.

func (SecurityAPI) GetUserDetails

GetUserDetails returns the legacy user document, without the password.

func (SecurityAPI) GetUserEncryptedPassword

GetUserEncryptedPassword returns, in place of Artifactory's encrypted password, a reference token bound to the caller: every client that took the encrypted password accepts it as a password. Like the encrypted password it is the same on every call and lasts until the password is set or expired, which revokes it; it is also revocable through the token API. A token-authenticated caller is refused: the encrypted password stands for a password, which only a password login proves.

func (SecurityAPI) GetUserLockPolicy

GetUserLockPolicy returns the lockout settings.

func (SecurityAPI) GetUsers

GetUsers lists users with their detail URLs, written as the store's pages are read.

func (SecurityAPI) PermissionTargetExistenceCheckV2

PermissionTargetExistenceCheckV2 answers 200 or 404 with no body.

func (SecurityAPI) RegenerateApiKey

RegenerateApiKey refuses: no user holds a key to rotate.

func (SecurityAPI) RevokeApiKey

RevokeApiKey answers 200 with nothing revoked, for scripts that revoke unconditionally. deleteAll=1 needs an administrator.

func (SecurityAPI) RevokeUserApiKey

RevokeUserApiKey answers 200 for an existing user and 404 otherwise; there is never a key to remove.

func (SecurityAPI) SetAPIRestriction

SetAPIRestriction restricts a user's API access, for a reason and until a time at most seven days ahead, for an administrator (PUT /artifactory/api/artifactweave/api-restrictions/{userName}).

func (SecurityAPI) SetPasswordExpirationPolicy

SetPasswordExpirationPolicy replaces the policy: omitted fields take their defaults, not their previous values, as in Artifactory.

func (SecurityAPI) UnexpirePasswordForSingleUser

UnexpirePasswordForSingleUser clears a forced password change.

func (SecurityAPI) UnlockAllLockedOutUsers

UnlockAllLockedOutUsers clears every lock.

func (SecurityAPI) UnlockLockedOutUser

UnlockLockedOutUser is the path form the JFrog CLI sends for one user.

func (SecurityAPI) UnlockLockedOutUsers

UnlockLockedOutUsers clears the named users' locks.

func (SecurityAPI) UpdateGroup

UpdateGroup changes the fields the body carries.

func (SecurityAPI) UpdateKeyPair

UpdateKeyPair replaces the pair named in the body; repositories that reference it sign with the new material from the next request.

func (SecurityAPI) UpdateUser

UpdateUser changes the fields the body carries.

func (SecurityAPI) VerifyKeyPair

VerifyKeyPair checks a pair without storing it.

type Server

type Server struct {
	Access   *AccessService
	Security *SecurityAPI
}

Server holds the access module's two partial strict servers over one shared state: the composition root embeds Access in the access spec's strict server and Security in the artifactory spec's.

func New

func New(d Deps) *Server

New returns the access partials over d. Without d.IDTokens it builds one verifier, which both partials share, so the providers' keys stay cached between exchanges for the life of the handler.

func (*Server) CheckAPIRestriction

func (s *Server) CheckAPIRestriction(
	health func(*http.Request) bool,
	limitErr func(http.ResponseWriter, *http.Request, error),
) func(http.Handler) http.Handler

CheckAPIRestriction returns the middleware that refuses an authenticated user's request while that user's API restriction is in force. It runs after authentication, which names the user, and needs a store. The router supplies health, the probes that every caller may make, and limitErr, which answers a restriction read that failed or timed out as the request limiter answers; recovery requests (APIRecoveryRequest) always pass.

This also covers embedders with a custom Authenticator. The application supplies the policy to Authenticator as well, for native self-authentication and subsequent Current credential checks.

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(r chi.Router)

RegisterRoutes mounts the legacy token API's create and revoke (legacyTokenPath and legacyTokenRevokePath), whose form-encoded bodies the generated server cannot bind. The caller bounds their bodies, as it bounds the generated routes' bodies.

type Store

type Store interface {
	port.Store
	// Settings holds the security policies, the basic authentication
	// switch and the other access settings the handlers serve.
	Settings() settings.SettingsStore
	// Configs holds the OIDC providers and identity mappings.
	Configs() configdoc.ConfigStore
}

Store is what the access handlers read and write: the access ports, the settings and OIDC configuration documents they serve, and the transaction a key pair delete runs in. The application passes its composite store, and every call joins the transaction ctx carries. The adapter declares its own rather than taking the module root's access.Store, because a module package never imports a module root, and because the handlers also serve the OIDC configuration documents, which no binding reads.

Directories

Path Synopsis
Package login will serve browser login and the native-client approval endpoints.
Package login will serve browser login and the native-client approval endpoints.
Package scim will serve the SCIM endpoints: discovery, users, groups, filters, pagination and PATCH.
Package scim will serve the SCIM endpoints: discovery, users, groups, filters, pagination and PATCH.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL