Loki SSO and identity integration

Loki has no login of its own, so access control depends on the proxy and Grafana you put in front of it. This page covers the decisions, build sequence, effort and checks for SSO and tenant mapping.

On this page

How Loki SSO works when Loki has no login of its own

If your staff must sign in with corporate identity before they query logs, you need to know first that Loki has no login of its own. Loki's documentation says you must place an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it. That proxy, together with the tenant selection rules behind it, decides who sees which logs. Loki is multi-tenant only when auth_enabled is set to true, and it identifies the tenant on every request from the X-Scope-OrgID header. Nothing in Loki checks that a caller is entitled to the tenant named in that header, so the proxy has to make that check before a request reaches Loki.

The header is only as trustworthy as the path that sets it. If a client can send X-Scope-OrgID directly to Loki, or the proxy passes through a value the user supplied, any user can read any tenant. The proxy must strip any client-supplied tenant header and set it itself from the verified identity, and Loki's ports should be reachable only from the proxy. Confirm this with a test: send a request with a forged header through the public path and directly to the Loki service, and check that both are refused or rewritten. Also confirm how your chosen proxy handles header injection and group-to-tenant mapping, since the mapping logic is yours to write and maintain.

Grafana login is a separate layer from Loki access. Signing into Grafana with single sign-on controls who can open dashboards and Explore, but a user who reaches the Loki endpoint directly, using a token or a copied API call, bypasses Grafana entirely. Grafana's data source configuration also has to send the right tenant header for each team, so a shared data source can quietly expose one team's logs to another. Plan the two layers as one design: a proxy that authenticates and maps identity to tenants, and a Grafana setup that only uses data sources that match each team's permitted tenant. Ask whether Grafana Enterprise Logs, which adds label-based access control and token authorization, fits your requirement, and treat that as a separate decision from the open-source build.

Which Loki identity integration pattern fits your team

This table compares four ways to put identity in front of Loki: OAuth2 Proxy, Pomerium, nginx or HAProxy with a custom auth module, and Grafana Enterprise Logs token authorization with label-based access control. Settle your tenant model first, then read each row for the identity provider fit and the operational load you would own. The main takeaway is that the open-source options all add a proxy you run and patch, while the commercial option moves access control into the product.

Decision factorOAuth2 ProxyPomeriumnginx or HAProxy with custom auth
When it fitsTeams with an OIDC identity provider that want a small, single-purpose login proxy for Loki and Grafana endpointsTeams that want identity-aware routing and per-route policy in one component, including for non-Loki internal toolsTeams with an existing gateway standard and in-house engineers who can write and test the auth module
Tenant mappingMaps identity claims to a header you set, so X-Scope-OrgID must be derived in config or a companion rulePolicy can set the tenant header per route based on identity attributes, which you must test for each teamMapping lives in your own code or config, so every new team or environment is a change you make and review
Components to runProxy service, identity provider client registration, session store if you add one, and TLS terminationPomerium core services, identity provider integration, policy file, and TLS terminationGateway, auth service or script, identity provider integration, and TLS termination
Certificate and session handlingCookie and session settings are set by the proxy; confirm cookie domain and TLS behavior with your security teamSession and certificate handling is built into the product; confirm defaults against your key management rulesYou design session expiry, token validation and certificate rotation, and test each failure path
Upgrade ownershipYou track proxy releases and identity provider changes; upgrade and test with each Loki version changeYou track product releases and policy syntax changes; retest routing after each upgradeYou own the gateway, the module and its dependencies for the full life of the stack
Custom code to maintainUsually configuration only, with minimal scriptingPolicy configuration, with occasional custom checks depending on your rulesMost custom code of the four options, including token checks and tenant header logic
Grafana Enterprise Logs optionNot applicable, because GEL adds token authorization and label-based access control inside the productNot applicable, because GEL adds token authorization and label-based access control inside the productNot applicable, because GEL adds token authorization and label-based access control inside the product

How a log query travels from SSO login to a tenant

