Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/@changesets/config@3.0.4/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": "./commit.cjs",
"fixed": [["@openauthjs/openauth"]],
"fixed": [["@kagii/openauth"]],
"linked": [],
"access": "public",
"baseBranch": "master",
Expand Down
2 changes: 1 addition & 1 deletion .changeset/popular-geese-reply.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@openauthjs/openauth": patch
"@kagii/openauth": patch
---

update google icon to comply with branding guidelines
2 changes: 1 addition & 1 deletion .changeset/stupid-boats-play.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@openauthjs/openauth": patch
"@kagii/openauth": patch
---

allow auth style autodetection
2 changes: 1 addition & 1 deletion .changeset/ten-pans-invent.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@openauthjs/openauth": patch
"@kagii/openauth": patch
---

add linkedin adapter
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
</p>
<p align="center">
<a href="https://sst.dev/discord"><img alt="Discord" src="https://img.shields.io/discord/983865673656705025?style=flat-square&label=Discord" /></a>
<a href="https://www.npmjs.com/package/@openauthjs/openauth"><img alt="npm" src="https://img.shields.io/npm/v/%40openauthjs%2Fcore?style=flat-square" /></a>
<a href="https://github.com/toolbeam/openauth/actions/workflows/release.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/toolbeam/openauth/release.yml?style=flat-square&branch=master" /></a>
<a href="https://www.npmjs.com/package/@kagii/openauth"><img alt="npm" src="https://img.shields.io/npm/v/%40kagii%2Fopenauth?style=flat-square" /></a>
<a href="https://github.com/kagii-dev/openauth/actions/workflows/release.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/kagii-dev/openauth/release.yml?style=flat-square&branch=master" /></a>
</p>

---

> Community-maintained fork of OpenAuth, published as `@kagii/openauth`.
> This fork keeps the upstream MIT license, carries forward unmerged fixes like the eventual-consistency key generation fix from `#323`, and is not an official SST/anomalyco release.
> Upstream source remains `sst/openauth` and `anomalyco/openauth`; this package exists so the project can keep shipping fixes in the open.

