BaGet

Configuration

You can modify BaGet Extension’s configurations by editing the appsettings.json file.

Top-level keys

Key Default Meaning
ApiKey empty global key to push and change packages; see Require an API key
PathBase . path the site is served under (. is the root)
AllowedHosts * see Restrict the host names BaGet Extension serves
PackageDeletionBehavior Unlist Unlist or HardDelete
AllowPackageOverwrites false accept a push of an existing id and version
IsReadOnlyMode false refuses pushes (packages and symbols), deletes, relists, deprecation/vulnerability changes, browser uploads, the manage page’s POSTs and an administrator’s permanent deletion of a deleted user’s packages
RunMigrationsAtStartup true apply pending database migrations when BaGet Extension starts
SettingsOverridesPath empty (= appsettings.Overrides.json) the file the Settings page saves to; relative paths start at the content root (or BAGET_CONFIG_ROOT)
Urls none the ASP.NET Core listening-address key; ineffective while Kestrel:Endpoints is set, see Listening address
Proxy:TrustedProxies, Proxy:TrustedNetworks, Proxy:TrustAnyProxy loopback only which reverse proxies may set X-Forwarded-For/-Proto, see Reverse proxies
Cors:AllowedOrigins empty (any origin, without credentials) origins allowed to call BaGet from a browser, see Single-page applications
Frontend:SpaPath, Frontend:SpaBasePath, Frontend:Mvc none, /app, true serve a built single-page application, or run without the server-rendered screens, see Single-page applications
DataProtection:KeyPath DataProtection-Keys beside the overrides file folder of the key ring, see Data protection keys

Listening address

The shipped appsettings.json sets Kestrel:Endpoints:Http:Url to http://localhost:6060. That setting outranks --urls and ASPNETCORE_URLS, which therefore have no effect. Override it with the environment variable Kestrel__Endpoints__Http__Url, or edit the file.

Reverse proxies and forwarded headers

BaGet Extension reads the client address and scheme from X-Forwarded-For / X-Forwarded-Proto, only when the request comes from a trusted proxy. By default that is loopback only (the framework default), so a client that reaches the server directly cannot spoof its address (the per-client rate limits and the log) or the scheme. These keys are read at startup, from appsettings.json, environment variables or the command line (not the Settings page).

Key Meaning
Proxy:TrustedProxies proxy addresses separated by ;, added to loopback: 10.0.0.5;fd00::1
Proxy:TrustedNetworks proxy networks in CIDR form separated by ;: 10.0.0.0/8;172.16.0.0/12
Proxy:TrustAnyProxy true believes every sender (the behaviour before this setting existed). Only safe when clients can reach BaGet through the proxy alone

An address or network that does not parse stops startup. Behind a proxy on another address without any of these, the forwarded headers are ignored: the client address is the proxy’s and an https front end looks like http.

Data protection keys

The key ring encrypts remote repository passwords, replication peer keys, sessions, antiforgery and registry tokens and reset/confirmation links. A single node keeps it in DataProtection:KeyPath (default: a DataProtection-Keys folder beside the overrides file; a relative path starts at that file’s folder), as XML files, encrypted with DPAPI (machine scope) on Windows and plain XML elsewhere: treat the folder like the database and keep it on a persistent volume (in Docker it is inside /var/baget when SettingsOverridesPath is). Losing it makes stored passwords unreadable (remote upstreams are then called anonymously) and signs everyone out. In a cluster (Ha:Enabled) the keys are in the database and this key is ignored. The folder must be writable: startup stops with a message naming DataProtection:KeyPath otherwise. Restart required; not on the Settings page.

Exit codes

baget exits with 0 when the command or the server finished, and 1 when the configuration is invalid or a command was refused or failed, so restart: on-failure and systemd see a failed start.

Require an API key

You can require that users provide a password, called an API key, to publish packages. To do so, you can insert the desired API key in the ApiKey field.

{
    "ApiKey": "NUGET-SERVER-API-KEY",
    ...
}

Users will now have to provide the API key to push packages:

dotnet nuget push -s http://localhost:6060/v3/index.json -k NUGET-SERVER-API-KEY package.1.0.0.nupkg

With accounts enabled, users can also push with keys of their own.

Restrict the host names BaGet Extension serves

The absolute URLs BaGet Extension advertises in its service index, registrations and URI templates are built from the incoming request’s Host header. By default BaGet Extension serves any host, because it is commonly run behind a reverse proxy on a host name it cannot know. If the host names are known, list them in AllowedHosts, separated by semicolons; a request with any other host is then rejected with a 400 response:

{
    ...

    "AllowedHosts": "nuget.example.com;nuget.example.com:8080",

    ...
}
Entry Matches
* any host — host filtering is off (the default)
example.com that host on any port
example.com:8080 that host on port 8080 only
*.example.com any subdomain of example.com

!!! info This is ASP.NET Core’s host filtering configuration key. If you embed BaGet Extension in your own application, call UseHostFiltering in its pipeline.

Enable read-through caching

Read-through caching lets you index packages from an upstream source. You can use read-through caching to:

  1. Speed up your builds if restores from nuget.org are slow
  2. Enable package restores in offline scenarios

The following Mirror setting configures BaGet Extension to index packages from nuget.org:

{
    ...

    "Mirror": {
        "Enabled":  true,
        "PackageSource": "https://api.nuget.org/v3/index.json"
    },

    ...
}

!!! info PackageSource is the value of the NuGet service index.

Key Default Meaning
Enabled false index packages from the upstream
PackageSource none the upstream service index URL; required while Enabled (startup fails otherwise)
Legacy false read the upstream through the NuGet V2 protocol
PackageDownloadTimeoutSeconds 600 timeout of every HTTP request to the upstream (and of import downloads)