The path starts in the user's browser, which signs in through the identity provider and reaches Grafana. Grafana sends each query to the authenticating reverse proxy, which validates the session and sets the X-Scope-OrgID header before forwarding it to Loki. Loki's query frontend and queriers then read only that tenant's chunks and index from object storage. Machine clients such as Alloy push logs through the same proxy with their own tenant header, so check that the proxy overwrites any tenant header a caller supplies.

Query path from login to tenant-scoped reads, with the proxy-to-Loki trust boundary marked.

Building Loki identity integration step by step

This sequence takes Loki from an open endpoint to one where every request is authenticated, mapped to a tenant the proxy controls, and queried through Grafana SSO. Each step ends with a check you can run and record before moving on.

  1. Confirm the tenant model in writing

    Before any configuration, the platform owner, security lead and the teams that query logs agree on which tenants exist, which identity groups map to each tenant, and who may read across tenants. Record the mapping as a table with one row per group and one tenant ID per row, and get sign-off from the security owner. Done means the table exists, names every group that will query logs, and states explicitly that no group receives cross-tenant read access unless a named owner has approved it. Loki itself does not enforce this mapping, so the document becomes the reference for every later check.

  2. Enable auth_enabled and test refusal

    Set auth_enabled to true in the Loki configuration on every component that serves reads or writes, then restart and confirm the change took effect on each one. Send a query and a push request without any tenant header and confirm both are refused. Repeat with a made-up X-Scope-OrgID value to confirm Loki does not treat an arbitrary tenant as valid access. Done means unauthenticated and header-only requests fail in a recorded test run, because Loki has no built-in login and will accept whatever tenant header it receives once auth is off.

  3. Place the authenticating proxy in front of Loki

    Put the chosen proxy, such as nginx, HAProxy, OAuth2 Proxy or Pomerium, between clients and Loki so that Loki is reachable only through the proxy. Configure the identity provider with the proxy's callback URL and a group claim that carries the team memberships used in the mapping table. Confirm that Loki's listener is not reachable directly from user networks or from Grafana's network segment. Done means a browser session through the proxy completes sign-in, the proxy shows the expected groups, and a direct request to Loki's port from a user network fails.

  4. Set the tenant header from verified identity

    Configure the proxy to derive X-Scope-OrgID from the group claim that it has verified, using the mapping table as the lookup. The proxy must also strip any X-Scope-OrgID value supplied by the client before adding its own, so a caller cannot choose a tenant. Where a user belongs to more than one group, decide in writing whether the proxy rejects the request or applies a defined rule. Done means a logged-in user in one group receives only that tenant's streams, and a request that carries a forged X-Scope-OrgID header for another tenant is rejected or overwritten, with the proxy log showing which value was applied.

  5. Connect Grafana SSO and the Loki data source

    Configure Grafana to sign users in through the same identity provider, and point the Loki data source at the proxy's address, not at Loki directly. Check the data source settings for any static tenant header, since a value stored there would override per-user identity. Confirm that Grafana forwards the user's session or token through the proxy in the way the chosen proxy expects. Done means a user who signs into Grafana runs an Explore query that returns only their tenant's streams, and a second user in a different group sees a different result for the same query.

  6. Separate write paths for log shippers

    Give each log shipper its own identity or credential and its own write route through the proxy, rather than letting shippers reuse a human user's session. Each shipper should send only to the tenant it belongs to, and the proxy should enforce that mapping the same way it does for reads. Confirm which shipper component will hold the credential and how it is stored and rotated, and record the answer. Done means a shipper pushes a test line that appears in its own tenant and is refused when it attempts to write with another tenant's header.

  7. Record the evidence and retest after changes

    Save the results of each check in one place: the mapping table, the refusal tests, the forged-header test, the Grafana cross-user test and the shipper write test. Repeat the full set after every proxy, identity provider, Loki or Grafana change, and after group membership changes that affect the mapping. Confirm with the owner of audit logging that proxy and Loki access logs capture the identity and tenant for each request. Done means a dated test record exists, the owner has reviewed it, and any failed check has a fix and a rerun attached.

