Closed StarZeus closed 2 months ago
@StarZeus, thanks for creating this issue! ππΌ I just tried this and I can get my project for both attempts.
Would you please check and make sure:
~/.appwrite/prefs.json
file is not malformed./appwrite.json
file is not malformed@stnguyen90 - Thank you for looking into this.
To add clarity.
~/.appwrite/prefs.json
is not malformed./appwrite.json
is not malformed/console/account/sessions page
Also, I noticed that the ~/.appwrite/pref.json updated with cookies a_session_console_legacy
and domain
after login but removed immediately after executing 1st command. I believe that's why the 2nd command onwards is not working.
The appwrite url is https
and I have set selfSigned=true
if that make a difference
Also, I noticed that the ~/.appwrite/pref.json updated with cookies a_session_console_legacy and domain after login but removed immediately after executing 1st command.
It's replaced with an empty string? The only time that would happen is either:
Maybe you have something between the CLI and Appwrite messing up the cookies?
Does this happen with other commands like appwrite projects list
? Do you get logged out from the Appwrite web console?
It happens for all command. I'm not logged out from appwrite web console. Thats stays logged in.
After every command the a_session_console_legacy and domain are not in cookie anymore.
"cookie": "route=b1c61a93f68b5c389187caa649ee5027; Expires=Mon, 30-Oct-23 17:02:35 GMT; Max-Age=172800; Path=/(.*); Secure; HttpOnly"
Very bizarre...Would you be able to curl Appwrite to see the full request? Something like:
ENDPOINT="https://[YOUR_HOSTNAME]/v1"
# Sign in (make sure to replace [YOUR_EMAIL] and [YOUR_PASSWORD]
curl -s -k -v -b console-cookies.txt -c console-cookies.txt "$ENDPOINT/account/sessions/email" \
-H 'content-type: application/json' \
-H 'x-appwrite-project: console' \
--data-raw '{"email":"[YOUR_EMAIL]","password":"[YOUR_PASSWORD]"}' \
--compressed \
--insecure
# List projects
curl -s -k -v -b console-cookies.txt -c console-cookies.txt "$ENDPOINT/projects" \
-H 'content-type: application/json' \
-H 'x-appwrite-project: console' \
--compressed \
--insecure
@StarZeus, have you had a chance to try the commands I suggested. Btw, I'll need to close this soon due to inactivity.
I'll try the above curl command and post an update
@stnguyen90 - I was able to execute above curl commands. I can see project details returning even when I hit the 2nd curl repeatedly.
"cookie": "route=b1c61a93f68b5c389187caa649ee5027; Expires=Mon, 30-Oct-23 17:02:35 GMT; Max-Age=172800; Path=/(.*); Secure; HttpOnly"
What is this you shared? This doesn't look like what Appwrite would typically respond. It seems there's something else that is passing back additional cookies...And since the CLI only grabs the first set-cookie
, the cookie gets overwritten
I am running appwrite in kubernetes cluster. "route" is the Sticky/Affinity cookie set by the nginx ingress controller so that subsequent requests are sent to the same container.
Is there a reason why the cli captures only the first cookie?
Below change to capture all cookies from response fixes my problem. I'll be raising a PR
let cookieString = "";
response.headers["set-cookie"].forEach((cookie) => {
cookieString += cookie.split(";")[0] + ";";
});
globalConfig.setCookie(cookieString);
@stnguyen90 raised https://github.com/StarZeus/sdk-generator/pull/1
@StarZeus, thanks for creating this PR. Would you please create the PR to target our repo instead of your forked master branch?
π Reproduction steps
appwrite login
command and console user id and passwordRegardless of what command we execute 2nd time onwards the command fails as the user is not logged in anymore
π Expected behavior
appwrite cli should stay logged in until logout
π Actual Behavior
appwrite cli logout automatically after each command
π² Appwrite version
Version 1.4.x
π» Operating system
Linux
𧱠Your Environment
Appwrite version 1.4.7 installed on kubernetes v1.20 appwrite-cli@4.1.0 installed on mac os Monterey
π Have you spent some time to check if this issue has been raised before?
π’ Have you read the Code of Conduct?