Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(provider): add United Effects provider #4546

Merged
merged 6 commits into from Jun 3, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/docs/providers/united-effects.md
@@ -0,0 +1,43 @@
---
id: united-effects
title: United Effects
---

## Documentation

https://docs.unitedeffects.com/integrations/nextauthjs

## Configuration

https://core.unitedeffects.com

## Options

The **United Effects Provider** comes with a set of default options:

- [United Effects Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/united-effects.ts)

You can override any of the options to suit your own use case.

## Example

```js
import UnitedEffectsProvider from "next-auth/providers/united-effects";
...
providers: [
UnitedEffectsProvider({
clientId: process.env.UNITED_EFFECTS_CLIENT_ID,
clientSecret: process.env.UNITED_EFFECTS_CLIENT_SECRET,
issuer: process.env.UNITED_EFFECTS_ISSUER
})
]
...
```

:::note
`issuer` should be the fully qualified URL including your Auth Group ID – e.g. `https://auth.unitedeffects.com/YQpbQV5dbW-224dCovz-3`
:::

:::warning
The United Effects API does not return the user name or image by design, so this provider will return null for both. United Effects prioritizes user personal information security above all and has built a secured profile access request system separate from the provider API.
:::
31 changes: 31 additions & 0 deletions packages/next-auth/src/providers/united-effects.ts
@@ -0,0 +1,31 @@
import type { OAuthConfig, OAuthUserConfig } from "."

export interface UnitedEffectsProfile extends Record<string, any> {
sub: string
email: string
}

export default function UnitedEffects<P extends UnitedEffectsProfile>(
options: OAuthUserConfig<P> & { issuer: string }
): OAuthConfig<P> {
return {
id: "united-effects",
name: "United Effects",
wellKnown: `${options.issuer}/.well-known/openid-configuration`,
type: "oauth",
authorization: {
params: { scope: "openid email profile", resource: options.issuer },
},
checks: ["pkce", "state"],
idToken: true,
profile(profile) {
return {
id: profile.sub,
name: null,
email: profile.email,
image: null,
}
},
options,
}
}