1.45.0 • Published 2 months ago
payload-plugin-oidc v1.45.0
OIDC plugin for Payload CMS
Features
- Adds ability to sign in with your own OIDC provider
- Adds sign in button on login page
- Supports sign in and optional creation of user
Installation
npm install payload-plugin-oidc
# or
yarn add payload-plugin-oidc
Usage
// payload.config.ts
import { oidcPlugin } from 'payload-plugin-oidc';
export default buildConfig({
serverURL: process.env.SERVER_URL,
collections: [Users],
plugins: [
oidcPlugin({
clientID: process.env.OIDC_CLIENT_ID,
clientSecret: process.env.OIDC_CLIENT_SECRET,
authorizationURL: `${process.env.OIDC_URI}/oidc/auth`,
tokenURL: `${process.env.OIDC_URI}/oidc/token`,
initPath: `/oidc/signin`,
callbackPath: `/oidc/callback`,
callbackURL: `${process.env.SELF_URL}/oidc/callback`,
scope: 'openid offline_access profile email custom_data',
mongoUrl: process.env.DATABASE_URI,
components: {
Button: SignInButton, //can be your own custom component
position: "beforeLogin" //beforeLogin | afterLogin
},
userCollection: {
slug: Users.slug,
searchKey: 'email',
},
registerUserIfNotFound: true,
async userinfo(accessToken) {
const { data: user } = await axios.get(`${process.env.OIDC_URI}/oidc/me`, {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return {
sub: user.sub,
name: user.name,
email: user.email,
// You can use OIDC user custom data to get the role for this app
role: user.custom_data?.my_app_role,
// or you can do something like this
// role: user.custom_data?.role ? 'admin' : 'editor',
};
},
}),
],
});
Contributing
Contributions and feedback are very welcome.
To get it running:
- Clone the project.
npm install
npm run build
License
The MIT License (MIT). Please see License File for more information.
1.45.0
2 months ago
1.44.0
6 months ago
1.43.0
6 months ago
1.42.0
6 months ago
1.41.0
6 months ago
1.40.0
6 months ago
1.39.0
6 months ago
1.38.0
6 months ago
1.37.0
6 months ago
1.36.0
6 months ago
1.35.0
6 months ago
1.34.0
6 months ago
1.33.0
6 months ago
1.32.0
6 months ago
1.31.0
6 months ago
1.30.0
6 months ago
1.29.0
6 months ago
1.27.0
6 months ago
1.26.0
6 months ago
1.24.0
6 months ago
1.23.0
6 months ago
1.22.0
6 months ago
1.21.0
6 months ago
1.20.0
6 months ago
1.19.0
6 months ago
1.15.0
6 months ago
1.14.0
6 months ago
1.12.0
6 months ago
1.11.0
6 months ago
1.4.0
6 months ago
1.3.0
6 months ago
1.0.0
6 months ago
0.10.0
6 months ago
0.9.0
6 months ago
0.8.0
6 months ago
0.7.0
6 months ago
0.5.0
6 months ago
0.0.1
6 months ago