I have a login page that utilizes the django
authentication system.
Now, I am looking to transfer just the login page to a separate server (an external login page).
My goal is to have the username and password fields on the external login page, and then log in to the django system.
I have created the HTML on the external server.
<form method="POST" action="http://djangoserver.com/">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit">
</form>
However, I encountered an error.
Reason given for failure:
CSRF token missing
Upon inspecting the source code of the login page, I noticed that django
automatically generates a csrf
token using middleware.
<form method="POST">
<input type="hidden" name="csrfmiddlewaretoken" value="VEkMTu0EpmLbMVLRh4h9MOcuvcryIlA0M1USByG7R5PXkgYvMyzAhdKyq7gohpko">
Username
<input type="text" name="username" autofocus autocapitalize="none" autocomplete="username" maxlength="150" class="form-control" placeholder="Username" required id="id_username">
Password
<input type="password" name="password" autocomplete="current-password" class="form-control" placeholder="Password" required id="id_password">
<button type="submit">login</button>
</form>
Therefore, I believe I need to replicate the csrf
token setup on the external login page.
Does anyone have any suggestions on how to achieve this?