While Enabled, a remote repository named mirror is created from these keys at startup and the default repository fetches through its settings: set credentials, cache periods or offline mode for the mirror on /admin/repositories/mirror. The URL, protocol and timeout stay owned by these keys.

Remote repositories: refuse private upstreams

An upstream URL (and Test connection) makes this server send requests to whatever address the administrator typed, so an administrator who may create remote repositories can reach what the server can reach (internal services, the cloud metadata address 169.254.169.254). Internal feeds are a normal use, hence the default is to allow them.

Key Default Meaning
Remote:BlockPrivateAddresses false refuse upstreams that are localhost, loopback, private (RFC 1918, fc00::/7), link-local, carrier-grade NAT or otherwise non-public, IPv6 forms that carry an IPv4 address (NAT64, 6to4, IPv4-compatible) judged by the address they carry. While on, the system proxy is not used (the target must be seen). Live (no restart)

Enforced when a repository is created or saved (the host name or literal address in the URL), when Test connection runs (also after DNS resolution) and on every connection a V3 or npm upstream client opens (a name that later resolves to a private address, or a redirect to one, is refused; with an HTTP proxy configured the proxy’s address is what is checked). A V2 upstream is contacted by NuGet’s own HTTP stack: only the URL’s host is checked. Mirror:PackageSource is operator configuration: if it is refused the mirror repository is not created (a warning is logged) and fetches fail.

npm repositories

Key Default Meaning
Npm:UnpublishWindow 72:00:00 how long after publishing a version its owner may unpublish it with Deploy alone; later unpublishing needs Delete. A key limited to package:pushversion always needs Delete. Zero or negative: always Delete. Live
Npm:MaxPublishBytes 536870912 largest npm publish request body in bytes (413 above); 0 = no limit. Live

See npm registry.

Docker repositories

Key Default Meaning
Oci:TokenLifetime 00:05:00 validity of a registry token from /v2/token (at least 10 seconds). Live
Oci:Service BaGet the service named in the registry’s WWW-Authenticate challenge and expected at the token endpoint. Live
Oci:MaxManifestBytes 4194304 largest manifest or index in bytes (413 above). Live
Oci:UploadExpiry 1.00:00:00 idle time after which an upload session is discarded (checked when a new upload starts, and by the Docker garbage collection). Live
Oci:PruneGrace 01:00:00 how long a layer no manifest uses is kept before Remove unused layers or the Docker garbage collection may remove it. Live

See Docker registry.

Maven repositories

Key Default Meaning
Maven:MaxFileBytes 1073741824 largest file in bytes a deploy or a remote download may store (413 above). Live

See Maven repositories.

Vulnerability scanning

Key Default Meaning
Scanning:Enabled false master switch; scanning calls OSV.dev, so it is off by default. Live
Scanning:ScanOnDeploy true queue a scan when a version is stored. Live
Scanning:RescanInterval 1.00:00:00 versions whose last scan is older are scanned again by a sweep every 10 minutes; 0 = never. Live
Scanning:OsvUrl https://api.osv.dev the OSV API root. Live
Scanning:OsvOfflinePath empty a directory or .zip of OSV records: scan without the internet. Live
Scanning:OsvTimeout, Scanning:OsvCacheLifetime 00:00:30, 01:00:00 one OSV request; how long an answer per component is reused. Live
Scanning:TrivyPath, Scanning:TrivyRegistryHost empty the trivy executable and this server’s registry address as Docker clients use it; both are needed to scan images. Live
Scanning:TrivyServerUrl, Scanning:TrivyInsecure, Scanning:TrivyRegistryUser, Scanning:TrivyRegistryPassword, Scanning:TrivyTimeout empty, false, empty, empty, 00:10:00 --server, --insecure, the credentials Trivy pulls with (the password is a sensitive setting) and the limit of one run. Live

See vulnerability scanning.

Enable package hard deletions

To prevent the “left pad” problem, BaGet Extension’s default configuration doesn’t allow package deletions. Whenever BaGet Extension receives a package deletion request, it will instead “unlist” the package. An unlisted package is undiscoverable but can still be downloaded if you know the package’s id and version. You can override this behavior by setting the PackageDeletionBehavior:

{
    ...

    "PackageDeletionBehavior": "HardDelete",

    ...
}

This setting also labels the button on a package’s management page: it reads “Unlist this version” by default and “Delete this version permanently” with HardDelete, so the page never offers a deletion the server would only unlist. Two things a hard delete does not do: it leaves indexed symbols being served from api/download/symbols/... (delete them first from the Manage page’s Symbols list), and an external search index (Search:Type=AzureSearch) is re-indexed for the ID after every unlist, relist and delete (SearchIndexChangeHandler).

Administrators (see Administrators) can always hard-delete from a package’s management page, after confirming their password, even with the default Unlist. The NuGet DELETE API keeps following this setting.

Enable package overwrites

Normally, BaGet Extension will reject a package upload if the id and version are already taken. You can configure BaGet Extension to overwrite the already existing package by setting AllowPackageOverwrites:

{
    ...

    "AllowPackageOverwrites": true,

    ...
}

Upload through the browser

/upload accepts a .nupkg or a .snupkg in two steps: the file is staged, what it contains is shown, and nothing is published until the preview is confirmed. With accounts on, the signed-in session is the identity and ownership decides what it may publish; with accounts off the page asks for the same ApiKey a push needs. IsReadOnlyMode refuses both. A .snupkg is indexed for a version the server already has - it never creates a package ID and confers no ownership. The Upload navigation entries are hidden where an upload cannot work: read-only mode, a closed maintenance gate, or accounts off with no ApiKey.