How users and teams map to tenants with X-Scope-OrgID

Loki does not decide who a user is or which tenant they may read. It only sees the X-Scope-OrgID header on each request and trusts whatever value it finds. That makes the mapping logic live entirely in the authenticating proxy or in the gateway in front of Loki, and that component must derive the tenant ID from the verified identity, never from anything the client sends. In practice, the identity provider groups a user belongs to are translated into a fixed table of allowed tenant IDs, and the proxy sets the header only to a value from that table. Decide this table with the people who own each log source before any dashboards are built, and keep it in version control so every change to a group-to-tenant rule is reviewed like any other access change.

Users who belong to several teams need an explicit rule. The simplest pattern gives each team its own tenant and lets a user query several tenants by sending separate requests, with the proxy checking each requested tenant against the user's group memberships. Grafana can be configured with one data source per tenant so that a dashboard chooses the tenant, but the proxy must still enforce the check, because a user can edit a data source or call the API directly. Confirm how your Grafana version and proxy handle multiple header values or cross-tenant queries before relying on them, and test the case where a user is removed from a group while a session is still active.

A shared tenant for platform, audit or security logs is convenient, and it is also the easiest place for access to become too broad. Anyone who can reach that tenant can read every stream in it, so a group rule that grants a broad team access to the shared tenant exposes logs that were never meant for them. Keep sensitive sources in separate tenants where possible, and treat any group that maps to a shared tenant as a privileged grant with its own review. The tenant is an isolation boundary only if every path to Loki sets and checks the header: the proxy, any service that writes to Loki, any internal ruler or query endpoint, and any direct port that bypasses the proxy. Test each path with a token from a user outside the allowed group and confirm the request is refused.

Grafana SSO for people who query logs

This option uses one identity provider for both Grafana logins and the proxy in front of Loki. Grafana authenticates people through OAuth or OIDC, and maps their group membership to Grafana roles. Grafana then sends queries to a datasource URL that points at the authenticating reverse proxy, not directly at Loki. The proxy checks the session, decides which tenants the user may read, and sets the X-Scope-OrgID header before forwarding the request. Loki itself trusts that header only because the proxy is the sole path to it.

  • Grafana login: controls who reaches the Grafana UI, which dashboards and Explore views they see, and their Grafana role.
  • Proxy authorization: controls which tenants a session can query, enforced on every request regardless of what the Grafana client sends.
  • Header injection: the proxy must overwrite any X-Scope-OrgID supplied by the client, so users cannot choose another tenant.
  • Network path: Loki's port should accept traffic only from the proxy, otherwise the header can be forged.
  • Group mapping: keep the mapping from identity provider groups to tenants in version-controlled configuration that the security team can review.

Confirm the Grafana SSO configuration keys against the Grafana documentation for your version rather than copying them from this page. Test that a user without tenant rights gets a denial from the proxy, not just a missing dashboard.

What drives SSO effort on a Loki deployment

This table lists the factors that change how much work an SSO and identity integration for Loki takes, what raises effort for each, and how to keep it down. Read it before scoping, because most of the effort comes from decisions about identities, tenants and proxies rather than from Loki itself.

DriverWhy it raises effortHow to keep it down
Identity providers and groups to mapEach provider adds claim formats, group names and login flows to test, and every group must map to a tenant or roleAgree the group-to-tenant mapping on paper before build and cap the number of identity sources in scope
Number of tenants and team exceptionsEach tenant needs its own access rule, and one-off exceptions create paths that are hard to review laterDefine a standard tenant model and limit exceptions to a short, written list with an owner
Grafana and Loki on separate domainsCross-domain cookies, redirects and token forwarding add configuration and testing across both hostnamesPlace Grafana and the authenticating proxy under one domain where your network policy allows it
Existing proxy or ingress standardsA new proxy product with its own auth model duplicates work already done for other internal toolsReuse the proxy and ingress pattern your platform team already runs and operates
Session and token lifetime policyShort sessions, refresh behavior and revocation rules must be set and tested for both browser and API accessGet the lifetime policy from security before build and apply one value across services
Write paths and machine clientsLog shippers, CI jobs and agents send with their own credentials, and each needs a separate identity path that does not rely on interactive loginInventory every writer and reader first, then give machine clients scoped service identities
Audit requirements for access logsAssessors often expect records of who queried which tenant and when, which needs logging at the proxy and Grafana layersConfirm the required fields and retention for access records before choosing the proxy and log sinks

