Skip to content

A Deno package to orchestrate OpenID authentication flow with Steam.

License

Notifications You must be signed in to change notification settings

brycedorn/deno-steam-openid

Repository files navigation

deno-steam-openid

deno_steam_openid module version .github/workflows/deno.yml

A Deno package to orchestrate OpenID authentication flow with Steam.

Borrows from node-openid and node-steam-openid with modifications to support the Deno runtime. Note: not all OpenID functionality is supported; only authentication logic required to support flow with Steam.

Usage

OpenID flow confirmed to work with these frameworks:

import { SteamAuth } from 'https://deno.land/x/deno_steam_openid/mod.ts';

// Initialize
const steam = new SteamAuth({
  realm: Deno.env.get('DOMAIN'),
  returnUrl: `${Deno.env.get('DOMAIN')}/auth`,
  apiKey: Deno.env.get('API_KEY'),
});

// Redirect to Steam
const handler = async () {
  const redirectUrl = await steam.getRedirectUrl();
}

// Handle redirect from Steam
const otherHandler = async (request) {
  const user = await steam.authenticate(request);
}

Example

There's a simple Oak example in the example directory that demonstrates the flow. This assumes you have the latest version of Deno installed.

  1. Get a Steam API key
  2. Run cp .env.example .env
  3. Replace xxxxx in new .env file with your API key
  4. Run deno task example
  5. Open localhost:8000 and log in to Steam to be redirected to a page with your user information

Test

deno task test

Format

deno task fmt