# @natlibfi/passport-keycloak

> Passport strategy for Keycloak JWT

Latest version **3.0.14** (published 2026-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @natlibfi/passport-keycloak
pnpm add @natlibfi/passport-keycloak
yarn add @natlibfi/passport-keycloak
bun add @natlibfi/passport-keycloak
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 3.0.14 |
| Published | 2026-09-18 |
| First published | 2023-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 4 |
| Unpacked size | 203.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | The National Library of Finland |
| Maintainers | drone-melinda, natlibfi-jonollil |

## Links

- npm: https://www.npmjs.com/package/@natlibfi/passport-keycloak
- Repository: https://github.com/NatLibFi/passport-keycloak-js
- Homepage: https://www.npmjs.com/package/@natlibfi/passport-keycloak
- Issues: https://github.com/natlibfi/passport-keycloak-js/issues
- npm.io page: https://npm.io/package/@natlibfi/passport-keycloak

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ^4.4.3
- [http-status](https://npm.io/package/http-status.md) ^2.1.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^9.0.2
- [passport-strategy](https://npm.io/package/passport-strategy.md) ^1.0.0

## Recent versions

- 3.0.14 (latest) — 2026-09-18
- 3.0.10-alpha.4 (next) — 2026-05-12
- 3.0.13 — 2026-08-19
- 3.0.12 — 2026-08-19
- 3.0.11 — 2026-06-30
- 3.0.10 — 2026-05-12
- 3.0.10-alpha.3 — 2026-05-12
- 3.0.10-alpha.1 — 2026-05-12
- 3.0.9-alpha.1 — 2026-05-12
- 3.0.9 — 2026-05-12
- 3.0.8 — 2026-05-11
- 3.0.8-alpha.1 — 2026-05-11
- 3.0.6 — 2026-04-01
- 3.0.5 — 2026-03-09
- 3.0.4 — 2025-12-12
- … 52 more at https://npm.io/package/@natlibfi/passport-keycloak/versions

## README

# Passport strategy for Keycloak JWT

Passport strategy for Keycloak JWT. This module has the following features:
- Written in modern day Javascript/ECMAscript
- Supports HTTP Bearer authentication using Keycloak JWT as bearer tokens
- Verifies token locally (i.e. does not use network calls to introspect endpoint, public keys are fetched from jwks endpoint and cached after first use)

## Strategies
This module provides the following Passport strategies.

### Bearer
HTTP Bearer authentication works by using the token generated after signing in to Keycloak for gaining access to the defined resources.

Does **not** allow configuration for ignoring token expiration.

### Usage

#### ES modules
```javascript
import {KeycloakStrategy} from '@natlibfi/passport-keycloak'
```

### Configuration
Configuration of the strategy needs to be passed to the class constructor as object.

- **algorithms (required):** Algorithm for decoding jwt
- **audience (required):** Audience of jwt
- **issuer (required):** Issuer of jwt
- **jwksUrl (required):** JWKS url to fetch public keys from


## License and copyright

Copyright (c) 2023-2024 **University Of Helsinki (The National Library Of Finland)**

This project's source code is licensed under the terms of **MIT license**

---
_Source: https://npm.io/package/@natlibfi/passport-keycloak · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