Access control risks when the proxy is the only gate

Loki has no authentication layer of its own, so every control on who can read which tenant depends on the proxy and the network around it. The cards below cover the places where that arrangement usually breaks: headers, bypass paths, shared credentials, sessions, claims and transport.

Client-supplied tenant headers

Loki picks the tenant from the X-Scope-OrgID header on every request. If the proxy forwards whatever header the client sends, a user authenticated for one team can ask for another team's tenant. The proxy should strip any incoming X-Scope-OrgID and set it only from the identity it has verified. To test, log in as a user limited to one tenant, send a request with a different tenant value, and confirm Loki returns no data from that tenant.

Loki multi-tenancy docs

Direct access to Loki's port

A proxy only protects Loki if nothing else can reach Loki's listening port. Services, jump hosts or pods on the same network may call Loki directly and send any tenant header they like. Confirm that Loki's HTTP port is bound to a private interface or restricted by network policy so that only the proxy and Grafana can connect. To test, connect to the Loki port from a host that is not the proxy and confirm the connection is refused or blocked.

Loki authentication docs

Shared shipper credentials

Log shippers often push to Loki through the same proxy route with a shared token or a single service account. If that credential leaks, an attacker can write false logs into any tenant it covers and may be able to read them if the token also grants query rights. Give each shipper its own credential scoped to write to one tenant, and record which credential wrote which logs. To test, revoke one shipper credential and confirm the others keep working.

Proxy session and cookie settings

The proxy's session lifetime, cookie flags and logout behavior decide how long a stolen session stays useful. Check that session cookies are marked secure and http-only, that they expire within a window your security team sets, and that logout invalidates the server-side session rather than only clearing the browser cookie. To test, log out in one browser, replay the old cookie in another client, and confirm the request is rejected.

Over-broad group claims

Mapping an identity provider group to a tenant is a policy decision, and a broad group such as all staff can quietly become all-tenant read access. Map each group to the smallest set of tenants its members need, and review the mapping whenever teams change. Test by signing in as a member of each mapped group and confirming that only the expected tenants are visible in Grafana and through direct queries.

TLS between proxy, Grafana and Loki

Tenant headers and session data pass between the proxy, Grafana and Loki, so a plaintext hop lets anyone on that path read or change them. Encrypt each hop and verify certificates on the internal connections, not only at the public edge. Confirm the setting in each component's configuration and test by inspecting the connection with a TLS client to confirm the expected certificate is presented and plaintext is refused.

How to test that tenant isolation and login failures fail safely

Test the boundary before you trust it. The first check is that every request without a valid session is refused by the authenticating proxy, including requests sent straight to the Loki push and query endpoints. Because Loki has no built-in authentication layer and its documentation requires an authenticating reverse proxy in front of it, the test must show that the proxy is the only path in. Run it from outside the proxy network and confirm that Loki itself does not answer. Then test tenant isolation with a user in team A who sends a forged X-Scope-OrgID header naming team B's tenant. The proxy should overwrite or strip any client-supplied value and set the header from the verified identity, so the forged query should return nothing from team B or be refused outright. Repeat the same check for Grafana: a query from a team A dashboard should return only the tenant the proxy set, and you should confirm that Grafana's data source configuration does not let users choose another tenant.

