Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Authentication

René Van Der Schueren edited this page Mar 16, 2023 · 3 revisions

Backend

For the backend we use two authentication methods.

Session authentication

This is only used for internal things such as the admin panel and the API docs. This should never be used from the frontend.

JWT Token authentication

This is the authentication for all API requests from the frontend.

Frontend

As suggested by the official NextJS documentation on authentication, we are using next-auth for authentication.

Next-auth is setup to use JWT.

Postman

If you want to use postman with authentication go to your collection, press Authorization and select Bearer token, in the Token field add {{BEARERTOKEN}} like so:
image

Then go to Pre-request script and enter the script below:

pm.sendRequest({
    url: 'localhost:8000/api/user/auth/',
    method: 'POST',
    header: {
        'Content-Type': 'application/json; charset=UTF-8',
    },
    body: {
        mode: 'raw',
        raw: JSON.stringify({'email': '[email protected]', 'password': 'admin'})
    }
},
    (err, res) => {
        console.log(res.json())
        // Set BEARERTOKEN
        pm.globals.set("BEARERTOKEN", res.json().access)
        // console.log(res.json());
});