Keystone is CMS for Nodejs based projects, featuring customizable API, access control, authentication etc. Its is self hosted CMS.

Let's learn setup Keystone authentication.

I assume that you had a Keystone project in hand and have a list of users. By default there is no login screen appeared in the CMS window, we have to setup authentication for that.

Keystone Authentication

First up all we need @ketsonejs/auth-password and create authentication rule.

npm i --save @keystonejs/auth-password

In the index.js add the import and create authentication object. We can utilize the email or other field for authentication, it is up to you.

const authStrategy = keystone.createAuthStrategy(   {     type: PasswordAuthStrategy,     list: 'User',     config: {       identityField: 'name',       secretField: 'password'     }   } )

Add the auth to Admin UI

Now we are ready to configure the authentication, add the authStrategy to AdminUIApp constructor.

module.exports = {   keystone,   apps: [     new GraphQLApp(),     new AdminUIApp({       name: PROJECT_NAME, authStrategy,     }),     new NuxtApp({       srcDir: 'src',       buildDir: 'dist',     }),   ], };

To run the CMS cd into the folder and run yarn dev

Following keystone post may help you learn more


This free site is ad-supported. Learn more