Test the lifecycle, not just the login. Remove a user from the identity provider group that maps to team A, then confirm that access ends once the existing session expires, and that a new login attempt is refused. Record the session lifetime you configured, because that value is the real upper bound on how long a removed person keeps access. Also test how the system behaves when things break. If the identity provider is unreachable, the proxy should deny access rather than fall back to an anonymous or default tenant. Malformed tokens, expired tokens and users with no group membership should all be refused, and each refusal should appear in the proxy's log with the time, the requested path and the identity if one was established. Confirm that those logs reach the place your security team reviews them, since a failure that is denied but never recorded cannot be investigated.

Treat these tests as a regression suite, not a one-time sign-off. Rerun them after every upgrade to the proxy, Grafana or Loki, because a changed header handling rule, a new default in Grafana's data source settings or a Loki configuration change can reopen a path that was closed. Keep the results with the configuration version they tested. Ask your implementation partner or internal team to confirm the exact header behavior of the proxy version you deploy, and check the current Loki authentication documentation against your deployment before writing the test cases, since the recommended proxy configuration may change between releases.

Questions buyers ask about Loki SSO and identity integration

How much effort and cost does Loki SSO integration add to a logging stack?

The integration adds a one-time build cost and a smaller recurring cost, and the size of both depends on how many identity sources, groups and tenants are involved. The one-time work covers choosing and configuring the authenticating reverse proxy, connecting it to your identity provider, mapping groups to tenants, setting the X-Scope-OrgID header for each tenant, and wiring Grafana to the same login. The recurring work covers group membership changes, certificate and proxy patching, and reviewing access when teams change. Cost rises with the number of tenants, the number of identity providers and the amount of custom proxy rules. Quotes should itemize the proxy design, the identity provider configuration, the testing with test accounts, and the handover documentation, so you can compare a partner quote with your internal estimate line by line.

How long does Loki SSO and identity integration take to deliver?

The timeline is set mainly by how quickly your identity team can provide access and decisions, not by Loki itself. The main variables are the number of tenants you need, whether your identity provider already issues the group claims you want to map, how many change approvals your environment requires, and how many environments (test, staging, production) must be built. Work usually moves in this order: agree the tenant model, configure the proxy in a test environment, connect the identity provider, verify group-to-tenant mapping with test accounts, then promote to production. Ask any partner for a written schedule that lists which steps depend on your team, because delays most often come from waiting for identity provider changes and approvals rather than from configuration work.

Can our internal team set up Loki SSO without a partner?

Yes, a capable internal team can do this, provided it has the right skills and time. The work needs three skill sets: identity provider administration (OIDC or SAML application setup, group claims, and conditional access), reverse proxy configuration (nginx, HAProxy, OAuth2 Proxy or Pomerium, with TLS and header handling), and Loki tenant design (auth_enabled, how X-Scope-OrgID is set per request, and how tenants map to retention and access rules). Most gaps appear in the proxy, where a misconfigured header can let a user reach another tenant's logs. Check whether your team has done this before, whether it can test cross-tenant access deliberately, and whether it has someone who will maintain the setup after handover. A partner can fill any of these gaps and can supply a test plan your team can rerun.

What do we need to provide before Loki SSO work can start?

Before work starts, you need to provide four inputs. First, administrator access to the identity provider, or a named administrator who can make changes during the build. Second, a group inventory that lists the groups or roles that should see logs, who owns each one, and which ones overlap. Third, a tenant decision: whether tenants follow teams, environments, business units or data classification, and which of them may read each other's logs. Fourth, test accounts for each role, including at least one account that should be denied access to a given tenant. Your team should also confirm where the proxy will run, what DNS names and TLS certificates it will use, and who approves production changes. Missing inputs are the most common cause of delay, so settle them before the schedule is fixed.

Is Grafana SSO alone enough to isolate log tenants in Loki?

