# ajency-keycloak-node

> A small node library that supports authentication for Keycloak which can be used with higher abstraction level frameworks like express

Latest version **1.3.8** (published 2018-05-31) · ISC license · 0 weekly downloads

## Install

```sh
npm install ajency-keycloak-node
pnpm add ajency-keycloak-node
yarn add ajency-keycloak-node
bun add ajency-keycloak-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.8 |
| Published | 2018-05-31 |
| First published | 2018-04-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ~6.5.0 |
| Dependencies | 3 |
| Unpacked size | 65.6 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Author | Cyrus Furtado |
| Maintainers | cyrus2021 |

## Links

- npm: https://www.npmjs.com/package/ajency-keycloak-node
- npm.io page: https://npm.io/package/ajency-keycloak-node

## Dependencies (3)

- [q](https://npm.io/package/q.md) ^1.5.1
- [request](https://npm.io/package/request.md) ^2.85.0
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.2.0

## Recent versions

- 1.3.8 (latest) — 2018-05-31
- 1.3.7 — 2018-05-29
- 1.3.6 — 2018-05-29
- 1.3.5 — 2018-05-29
- 1.3.4 — 2018-05-29
- 1.3.3 — 2018-05-29
- 1.2.2 — 2018-05-18
- 1.2.1 — 2018-04-23
- 1.2.0 — 2018-04-12
- 1.1.0 — 2018-04-12
- 1.0.5 — 2018-04-06
- 1.0.4 — 2018-04-06
- 1.0.3 — 2018-04-06
- 1.0.2 — 2018-04-06
- 1.0.1 — 2018-04-06

## README

Ajency keycloak auth utility
=========

A small node library that supports authentication for Keycloak which can be used with higher abstraction level frameworks like express.

## Installation

  `npm install --save ajency-keycloak-node`

## Basic Usage

```

  const ajauth = require('@ajency-keycloak/node')('keycloak.json'); // pass in your keycloak configuration file path (only paths relative to project root are valid)

  var permissions = [ // your resource and scope premissions
          {
              "resource_set_name" : "res:lead",
              "scopes":["scopes:view"]
          }
      ];

var authMiddleware = function(){
  return function(request, response, next){
        ajauth.isUserAuthorised(request.keycloak_access_token, permissions, 'post') // your keycloak access token & resource permissions
                    .then(function(result){
                        console.log("user authorized");
                        next();
                    })
                    .catch(function(err){
                      console.warn("user not authorized");
                      response.redirect("/not-authorized");
                    })
  }    
}

app.get("/user-data", authMiddleware(), function(request, response){
  response.render("user-data");
});

```

## Tests

  `npm run test`

## Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

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