Missing or incorrect CSRF cookie type - cakephp

I am using cakephp 4.1 and also xero api. When the user logs in xero is connected . Sometimes this error appears below. My questions is that how do i prevent this and why is this happening? "The problem is this: If a user has the login page tab several days opened in the browser then the cookie expires and this leads to this exception". This is incorrect as i can leave login page open for days and not get this error. I can't reproduce it . How do i detect this error and ow do i fix it. I thought the answer to the post does not solve my problem
Catch "Missing or incorrect CSRF cookie type." exception

Yes you are correct it should not happen, the way you can reproduce is by manually modifying the cookies from the browser dev tools.
Steps to do that (Chrome)
Open dev tools (Right-click and click on inspector)
Open Application tab
Switch to cookies (Choose the domain for which you are setting the cookies)
Change the expires field (to past date).

Related

Getting Error400 when signing into Strapi admin panel

I have a strapi cms which I use for fetching. Today I ran npm run develop to start the server, and it needed be to login. No big deal, I logged in with my credentials, and it says wrong credentials. I tried the 3 passwords I use, but none of them work. I clicked "forgot password" and waited for the password reset, but it never came. I went back to sign in again, and I notice this message whenever I click the sign in button:
POSThttp://localhost:1337/admin/login [HTTP/1.1 400 Bad Request 95ms]
This message is also displayed in my IDE's console:
debug POST /admin/login (89 ms) 400
I've been trying to login for the past hour but it's still not letting me. I've already restarted the server, the IDE, my computer, as well as clearing cache and cookies, but none of them worked. Any clue to solve this?
Update:
This message is appearing in the console. I wonder if it's relevant? It's weird though because I never modified with the scripts in my IDE.
DevTools failed to load SourceMap: Could not parse content for http://localhost:1337/admin/shallowequal.cjs.production.min.js.map: Unexpected token < in JSON at position 0

UNAUTHORIZED_CLIENT ABP Framework

My client site is broadcasting from 10.0.0.70. api broadcasts from localhost:44376 on the same machine.
10.0.0.70:4200 opens but when I click login it leads to http://localhost:44376/account/login site but 500
Internal Server Error
I am getting an UNAUTHORIZED_CLIENT error.
Probably you changed the appsettings endpoints to 10.0.x from localhost after running dbmigrator causing your client still registered with localhost:4200 redirect uri.
That's why you're getting UNAUTHORIZED_CLIENT error. I assume you are at the beginning of the project; you can delete your db and run db migrator again with your updated settings.
You can also check application logs for exact error messages; identityserver errors are logged detailed in log file.
This usually happens when CORS URL defined in the ClientCorsOrign database table is not valid. eg https:///www.domain.co.za is valid while https:///www.domain.co.za/app is not valid. So to accurate identitify cause of this error, open Logs in Identity api, in my case the CORS url was invalid..

Using AWS-Amplify with Firefox

I hope you are all doing good,
I have a question that I've been stuck on for the past couple of days.
I am building a website with React that uses AWS-Amplify for user authentications (For users on the Cognito AWS database).
I am working on the Log-in and Sign-up page, and it's working fine when using Chrome, but whenever I am using Firefox there is an issue (Specifically the Log-in).
Problem: There is a part in the JS code that uses the Auth.signin() function from the aws-amplify extension. This function takes in the username and password and returns if the user is authenticated or not. However, when using Firefox, this function gets timed-out, as if the browser can't get the response from the server. Here is a screenshot of the console:
Seems like the response is 403 but I am guessing it's because of the time-out.
(The try/catch doesn't catch anything because it looks as if the page freezes)
I hope I made it clear, and thank you for your time reading everything!
Do your request headers/body contain the correct username and password for the user in Firefox, and is it sending the request to the same endpoint as in Chrome? The 403 code makes me think that the endpoint is malformed on the Firefox request. Finally, is it sending with SRP_AUTH or USER_PASSWORD_AUTH?
Also, since you're using React with Cognito+Amplify for auth*, you might want to consider using the withAuthenticator higher-order-component provided by aws-amplify-react and styling it to your needs. Then you won't need to maintain your own login logic, won't need to worry about fixing it yourself if a browser change breaks your code, etc.

Keep Me Signed In message missing during login if using msal.js

Context
I'm developing a browser application that uses msal.js library to allow Azure Active Directory accounts to access our website. The application has the clientId and the scopes properly set and it uses loginRedirect and acquireTokenSilent successfully.
Problem
The issue I'm facing is that I'm unable to keep the session open because I don't see the Keep Me Signed In message (KMSI) so I can not answer 'YES' and make the AADSSO cookie persistent. For that reason after the login process, if the browser is closed I need to log in again.
Expectation
If I'm redirected to microsoft login from my website using msal.js library, I expect to see the KMSI message to enable persistent session (which for some reason I can see if I go directly to login.microsoftonline.com)
Sorry for the spanish: It says Do you want to keep the session open? No / Yes
Question
How can I enable KMSI with msal.js ?
The cause of not seeing 'Keep me signed in' login message when using msal.js is because when the library builds the URL to perform the login, it contains a query string item called x-client-Ver that changes the microsoftonline.com login flow.
If you remove that item from the URL (&x-client-Ver=1.1.3 for example), you can see the 'Keep me signed in' message.
The solution is to manually patch the library removing this until Microsoft fixes it. Like that: https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/982/commits

Google API app engine redirect uri

can someone point me in the right direction re: redirect uri
right now i have app hosted on appspot (nothing done or uploaded to it at this point)
"Error: Server Error
The server encountered an error and could not complete your request.
If the problem persists, please report your problem and mention this error message and the query that caused it."
do i need to upload anything for this to work?
https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi
POST /o/oauth2/token HTTP/1.1
Host: accounts.google.com
Content-Type: application/x-www-form-urlencoded
code=4/v6xr77ewYqhvHSyW6UJ1w7jKwAzu&
client_id=8819981768.apps.googleusercontent.com&
client_secret={client_secret}&
redirect_uri=https://oauth2-login-demo.appspot.com/code&
grant_type=authorization_code
i just want to authenticate so that i can use the calendar api
Do upload the application. I am not sure what you mean by saying that the app is hosted on appspot but nothing done or uploaded at this point. So, first make sure that you have uploaded a version of your application.
The OAuth process is redirecting the flow if I understand correct to oauth2-login-demo.appspot.com and you must have registered this callback url when setting up your application.
So it seems that the redirection is probably taking place but you are seeing the General Exception that is normally thrown by App Engine.
You should look into the Admin Console -> Logs for your application to understand the reason for the failure. You might get some information there about the cause.
If there is a problem with your code, it will point that in the logs. Alternately, put in some exception handlers and bump up the Log Level to INFO in your logging.properties to have a better chance of tracking down the root case.

Resources