No. Grafana SSO controls who can sign in to Grafana and which Grafana features they can use, but it does not stop a request that reaches Loki directly from choosing any tenant. Loki has no built-in authentication layer, and its documentation says you must place an authenticating reverse proxy in front of it. Tenant isolation therefore depends on that proxy: it must authenticate every request, decide which tenants the user may access, and set or overwrite the X-Scope-OrgID header so that clients cannot choose a tenant themselves. Grafana SSO should be configured as well, so people sign in once, but it is the proxy and the network path to Loki that enforce isolation. Test this with a user who is denied a tenant and try direct requests to the Loki endpoints, not only queries through Grafana.

Do we need Grafana Enterprise Logs for label-based access control?

Not for tenant-level separation, but you may need Grafana Enterprise Logs (GEL) if you need finer control within a tenant. According to Grafana's enterprise logs documentation, GEL adds token authorization, label-based access control and cross-tenant queries on top of Loki. In open-source Loki, the practical boundary is the tenant, which the authenticating proxy enforces. If your requirement is that one team sees only certain streams inside a shared tenant, you need to decide whether to split those streams into separate tenants, enforce filtering at the proxy, or license GEL. Each option has trade-offs in cost, operating complexity and licensing terms. Confirm the requirement with your compliance and security owners first, and check the current GEL terms with Grafana Labs before you decide.

What to monitor, document and review after SSO goes live

Once the authenticating proxy and Grafana SSO are live, the team keeps a short, recurring set of checks running. Log every login decision at the proxy and at the identity provider, both failed and successful, and ship those logs to a store that the security team can query separately from Loki itself. Failed logins show misconfigured group claims or brute-force attempts, and successful logins tell you which accounts reached which tenants. Also keep an audit trail for every change to the group-to-tenant mapping in the proxy rules or the identity provider, and require a named approver before a mapping change reaches production. Mapping changes are the most common way tenant isolation quietly weakens, so treat them like firewall rule changes.

Run a periodic access review of tenant membership. Ask each tenant owner to confirm which people and service accounts should still read their logs, and remove anyone who has changed teams or left. Track certificate expiry for the proxy and the identity provider connection, and rotate the OIDC client secret, cookie signing keys and any service tokens on a fixed schedule with a tested rollback. Confirm the exact rotation mechanics with your proxy and identity provider documentation, since they differ by product.

Document auth_enabled, the tenant header rules and the proxy route configuration in one place, next to the proxy policy files. An on-call engineer who sees a denied query should be able to trace it: which identity the proxy saw, which group claim mapped to which X-Scope-OrgID value, and whether Loki was running with multi-tenancy on. Re-run the isolation tests after every Loki, Grafana or proxy upgrade, because a new release can change how headers are forwarded or how Grafana data source settings behave. Keep the test results with the change record. For patching, retention and sensitive log handling beyond access control, see the wider stack operations and the Loki security hardening guidance.

How DeployOpen scopes, builds and hands over Loki identity integration

DeployOpen plans and builds the authentication layer in front of Loki and the Grafana sign-in for people who query logs, inside your own infrastructure. We agree the scope in writing first, then test, document and hand over the setup so your security and platform teams can review it.

How we scope

  • Inventory which teams query logs, which tenants they need and which identity provider issues their accounts.
  • Agree in writing which endpoints the authenticating reverse proxy will cover, including push and query paths.
  • Record the team-to-tenant mapping rules, the Grafana SSO settings and the admin roles that stay outside SSO.

How we build

  • Configure the reverse proxy so every request is authenticated before it reaches Loki, with X-Scope-OrgID set from verified identity.
  • Set up Grafana SSO against your identity provider and map groups to data sources and tenant-scoped views.
  • Test unauthenticated access, header spoofing, cross-tenant reads and expired sessions before anything goes live.

How we hand over

  • Deliver configuration files, mapping tables and a runbook covering adding a team, a tenant or a new identity source.
  • Document the verification steps your team can repeat after upgrades or identity provider changes.
  • Walk through the evidence of access controls so your compliance and security reviewers can check it against their own requirements.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, scoped separately from the build.
  • Retesting after Loki version upgrades or proxy changes can be included in the written scope if you need it.
  • Confirm with your identity provider and Grafana documentation which SSO features your edition and version support before the build starts.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.