Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create LaravelInertia.js #436

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Create LaravelInertia.js #436

wants to merge 2 commits into from

Conversation

GoldraK
Copy link

@GoldraK GoldraK commented Feb 9, 2024

Hello,

Based on Django Auth I have created Laravel + Inertiajs Auth.

Comment on lines 60 to 62
var dataPageObject;

dataPageObject = JSON.parse(dataPageJsonString);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var dataPageObject = JSON.parse(dataPageJsonString);

secondMsg.getRequestHeader().setHeader("X-XSRF-TOKEN", decodeURIComponent(csrfTokenValue));
secondMsg.getRequestHeader().setHeader("Content-Type", "application/json");
secondMsg.getRequestHeader().setHeader("X-Requested-With", "XMLHttpRequest");
secondMsg.getRequestHeader().setHeader("Referer", "https://app.opensecdevops.com/login");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect this to use baseURL, if not possible it should be a required parameter.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this a big error of the testing sorry

Comment on lines 78 to 87
secondMsg.getRequestHeader().setHeader("X-XSRF-TOKEN", decodeURIComponent(csrfTokenValue));
secondMsg.getRequestHeader().setHeader("Content-Type", "application/json");
secondMsg.getRequestHeader().setHeader("X-Requested-With", "XMLHttpRequest");
secondMsg.getRequestHeader().setHeader("Referer", "https://app.opensecdevops.com/login");
secondMsg.getRequestHeader().setHeader("X-Inertia", 'true');
secondMsg.getRequestHeader().setHeader("X-Inertia-Version", inertiaVersion);
secondMsg.getRequestHeader().setHeader("Accept", "text/html, application/xhtml+xml");

// Send cookies
secondMsg.getRequestHeader().setHeader(HttpHeader.COOKIE, "XSRF-TOKEN=" + csrfTokenValue + "; osdo_session=" + cookieSessionValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use secondRequestHeader instead of the getter.

helper.sendAndReceive(secondMsg, false);

// Get the status code of the response.
// Aquí puedes verificar el código de estado de la respuesta para confirmar si la autenticación fue exitosa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to English?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes no problem

//

// Build message.
var firstRequestURI = new URI(targetURL, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have expected the URLs to be properly encoded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the problem, it's how I saw it being done here

https://github.com/GoldraK/community-scripts/blob/main/authentication/DjangoAuthentication.js#L29



function getRequiredParamsNames() {
return ["Target URL", "Username field", "Password field", "Session Cookie name"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these are not used.



function getOptionalParamsNames() {
return ["Extra POST data"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, go to delete.

@thc202
Copy link
Member

thc202 commented Feb 9, 2024

The changelog should be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants