Authentication
User authentication is implemented in next-auth 4 using a custom CredentialsProvider and ldapts as a typesafe LDAP client.
When a user enters their credentials on the Login Page, this info is passed to the authorize function and then used to fetch the user’s data using their own credentials.
- If this LDAP query returns the data, the query was successful and the user is authenticated
- If this LDAP query returns an error, the login was not successful and the users gets an error message
This data is then fet into the session function in order to store it in the session token.
ℹ️
ldapts is a well-maintained and well-documented package. However, it lacks
the ability to configure mutiple LDAP servers to use as backup, so if “our”
LDAP server is offline, authentication will not work.
Relevant Files
- route.ts
Last updated on