Operating note  
Temporary space Each upload is spooled to ASPNETCORE_TEMP (else the system temporary directory) before it is staged, so a browser upload needs free space there equal to the package’s size, on top of the staged copy.
Size ceiling No multipart limit of its own on the upload and push endpoints, which carry [UploadSizeLimit] (the NuGet and symbol push, the NuGet, npm and Maven upload screens and their /api/ui twins); every other form is limited to 1 MiB (FormOptions.MultipartBodyLengthLimit, since antiforgery validation buffers the whole form of any POST, anonymous ones included). Beyond it the request is rejected with a bare 400 before the page runs, so the page cannot explain it. Under IIS in-process, IISServerOptions.MaxRequestBodySize caps uploads at 250 MB and requestLimits/maxAllowedContentLength in web.config at 30 MB - the ceilings the push endpoint already has.
Unconfirmed uploads Staged under staging/ in the configured store, and removed when the preview is confirmed or discarded. Whatever nobody comes back to is swept after 24 hours - on FileSystem and Null storage; the cloud providers cannot list a prefix yet, so abandoned uploads there accumulate.
Storage:Path Do not point it at the web root: static files would then serve the store, staging/ and validation/ included. That is a pre-existing misconfiguration rather than something uploads introduce.

NuGet V2 feed

BaGet Extension serves a NuGet V2 (OData) feed at /api/v2 for clients that cannot use V3: nuget list, older Install-Package, and PowerShellGet. It is on by default.

GET /api/v2/$metadata (and /r/{repo}/api/v2/$metadata) returns the entity model as an EDMX document (application/xml, OData 2.0): the entity type NuGetGallery.V2FeedPackage (key Id + Version, every property the entries carry, m:HasStream: an entry’s content is the .nupkg), the entity set Packages and the service operations Search(searchTerm, includePrerelease, semVerLevel) and FindPackagesById(id, semVerLevel), so OData tools can generate a client from it.

To turn the feed off:

{
    ...

    "Feeds": {
        "EnableV2": false
    },

    ...
}

!!! info The OData query options $filter, $orderby, $select and $expand are ignored; $skip and $top are honoured. Search() and Packages() page by package id ($top ids, at most 1000) and emit a next link while more ids follow; they list only the versions the request allows (includePrerelease, and SemVer 2 versions only with semVerLevel=2.0.0, like FindPackagesById()).

Accounts, package owners and API keys

Accounts are on in the shipped appsettings.json (the code default, for hosts embedding BaGet Extension, is off). With them off, only the global ApiKey authenticates. Set Accounts:Enabled to false to get that behaviour back; otherwise configure them with:

{
    ...

    "ApiKey": "NUGET-SERVER-API-KEY",

    "Accounts": {
        "Enabled": true,
        "AllowRegistration": true
    },

    ...
}
Key Default Meaning
Enabled false in code, true in the shipped file turns accounts on
AllowRegistration true whether /account/register creates accounts
RequireApproval false a self-registered account (registration page, or first sign-in through the external provider) stays disabled until an administrator approves it on /admin/users; accounts an administrator creates are never pending. See Approving new accounts
InitialAdministrators, CreateDefaultAdministrator none, true see Administrators
OpenIdConnect:* none see Sign in with OpenID Connect
OpenIdConnectProviders:<id>:* none named providers, see Several providers

Users then sign in at /account/login, create an account at /account/register (unless AllowRegistration is false), and create API keys at /account/apikeys. /account/packages lists the IDs they own, directly or through an organization, and links to each one’s /packages/{id}/manage. A key is shown once, and has:

Property Meaning
Scopes package:push (new IDs and new versions), package:pushversion (new versions of owned IDs only), package:unlist (unlist, relist, delete, deprecation and vulnerabilities), and for administrators only admin:api (the administration REST API; never given to sessions or npm tokens)
Package glob pattern the IDs the key applies to, * as a wildcard, for example Contoso.*
Repositories optional: the repositories the key may be used in (tick them on /account/apikeys; none ticked = every repository, as every key was before). See Repository-scoped keys
Expiry after which the key stops working

Who may change a package:

!!! warning “Upgrade note: keyless pushes are refused” Earlier releases shipped with accounts off, so a default install accepted dotnet nuget push with no key. With accounts on and ApiKey empty, a push without a key now gets 401; BaGet Extension logs a warning at startup. Fix CI by pushing with -k <key>, using a user key from /account/apikeys (or the global ApiKey), or restore the old behaviour with "Accounts": { "Enabled": false }.

!!! warning With accounts off, set ApiKey. Without it the server is open: anyone may push anything.

Approving new accounts

With Accounts:RequireApproval on, /account/register creates the account but does not sign the user in, and no route (password, two-factor, external provider, API key) works for it until an administrator approves it. The user is told to wait (also when email is configured: the registration result page and the email confirmation page say approval is needed; the confirmation mail does not). A sign-in attempt with the right password says the account awaits approval; a wrong password gets the usual “incorrect” message and counts as a failed attempt, so a pending account locks out like any other and a locked-out one answers “locked” whatever the password (passwords are not revealed; a “locked” answer shows the name exists, as for every account). npm login follows the same rule.

Administrators

An account can be an administrator: a flag kept in the database, on the account. An administrator reaches /admin/users (the “Users” entry of the account menu), where they promote and demote other accounts, each time confirming with their password (or by signing in again with the provider, for an account without one). Everyone else, and every request while accounts are off, gets 404 there.

Default administrator

   
User name Admin
Password Admin1234!
Created at startup, only when accounts are on (Accounts:Enabled, the default) and the database has no users at all (a fresh install)
Not created when any user exists (an upgraded server, or users registered first), or Accounts:CreateDefaultAdministrator is false

The password is public: sign in at /account/login and change it at once on Account > Settings (/account/settings). Every start logs a warning while Admin still has it; nothing else forces the change. Admin is an ordinary account: once another administrator exists it can be demoted or deleted on /admin/users.