[OpenAuth](https://openauth.js.org) is a standards-based auth provider for web apps, mobile apps, single pages apps, APIs, or 3rd party clients. It is currently in beta.

- **Universal**: You can deploy it as a standalone service or embed it into an existing application. It works with any framework or platform.
Expand All @@ -30,7 +34,13 @@

## Quick Start

If you just want to get started as fast as possible you can jump straight into the [code examples](https://github.com/toolbeam/openauth/tree/master/examples) folder and copy paste away. There are also [SST components](https://sst.dev/docs/component/aws/auth) for deploying everything OpenAuth needs.
If you just want to get started as fast as possible you can jump straight into the [code examples](https://github.com/kagii-dev/openauth/tree/master/examples) folder and copy paste away. There are also [SST components](https://sst.dev/docs/component/aws/auth) for deploying everything OpenAuth needs.

Install this fork with:

```bash
npm install @kagii/openauth
```

## Approach

Expand All @@ -56,10 +66,10 @@ We'll show how to deploy the auth server and then a sample app that uses it.

### Auth server

Start by importing the `issuer` function from the `@openauthjs/openauth` package.
Start by importing the `issuer` function from the `@kagii/openauth` package.

```ts
import { issuer } from "@openauthjs/openauth"
import { issuer } from "@kagii/openauth"
```

OpenAuth is built on top of [Hono](https://github.com/honojs/hono) which is a minimal web framework that can run anywhere. The `issuer` function creates a Hono app with all of the auth server implemented that you can then deploy to AWS Lambda, Cloudflare Workers, or in a container running under Node.js or Bun.
Expand All @@ -78,7 +88,7 @@ const app = issuer({
First we need to define some providers that are enabled - these are either third party identity providers like Google, GitHub, etc or built in flows like email/password or pin code. You can also implement your own. Let's try the GitHub provider.

```ts
import { GithubProvider } from "@openauthjs/openauth/provider/github"
import { GithubProvider } from "@kagii/openauth/provider/github"

const app = issuer({
providers: {
Expand All @@ -95,7 +105,7 @@ const app = issuer({
Providers take some configuration - since this is a third party identity provider there is no UI to worry about and all it needs is a client ID, secret and some scopes. Let's add the password provider which is a bit more complicated.

```ts
import { PasswordProvider } from "@openauthjs/openauth/provider/password"
import { PasswordProvider } from "@kagii/openauth/provider/password"

const app = issuer({
providers: {
Expand All @@ -109,8 +119,8 @@ const app = issuer({
The password provider is quite complicated as username/password involve a lot of flows so there are a lot of callbacks to implement. However you can opt into the default UI which has all of this already implemented for you. The only thing you have to specify is how to send a code for forgot password/email verification. In this case we'll log the code but you would send this over email.

```ts
import { PasswordProvider } from "@openauthjs/openauth/provider/password"
import { PasswordUI } from "@openauthjs/openauth/ui/password"
import { PasswordProvider } from "@kagii/openauth/provider/password"
import { PasswordUI } from "@kagii/openauth/ui/password"

const app = issuer({
providers: {
Expand Down Expand Up @@ -184,7 +194,7 @@ Note all of this is typesafe - based on the configured providers you will receiv
Next we have the `storage` field which defines where things like refresh tokens and password hashes are stored. If on AWS we recommend DynamoDB, if on Cloudflare we recommend Cloudflare KV. We also have a MemoryStore used for testing.

```ts
import { MemoryStorage } from "@openauthjs/openauth/storage/memory"
import { MemoryStorage } from "@kagii/openauth/storage/memory"

const app = issuer({
providers: { ... },
Expand Down Expand Up @@ -219,7 +229,7 @@ You now have a centralized auth server. Test it out by visiting `/.well-known/oa
Since this is a standard OAuth server you can use any libraries for OAuth and it will work. OpenAuth does provide some light tooling for this although even a manual flow is pretty simple. You can create a client like this:

```ts
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"

const client = createClient({
clientID: "my-client",
Expand Down
2 changes: 1 addition & 1 deletion examples/client/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"astro": "astro"
},
"dependencies": {
"@openauthjs/openauth": "workspace:*",
"@kagii/openauth": "workspace:*",
"astro": "5.0.2"
}
}
2 changes: 1 addition & 1 deletion examples/client/astro/src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import type { APIContext } from "astro"
export { subjects } from "../../../subjects"

Expand Down
2 changes: 1 addition & 1 deletion examples/client/astro/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SubjectPayload } from "@openauthjs/openauth/subject"
import type { SubjectPayload } from "@kagii/openauth/subject"
import { subjects } from "./auth"

declare global {
Expand Down
2 changes: 1 addition & 1 deletion examples/client/cloudflare-api/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Service } from "@cloudflare/workers-types"
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import { subjects } from "../../subjects"

interface Env {
Expand Down
2 changes: 1 addition & 1 deletion examples/client/jwt-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
### Patch Changes

- Updated dependencies [8b5f490]
- @openauthjs/openauth@0.2.4
- @kagii/openauth@0.2.4
2 changes: 1 addition & 1 deletion examples/client/jwt-api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import { subjects } from "../../subjects"

const headers = {
Expand Down
2 changes: 1 addition & 1 deletion examples/client/jwt-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"@openauthjs/openauth": "workspace:*"
"@kagii/openauth": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion examples/client/lambda-api/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Context, Hono } from "hono"
import { getCookie, setCookie } from "hono/cookie"
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import { handle } from "hono/aws-lambda"
import { subjects } from "../../subjects"

Expand Down
12 changes: 6 additions & 6 deletions examples/client/nextjs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
### Patch Changes

- Updated dependencies [8b5f490]
- @openauthjs/openauth@0.2.4
- @kagii/openauth@0.2.4

## 0.1.5

### Patch Changes

- Updated dependencies [80238de]
- @openauthjs/openauth@0.2.3
- @kagii/openauth@0.2.3

## 0.1.4

### Patch Changes

- Updated dependencies [6da8647]
- @openauthjs/openauth@0.2.2
- @kagii/openauth@0.2.2

## 0.1.3

### Patch Changes

- Updated dependencies [83125f1]
- @openauthjs/openauth@0.2.1
- @kagii/openauth@0.2.1

## 0.1.2

### Patch Changes

- Updated dependencies [8c3f050]
- Updated dependencies [0f93def]
- @openauthjs/openauth@0.2.0
- @kagii/openauth@0.2.0

## 0.1.1

Expand All @@ -43,4 +43,4 @@
- Updated dependencies [584728f]
- Updated dependencies [41acdc2]
- Updated dependencies [2aa531b]
- @openauthjs/openauth@0.1.2
- @kagii/openauth@0.1.2
2 changes: 1 addition & 1 deletion examples/client/nextjs/app/auth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import { cookies as getCookies } from "next/headers"
export { subjects } from "../../../subjects"

Expand Down
2 changes: 1 addition & 1 deletion examples/client/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"lint": "next lint"
},
"dependencies": {
"@openauthjs/openauth": "workspace:*",
"@kagii/openauth": "workspace:*",
"next": "15.1.0",
"react": "19.0.0",
"react-dom": "19.0.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/client/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"@openauthjs/openauth": "workspace:*",
"@kagii/openauth": "workspace:*",
"react": "19.0.0",
"react-dom": "19.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/client/react/src/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
useContext,
createContext,
} from "react"
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"

const client = createClient({
clientID: "react",
Expand Down
2 changes: 1 addition & 1 deletion examples/client/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@openauthjs/openauth": "^0.4.3",
"@kagii/openauth": "^0.4.4",
"@sveltejs/adapter-auto": "^4.0.0",
"@sveltejs/kit": "^2.16.0",
"@sveltejs/vite-plugin-svelte": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/client/sveltekit/src/lib/auth.server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import type { RequestEvent } from "@sveltejs/kit"

export function createAuthClient(event: RequestEvent) {
Expand Down
8 changes: 4 additions & 4 deletions examples/issuer/bun/issuer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { issuer } from "@openauthjs/openauth"
import { MemoryStorage } from "@openauthjs/openauth/storage/memory"
import { PasswordProvider } from "@openauthjs/openauth/provider/password"
import { PasswordUI } from "@openauthjs/openauth/ui/password"
import { issuer } from "@kagii/openauth"
import { MemoryStorage } from "@kagii/openauth/storage/memory"
import { PasswordProvider } from "@kagii/openauth/provider/password"
import { PasswordUI } from "@kagii/openauth/ui/password"
import { subjects } from "../../subjects.js"

async function getUser(email: string) {
Expand Down
2 changes: 1 addition & 1 deletion examples/issuer/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "@openauthjs/example-issuer-bun",
"version": "0.0.0",
"dependencies": {
"@openauthjs/openauth": "workspace:*"
"@kagii/openauth": "workspace:*"
}
}
8 changes: 4 additions & 4 deletions examples/issuer/cloudflare/issuer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { issuer } from "@openauthjs/openauth"
import { CloudflareStorage } from "@openauthjs/openauth/storage/cloudflare"
import { issuer } from "@kagii/openauth"
import { CloudflareStorage } from "@kagii/openauth/storage/cloudflare"
import {
type ExecutionContext,
type KVNamespace,
} from "@cloudflare/workers-types"
import { subjects } from "../../subjects.js"
import { PasswordProvider } from "@openauthjs/openauth/provider/password"
import { PasswordUI } from "@openauthjs/openauth/ui/password"
import { PasswordProvider } from "@kagii/openauth/provider/password"
import { PasswordUI } from "@kagii/openauth/ui/password"

interface Env {
CloudflareAuthKV: KVNamespace
Expand Down
2 changes: 1 addition & 1 deletion examples/issuer/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@openauthjs/example-issuer-cloudflare",
"version": "0.0.0",
"dependencies": {
"@openauthjs/openauth": "workspace:*",
"@kagii/openauth": "workspace:*",
"sst": "3.5.1"
}
}
6 changes: 3 additions & 3 deletions examples/issuer/custom-frontend/auth/issuer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { issuer } from "@openauthjs/openauth"
import { MemoryStorage } from "@openauthjs/openauth/storage/memory"
import { CodeProvider } from "@openauthjs/openauth/provider/code"
import { issuer } from "@kagii/openauth"
import { MemoryStorage } from "@kagii/openauth/storage/memory"
import { CodeProvider } from "@kagii/openauth/provider/code"
import { subjects } from "../../../subjects.js"

async function getUser(email: string) {
Expand Down
2 changes: 1 addition & 1 deletion examples/issuer/custom-frontend/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"name": "@openauthjs/example-custom-frontend-issuer",
"version": "0.0.0",
"dependencies": {
"@openauthjs/openauth": "workspace:*"
"@kagii/openauth": "workspace:*"
}
}
6 changes: 3 additions & 3 deletions examples/issuer/lambda/issuer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { issuer } from "@openauthjs/openauth"
import { issuer } from "@kagii/openauth"
import { handle } from "hono/aws-lambda"
import { subjects } from "../../subjects.js"
import { PasswordUI } from "@openauthjs/openauth/ui/password"
import { PasswordProvider } from "@openauthjs/openauth/provider/password"
import { PasswordUI } from "@kagii/openauth/ui/password"
import { PasswordProvider } from "@kagii/openauth/provider/password"

async function getUser(email: string) {
// Get user from database
Expand Down
2 changes: 1 addition & 1 deletion examples/issuer/lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@openauthjs/example-issuer-aws",
"version": "0.0.0",
"dependencies": {
"@openauthjs/openauth": "workspace:*",
"@kagii/openauth": "workspace:*",
"sst": "3.5.1"
}
}
8 changes: 4 additions & 4 deletions examples/issuer/node/authorizer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { issuer } from "@openauthjs/openauth"
import { MemoryStorage } from "@openauthjs/openauth/storage/memory"
import { PasswordUI } from "@openauthjs/openauth/ui/password"
import { issuer } from "@kagii/openauth"
import { MemoryStorage } from "@kagii/openauth/storage/memory"
import { PasswordUI } from "@kagii/openauth/ui/password"
import { serve } from "@hono/node-server"
import { subjects } from "../../subjects"
import { PasswordProvider } from "@openauthjs/openauth/provider/password"
import { PasswordProvider } from "@kagii/openauth/provider/password"

async function getUser(email: string) {
// Get user from database
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/sst/app/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Resource } from "sst"
import { createClient } from "@openauthjs/openauth/client"
import { createClient } from "@kagii/openauth/client"
import { cookies as getCookies } from "next/headers"

export const client = createClient({
Expand Down
8 changes: 4 additions & 4 deletions examples/quickstart/sst/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { handle } from "hono/aws-lambda"
import { issuer } from "@openauthjs/openauth"
import { CodeUI } from "@openauthjs/openauth/ui/code"
import { CodeProvider } from "@openauthjs/openauth/provider/code"
import { MemoryStorage } from "@openauthjs/openauth/storage/memory"
import { issuer } from "@kagii/openauth"
import { CodeUI } from "@kagii/openauth/ui/code"
import { CodeProvider } from "@kagii/openauth/provider/code"
import { MemoryStorage } from "@kagii/openauth/storage/memory"
import { subjects } from "./subjects"

async function getUser(email: string) {
Expand Down
Loading