# pcf-express-sso

> Express JS/TS middleware for Pivotal Cloud Foundry Single Sign On

Latest version **0.1.7** (published 2019-02-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install pcf-express-sso
pnpm add pcf-express-sso
yarn add pcf-express-sso
bun add pcf-express-sso
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.7 |
| Published | 2019-02-13 |
| First published | 2018-08-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 95.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | haplesshero13 |
| Maintainers | haplesshero13, ochong, stevensouto |
| Keywords | Pivotal Cloud Foundry, PCF, Single Sign-On, SSO, Oauth, Oauth2, Authentication, Express, Middleware, Cloud Foundry |

## Links

- npm: https://www.npmjs.com/package/pcf-express-sso
- Repository: https://github.com/haplesshero13/pcf-express-sso
- Homepage: https://github.com/haplesshero13/pcf-express-sso#readme
- Issues: https://github.com/haplesshero13/pcf-express-sso/issues
- npm.io page: https://npm.io/package/pcf-express-sso

## Dependencies (2)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.2.0
- [simple-oauth2](https://npm.io/package/simple-oauth2.md) ^2.2.1

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@oxyhq/services](https://npm.io/package/@oxyhq/services.md) — 2.3K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads

## Recent versions

- 0.1.7 (latest) — 2019-02-13
- 0.1.6 — 2019-02-12
- 0.1.5 — 2019-02-08
- 0.1.4 — 2019-02-07
- 0.1.3 — 2018-08-14
- 0.1.2 — 2018-08-14
- 0.1.1 — 2018-08-14
- 0.1.0 — 2018-08-14

## README

# pcf-express-sso

A fork and straight port to TypeScript of [pcf-sso-express-middleware](https://github.com/vanceric/pcf-sso-express-middleware#readme).

The purpose of this module is to wrap the process of interfacing with the Single
Sign-On service provided for Pivotal Cloud Foundry into a middleware for express.

For more information on PCF SSO visit:
[PCF Single Sign-On Overview](http://docs.pivotal.io/p-identity/1-5/index.html)

## Basic Usage Example:

Install with NPM or Yarn: `yarn add pcf-express-sso`. If you are using TypeScript you will also need to add `@types/express` and `@types/simple-oauth2`.

```typescript
import * as express from "express"
import * as session from "express-session"
import SSOClient from "pcf-express-sso"

const PORT = process.env.PORT || 8080
const AUTH_CONDITION = process.env.ENABLE_AUTH || false
const app = express()

app.use(
  session({
    name: "server-session",
    resave: true,
    saveUninitialized: true,
    secret: "genericSecret",
  }),
)

const ENABLE_AUTH = app.get("env") === "production"
const auth = new SSOClient(app)
auth.initialize(ENABLE_AUTH)

app.use(/\/(?!callback).*/, (req, res, next) => {
  auth.middleware(req, res, next)
})

app.get("/*", (req, res) => {
  res.send("Hello World!")
})

app.listen(PORT, () => {
  console.log(`Express server started on port ${PORT}`)
})
```

Notes:

1. Use an external store once in production, like Redis.
2. Use a secret provided via environment variables once in production

## Testing:

Run `yarn test`.

### TODO:

Backfill tests for SSOClient#initialize, etc.

## Module Dependencies:

* [Node Fetch](https://github.com/bitinn/node-fetch)
* [Simple Oauth2](https://github.com/lelylan/simple-oauth2)

## Prerequisites:

* [Express JS Application](https://github.com/expressjs/express)
* [Express Session Implemented](https://github.com/expressjs/session)
* [Pivotal Cloud Foundry Platform for Deployment](https://pivotal.io/platform)

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