Lost access: baget account reset-password Admin sets a generated password (printed once) and switches off two-factor authentication, and baget account promote <user> makes any existing account an administrator (see the table below).

"Accounts": {
    "InitialAdministrators": "alice;bob"
}
Setting or command Meaning
Accounts:InitialAdministrators User names, separated by ;, promoted at start only while no administrator exists (it bootstraps an empty server). Only accounts that already exist are promoted; once any administrator exists the list is ignored, so registering a listed name later grants nothing and a demotion is not reversed.
Accounts:CreateDefaultAdministrator Default true. On a server with no users at all, startup creates the administrator Admin with password Admin1234! (email counted as confirmed, so it can sign in while SMTP is configured). Every start warns until the password is changed. Set false to bootstrap only through InitialAdministrators or account promote.
Accounts:SessionTokenLifetime, Accounts:SessionRefreshLifetime, Accounts:SessionMaxLifetime Defaults 00:15:00, 14.00:00:00 and 30.00:00:00. Lifetime of the access and refresh tokens of POST /api/ui/session, and the longest a session lasts from the sign-in however often it is refreshed (sessions). Not shown on the Settings page; a changed password or “sign out everywhere” ends every token regardless.
baget account promote <user> Makes the user an administrator. Needs Accounts:Enabled; exit code 1 for an unknown user.
baget account approve <user> Enables a self-registered account that waits for approval (Accounts:RequireApproval). Needs Accounts:Enabled; exit code 1 for an unknown user. promote approves too.
baget account demote <user> Removes the flag. Exit code 1 for an unknown user or the last administrator.

User powers (/admin/users; each action asks for the administrator’s password, and none applies to your own row, which stays on /account/settings):

Action Behaviour
Name (/admin/users/{name}) The user’s detail page, built from sections: account, organizations, API keys (see below).
Packages Opens /admin/users/{name}/packages.
Create a user The Create a user form: name, optional email, and a typed password, a generated one (blank field; shown once, like a reset) or Send an invitation (needs SMTP and an address): the account gets an unknown random password and is mailed a reset link to choose its own. A name used by a user or organization is refused. The address counts as confirmed. Logged at Warning.
Reset password, Generate Replaces the password with a generated one, shown once on the response (no redirect, Cache-Control: no-store, never stored or logged). Two-factor is switched off, a lockout lifted, an unconfirmed email address marked confirmed, the user’s sessions end.
Reset password, Email link Mails the user a reset link. Only offered while SMTP is configured and the user has an address; no rate limit.
Delete (/admin/users/{name}/delete) Removes the account, its API keys and its ownerships. The last administrator cannot be deleted.

Email (optional)

Email is off until Email:Smtp has a Host and a From. While it is off, nothing that needs email is offered, and sign-in does not require a confirmed address. When it is on, sign-in requires one.

{
    "Email": {
        "Smtp": {
            "Host": "smtp.example.com",
            "Port": 587,
            "UserName": "baget",
            "Password": "...",
            "EnableSsl": true,
            "From": "BaGet Extension <baget@example.com>"
        }
    }
}
Key Default
Host, From none; both required to switch email on
Port 587
EnableSsl true
UserName, Password none

EnableSsl uses implicit TLS on port 465 and STARTTLS otherwise; false sends in the clear. A send failure is logged and reported to the user as a failure.

Links in emails need Site:PublicUrl. Confirmation and password-reset links are never built from the request’s Host header, which anyone can forge (a forged Host on “forgot password” would otherwise put the attacker’s address in the victim’s mail).

Configuration Links point at
Site:PublicUrl set (absolute http/https, a path is allowed: https://example.com/feed) Site:PublicUrl
No PublicUrl (whatever AllowedHosts says) email is switched off and a startup warning says so

AllowedHosts does not help: even a restricted host list leaves the scheme to X-Forwarded-Proto, which a client can spoof to downgrade a link to http.

{ "Site": { "PublicUrl": "https://packages.example.com" } }

An invalid PublicUrl fails startup. While email is switched off for this reason, nothing that needs it is offered and sign-in does not require a confirmed address, exactly as with no SMTP.

Other rules with email on:

Without email, an administrator recovers an account from the command line:

baget account reset-password <user>

It prints a generated password, switches off the user’s two-factor authentication and lifts any lockout, and marks the user’s email address confirmed (the administrator at the console is trusted). It needs Accounts:Enabled and works with or without SMTP.

Turning SMTP on with existing users. Sign-in then requires a confirmed address. A user with an address who knows their password can use “Forgot password” (following the link confirms it). A user with no address cannot sign in: the administrator runs baget account reset-password <user> --email <address>, which sets the address, marks it confirmed and prints a new password. The Users page does the same: its Confirm section takes the address, used by Generate a password.

Email also enables Contact owners on a package page (/packages/{id}/contact-owners, signed-in users only). The message goes, one email each, to the owning users with a confirmed address and to the administrators of owning organizations, with the sender in Reply-To; the sender never sees owner addresses. One message per sender per package every 10 minutes, counted in memory per process (it resets on restart and is not shared between instances). Without email the page answers 404 and the link is not shown.

Avatars

Owners, profiles and the account menu show a Gravatar (d=retro), keyed by the MD5 of the user’s email, or of the name for organizations and users without an email. Every avatar is a request from the visitor’s browser to gravatar.com carrying that hash. A private feed can turn them off, which shows initial-letter placeholders instead:

{ "Site": { "UseGravatar": false } }

Site:UseGravatar defaults to true.

Organizations

Signed-in users create organizations at /account/organizations. An organization can own packages like a user; its members act for it, and its administrators add and remove members. User and organization names share one namespace.

Sign in with OpenID Connect

To let users sign in with an external provider such as Microsoft Entra ID:

{
    ...

    "Accounts": {
        "Enabled": true,
        "OpenIdConnect": {
            "Authority": "https://login.microsoftonline.com/<tenant-id>/v2.0",
            "ClientId": "<client-id>",
            "ClientSecret": "<client-secret>",
            "DisplayName": "Microsoft"
        }
    },

    ...
}

Authority and ClientId are required: without both, the provider is not offered. DisplayName (default OpenID Connect) labels the sign-in button. Register https://<your-host>/signin-oidc as the redirect URI. The first sign-in creates an account, whatever AllowRegistration says: the provider decides who may sign in. This single block is the provider with id oidc.

Several providers

Accounts:OpenIdConnectProviders:<id> lists named providers, each with its own button on the sign-in page. Restart-required (the handlers are registered at startup); an invalid entry stops startup. Edit them on the Settings page (Accounts section, Sign-in providers; password-confirmed, the secret never shown back, a blank secret keeps the saved one) or in the configuration:

"Accounts": {
    "Enabled": true,
    "OpenIdConnectProviders": {
        "entra": {
            "DisplayName": "Microsoft",
            "Authority": "https://login.microsoftonline.com/<tenant-id>/v2.0",
            "ClientId": "<client-id>",
            "ClientSecret": "<client-secret>",
            "Scopes": "groups",
            "Parameters": { "domain_hint": "example.com" },
            "AdministratorClaim": "roles",
            "AdministratorValue": "baget-admin",
            "GroupClaim": "groups",
            "GroupMappings": { "<group-object-id>": "Developers" }
        },
        "google": {
            "DisplayName": "Google",
            "Authority": "https://accounts.google.com",
            "ClientId": "<client-id>",
            "ClientSecret": "<client-secret>"
        }
    }
}

The <id> is the authentication scheme, the stored login-provider name (UserLogins.LoginProvider) and part of the callback path: 1 to 32 lower-case letters, digits and - (read without case, kept lower-case; used once). Register https://<your-host>/signin-oidc-<id> as the redirect URI (/signout-callback-oidc-<id> after a sign-out). A provider without Authority and ClientId is not offered. oidc is reserved while the single block is configured (startup error); with the block unconfigured a named oidc works (callback /signin-oidc-oidc).

Field Meaning
Authority, ClientId, ClientSecret, DisplayName As the single block (the name defaults to the id)
Scopes Extra scopes separated by spaces or ; (openid profile email are always requested)
Parameters Extra authorization request parameters (domain_hint, login_hint…). Never replace what BaGet sets: prompt and max_age of a re-authentication, state, nonce, redirect_uri, client_id, scope, response_type, response_mode, PKCE
UserNameClaim, EmailClaim, EmailVerifiedClaim Claims read for the new account (defaults preferred_username, email, email_verified; the user name falls back to the email’s local part). The address is confirmed only when that provider’s verified claim is true
AdministratorClaim + AdministratorValue Opt-in, together. See below
GroupClaim + GroupMappings Opt-in. Claim value to BaGet group name; a value holds no :

Claim names are those of the token (roles, groups, email). The OpenID Connect handler renames some incoming claim types (role and roles become the .NET role claim type, group a URI, email, sub, given_name and family_name likewise; groups is not renamed): a name is matched as written and as the handler renames it, so roles and role find the same claim. Claims must be in the ID token.

Several providers, several accounts. The first sign-in through a provider creates its own account; nothing is linked by email. A signed-in user links further providers (and unlinks them) under Sign-in providers on the account settings page (password-confirmed; the only way to sign in cannot be unlinked). Re-authenticating (for an account without a password) uses a provider linked to the account, asking which when there are several.

Administrator and group mapping. With AdministratorClaim/AdministratorValue set, the provider decides who is an administrator for the users who sign in through it: at each of their sign-ins the flag is set when the claim holds the value and cleared when it does not (never the last administrator; a promotion also approves a pending account). Grant it only to a provider you trust with administrator rights, and only claims the provider controls. With GroupMappings, each sign-in adds the user to the mapped groups whose value is present and removes them from the mapped groups whose value is absent; other groups are untouched and a group name that does not exist is logged and skipped (never created). Users who never sign in through that provider are not affected. Changes go through the usual services (the access model refreshes) and are audited with the actor provider:<id> (account.promote / account.demote in the admin audit, group.member.add / .remove in the access audit). While the server is read-only the mapping waits for the next sign-in.

Verified packages

An owner can be marked as verified for a package ID, which search reports as verified. There is no page for this yet; it is set through PackageOwnershipService.SetVerifiedAsync.

Single-page applications

A frontend written against /api/ui can run on its own origin, or be served by BaGet. Restart-required; not on the Settings page. An invalid value stops startup.

Setting Default Meaning
Cors:AllowedOrigins empty Origins (https://app.example.com), separated by ;. Empty: the APIs answer any origin without credentials (they authenticate with headers a page sets itself), except the endpoints that sign a visitor in or prepare for it (/api/ui/session*, /api/ui/antiforgery, /api/ui/account/*), which are same-origin only, so no other page can script them from visitors’ browsers. A list: those origins may call /api/ui with credentials (the cookie with its antiforgery header, readable answers, the X-Session-* headers) and call the session endpoints; nothing else changes: the package protocols, /api/v1 and the registry keep “any origin, no credentials”, so listing an origin gives it no more reach there than any web page has. The cookie sign-in endpoints stay same-origin. The same list says where the external sign-in may return (returnUrl)
Frontend:SpaPath empty Folder with a built application (it must contain index.html, else startup fails). Relative paths start at the content root
Frontend:SpaBasePath /app URL path it is served under: its files, and index.html for any other GET below it (client-side routes; a missing file with an extension stays 404). Fallback endpoints have the lowest priority, so /api, the protocol routes and the screens are never shadowed; the root, the first segment of any route BaGet maps (derived at startup) and a fixed list (api, v3, v2, r, scalar, openapi, health, _content, admin, account, packages, upload, …) are refused at startup. Same-origin external-sign-in return addresses must lie under it
Frontend:Mvc true false serves no server-rendered screen (no Views, no /account/login, no home page) and the host answers the APIs (and the application) only; emails then link to the application (routes) and the cookie’s login path is {SpaBasePath}/sign-in
Frontend:SpaUrl empty Absolute address of a single-page application hosted elsewhere (https://app.example.com): account emails link to {SpaUrl}/confirm-email and /reset-password. Takes precedence over SpaLinks. With Frontend:Mvc=false and email configured, one of SpaPath, SpaUrl or SpaLinks=true is required, else the host does not start (no email link may point at a 404)
Frontend:SpaLinks true only with SpaPath set when Mvc=false true makes emails link to the application’s routes (confirm-email, reset-password, sign-in under the base path) even with the screens on, or with no SpaPath (an application a reverse proxy serves there); false keeps the screens’ links

Search sort

The package list offers Most downloaded and Recently updated beside relevance (web UI only; the V3 search API has no sort parameter and is unchanged). The Database search provider sorts on the server. AzureSearch and Azure Table do not (the index has no sortable published field, and Table storage cannot order), so the control is hidden there.

Validate packages before serving them

The validation pipeline is off by default (Validation:Enabled and RequireSignedPackages default to false); with it off a push is indexed at once. Turn it on with:

{
    ...

    "Validation": {
        "Enabled": true,
        "RequireSignedPackages": false
    },

    ...
}

A push is then answered 202 Accepted, and the package is checked in the background before it appears. Until then it cannot be found or downloaded. The checks are:

A package that fails is quarantined and never served. Its owners can see why with GET /v3/package/{id}/{version}/validation, sending their API key in X-NuGet-ApiKey. Pending validations resume when BaGet Extension restarts. A run that throws (not a failed step) is queued again up to 5 times, after 30 s doubling each time, then stays pending until the next start or an administrator rejects it (a reject stops a validation still running on that node and waits for it, so nothing is published afterwards; the runner also re-checks the submission right before indexing).

Symbols: a .snupkg needs the published package, which exists only once validation releases it. Pushed earlier, it answers 404 (with the reason in the body) and is not kept: push it again after the release (dotnet nuget push of a .nupkg sends the .snupkg right behind it, so with validation on push the symbols in a second step).

Administrators see and decide on stuck submissions of every repository at /admin/validation (menu: Validation queue):

Action Effect
Retry Resets the steps to pending and queues the submission again (needs the staged file)
Release Indexes the quarantined package although validation failed. Needs the administrator’s password; logged as a warning and recorded with IAdminAudit; the failed verdicts stay on record
Reject Deletes the staged file and the submission’s rows; also for a submission stuck pending. Needs the password; audited

Release applies to quarantined submissions only, Reject also to pending ones; all three are refused with 503 while the server is read-only for maintenance.

Repository signing

BaGet Extension can repository-sign every package that passes validation:

{
    ...

    "Validation": {
        "Enabled": true,
        "RepositorySigningCertificatePath": "/secrets/repository-signing.pfx",
        "RepositorySigningCertificatePassword": "...",
        "RepositorySigningServiceIndexUrl": "https://nuget.example.com/v3/index.json"
    },

    ...
}

The certificate needs the code signing usage. RepositorySigningServiceIndexUrl must be your public, https service index URL: NuGet rejects repository signatures for any other scheme. BaGet Extension then advertises the certificate through the RepositorySignatures/5.0.0 resource. Signing is on while RepositorySigningCertificatePath is set; if RepositorySigningServiceIndexUrl is not an absolute https URL, the package fails the final indexing step and is quarantined.

Catalog

BaGet Extension keeps a NuGet catalog, an append-only log of package changes that mirrors can follow. It needs no configuration. Packages pushed before the catalog existed are added with:

dotnet BaGet.dll catalog rebuild

Each repository has its own catalog; catalog rebuild --repository <name> rebuilds a repository other than default. Administrators can also start it, import downloads and (Docker repositories) the garbage collection (with a dry run), per repository at /admin/operations (menu: Operations): a background job, one run at a time per operation and repository, with its last status (counts or error) kept in memory until the next start. Starting is refused with 503 while the server is read-only for maintenance.

The catalog is not available with Azure Table Storage.

Site:TermsOfUsePath and Site:PrivacyPolicyPath point at Markdown files (absolute, or relative to the content root). They are served at /terms and /privacy, and the footer links to each only while its path is set; BaGet Extension ships no legal text. A page whose path is unset or whose file is missing answers 404. The path must end in .md and contain no .. segment (the pages are public, so no other file may be served); any other value is refused when saved on the Settings page and at startup.

{ "Site": { "TermsOfUsePath": "legal/terms.md", "PrivacyPolicyPath": "legal/privacy.md" } }

Private feeds

A repository can require authentication to read: switch off Anonymous read on /admin/repositories/{name} (or remove the Anyone reads every repository permission target) and anonymous callers get 401 with a Basic challenge, which NuGet clients answer with an API key as password. See Access control for the model, the upgrade defaults (nothing changes until you edit them) and the client setup. Needs accounts for per-user keys, and a relational database.

Upgrading. A repository whose Anonymous read was saved as off before access control existed becomes private on upgrade (the switch did nothing before). The setting is kept, and a startup Warning names every such repository with no Read grant for anyone but administrators, until you switch it on or grant Read.

Storage

Storage:Type picks where package and symbol content lives (case-insensitive):

Shipped default FileSystem; the code has none, and a missing or unknown Type fails startup. Cloud providers require their identifying keys (bucket or container, region, credentials) and fail startup without them.

Type Keys under Storage Guide
FileSystem (default) Path; empty means the current working directory local
AzureBlobStorage ConnectionString, or AccountName and AccessKey; Container; DownloadUriExpiry (default 10 minutes) Azure
AwsS3 Region, Bucket, Prefix; AccessKey and SecretKey (or UseInstanceProfile, AssumeRoleArn) AWS
GoogleCloud BucketName Google Cloud
AliyunOss AccessKey, AccessKeySecret, Endpoint, Bucket, Prefix Alibaba Cloud
Null none; stores nothing  

Search:Type picks the search index (shipped default Database; a missing or unknown value fails startup):

Type Notes
Database (default) searches the package database
AzureSearch AccountName and ApiKey under Search
Null no search results

Database configuration

BaGet Extension supports multiple database engines for storing package information:

!!! info Azure Table Storage only stores packages. Accounts, the catalog, the validation pipeline, statistics, abuse reports, deprecation and vulnerabilities need one of the relational databases.

Each database engine requires a connection string to configure the connection. Please refer to ConnectionStrings.com to learn how to create the proper connection string for each database engine.

You may configure the chosen database engine either using environment variables or by editing the appsettings.json file.

Environment Variables

There are two environment variables related to database configuration. These are:

appsettings.json

The database settings are located under the Database key in the appsettings.json configuration file:

{
    ...

    "Database": {
        "Type": "Sqlite",
        "ConnectionString": "Data Source=baget.db"
    },

    ...
}

There are three settings related to the database configuration:

IIS server options

IIS Server options can be configured under the IISServerOptions key. The available options are detailed at docs.microsoft.com Note: If not specified, the MaxRequestBodySize in BaGet Extension defaults to 250MB (262144000 bytes), rather than the ASP.NET Core default of 30MB

A Docker registry (large layers sent in one PATCH) also needs requestLimits maxAllowedContentLength in web.config raised (30 MB default, 4 GB ceiling); see Streaming storage.

{
    ...

    "IISServerOptions": {
        "MaxRequestBodySize": 262144000
    },

    ...
}

Logging

The host logs with Serilog, configured only from the Serilog section (levels, sinks, retention); libraries log through Microsoft.Extensions.Logging and need no change. The old Logging section is no longer read.

Where What
Console [HH:mm:ss LVL] SourceContext: message, Information and up
logs/baget-YYYYMMDD.log same events, daily files, 14 kept, rolls at 50 MB (baget-YYYYMMDD_001.log)
Windows Application event log Windows only: Warning and up, source .NET Runtime (as before, no administrator right needed)

Telemetry

Off in code (Telemetry:Enabled is false), but the shipped appsettings.json sets Enabled to true with Otlp:Endpoint http://localhost:4317 (Grpc), so a local collector such as Jaeger is used when present; set Telemetry__Enabled=false to switch it off. The server emits traces and metrics with System.Diagnostics (ActivitySource / Meter named BaGet); the host exports them over OTLP (OpenTelemetry) only while Telemetry:Enabled is true and an endpoint is set. Logs go out through a Serilog sink. Keys apply without a restart, except ServiceName and Metrics:ExportInterval (read at startup):

Key Default Meaning
Telemetry:Enabled false in code, true in the shipped file Master switch. Off: spans are not recorded, nothing is queued, no connection is made
Telemetry:ServiceName baget service.name of every signal, read once at startup (restart)
Telemetry:Otlp:Endpoint empty Traces collector, absolute http(s) URL, for example http://jaeger:4317; empty = no traces
Telemetry:Otlp:Protocol Grpc Grpc (port 4317) or HttpProtobuf (4318; /v1/traces, /v1/metrics, /v1/logs is appended)
Telemetry:Otlp:Headers empty key=value,... request headers, for an API key (sensitive: masked on the Settings page, never logged or shown)
Telemetry:Otlp:Timeout 00:00:10 Per-export timeout
Telemetry:Traces:Enabled / SamplingRatio / Database true / 1.0 (0 to 1) / true Trace export, share of new traces kept (a trace sampled upstream is kept), database command spans
Telemetry:Metrics:Endpoint / ExportInterval empty / 00:01:00 Metrics collector (empty = not exported) and period (restart)
Telemetry:Logs:Endpoint / MinimumLevel empty / Information Logs collector (empty = not exported) and lowest Serilog level

An invalid endpoint (not absolute http or https), protocol, level, a sampling ratio outside 0 to 1 or a non-positive duration stops the server at startup.

Jaeger accepts traces only (its OTLP receiver answers Unimplemented to metrics and logs), so metrics and logs have their own endpoints, for example an OpenTelemetry Collector. A typical setup:

Telemetry__Enabled=true
Telemetry__Otlp__Endpoint=http://jaeger:4317

A push then shows in Jaeger (UI on 16686) as one trace: the ASP.NET Core request, package.index, and the database commands. See the Docker example.

Traced: incoming requests (static files excluded), outgoing HTTP calls (mirror, upstream), database commands (Telemetry:Traces:Database; the SQL text, also under the newer database semantic conventions, is removed from the spans before export), the spans package.index, package.validate, mirror.fetch, database.copy (one database.copy.table child per table). Metrics: baget.packages.pushed, baget.downloads, baget.validation.results, plus ASP.NET Core, HTTP client and .NET runtime metrics.

Never exported: query-string values (the instrumentation records apikey=Redacted), request headers (such as X-NuGet-ApiKey), SQL text, connection strings; the OTLP Headers value. Spans and metrics carry no user names or email addresses. Logs reach the collector exactly as Serilog would write them, so they do include whatever the application logs, such as the audit lines naming the acting administrator and the affected user (settings changes, administrator promotion, password resets, account deletion); point Logs:Endpoint only at a collector you trust with that. The Microsoft.AspNetCore.Hosting.Diagnostics Warning floor still keeps request URLs out; each log event carries TraceId / SpanId of the request it was written in.

Never blocks, never throws into a request. Spans wait in a bounded queue (2048) and are dropped when the collector is down; export runs on a background thread with the Otlp:Timeout. Failures are kept in TelemetryStatus (per signal: last attempt, last success, failing since, scrubbed last error without headers or URL paths). TelemetryConnectionTester sends one test span to the settings given, saving nothing.

On the Settings page (a host that does not export telemetry, such as an embedded one, shows a note that these settings have no effect there; they stay editable for a host sharing the file) the Telemetry section starts with a status table, one row per signal: Off (telemetry or the signal is disabled), Not configured (no endpoint), Configured, nothing exported yet, Last export ok at … or Failing since … with the scrubbed error (and the spans dropped when the queue was full). Test connection sends one test span (10 s timeout) to the endpoint, protocol and headers currently typed in the form, saved or not, and shows Connection ok or the scrubbed error; nothing is saved and telemetry is not switched on. It asks for your password like a save, is for administrators only, and a blank Headers field tests with the saved headers (tick Clear to test with none).

Changing the endpoint, protocol, headers or timeout rebuilds the exporter in place; the old one finishes its running export first and no queued span is lost. Any configuration reload fires this check, but an exporter whose settings did not change is kept.

Settings page

Settings changed on the server’s Settings page are saved to a JSON file, so appsettings.json and its comments stay untouched. The file is appsettings.Overrides.json in the content root (or in BAGET_CONFIG_ROOT); set SettingsOverridesPath (also as the environment variable SettingsOverridesPath) to put it elsewhere.

Source, lowest to highest precedence Notes
appsettings.json, appsettings.{Environment}.json shipped defaults
the overrides file saved by the Settings page, reloaded when it changes; sits right after the last appsettings*.json, so user secrets (Development) outrank it
environment variables, command line an operator’s explicit setting still wins; the page marks a saved value that one of these overrides, because the saved value then has no effect

Using the Settings page

Read-only maintenance gate

While a maintenance job (such as a database copy) runs, BaGet Extension makes the database read-only with an in-memory gate (MaintenanceGate). It is not a setting and is never saved: a restart opens it.

While the gate is closed Behaviour
Any other database write (push, delete, unlist, sign-up, failed sign-in, API keys, owners, abuse reports, Settings page save) refused with HTTP 503 and Retry-After: 60
Reads: feeds, search, downloads, pages work; a download is served but not counted
Pushes (also with Validation:Enabled, which stages the file) and catalog entries refused before any file reaches storage, so a retry after the gate opens is clean
Sign-in a correct password completes: the failed-attempt counter reset (an incidental write) is skipped, so an administrator can sign in after a copy to see the status and restart instructions. A wrong password, sign-up and every other write stay refused (counting a failed attempt is a write)
Validation worker logs a warning, keeps the submission pending and retries every 30 s
Pages show a “Read-only” banner with the reason

High availability

Ha:* runs several nodes behind a load balancer; it is off by default and every key needs a restart. A node refuses to start with Ha:Enabled on SQLite, Azure Table, the file system store or without Ha:ConnectionString. See High availability for the keys, what is shared and the health endpoints.

Key Default Meaning
Ha:Enabled false Cluster mode
Ha:Backend Redis The only backend
Ha:ConnectionString empty Redis connection string (sensitive)
Ha:NodeName machine name + suffix Name on the Cluster page
Ha:KeyPrefix baget Prefix of every Redis key
Ha:KeyCertificatePath / Ha:KeyCertificatePassword empty PFX that encrypts the data protection keys kept in the database (same on every node; password sensitive). Unset = keys stored unencrypted, warned at start. See High availability
Ha:LeaseDuration 00:00:30 How long a lease of a stopped node holds (min 3 s)
Ha:SyncInterval 00:00:02 Heartbeat and pick-up interval (min 100 ms)

Moving to another database

On the Settings page, changing Database:Type or Database:ConnectionString between two relational databases (SQLite, SQL Server, PostgreSQL, MySQL, in any direction, also the same engine on another server) shows Copy all data to the new database (ticked). With it ticked, Save does not save: it queues a copy, and the settings are saved only after the copy is verified. Unticked, or with AzureTable on either side (no option shown), Save behaves as before.

Step Detail
1. Read-only The gate closes when the copy is accepted (pushes etc. get 503).
2. Source Checked first, before the target is created, migrated or changed. Refused if it has pending migrations or holds what the target cannot, judged per target engine and column: strings longer than the model’s maximum length (SQL Server, PostgreSQL, MySQL; SQLite does not enforce lengths), values of a unique index or key (primary or alternate) differing only by case where the target column compares case-insensitively (SQL Server and MySQL by default; any COLLATE NOCASE / citext / *_ci column; not SQLite or PostgreSQL by default), local-time dates (PostgreSQL). All problems are listed at once, before anything is copied.
3. Target Must be reachable (a new SQLite file or a database the login may create is created) and, after its schema is migrated, every table empty. A current target that holds rows is refused and nothing is changed; one that needed migrating and then proves not empty keeps its updated schema, and the refusal says so.
4. Copy Tables in foreign-key order (Identity’s included), 1000 rows per batch, original keys kept; SQL Server IDENTITY_INSERT and PostgreSQL sequences are handled, so keys generated later continue after the highest copied one.
5. Verify Row counts and an order-independent checksum of the keys (engines sort text differently) must match per table.
6. Save Database:Type, Database:ConnectionString (and MySqlServerVersion if changed) are saved. The gate stays closed until you restart BaGet: writes accepted before the restart would land in the old database.