-
Notifications
You must be signed in to change notification settings - Fork 56
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
How to get the logged in user in the application #62
Comments
all retrieved information are saved in the cookie. one of them has a value of userId which has .LastAuthUser as suffix in key |
Thanks!
From: Junghwa Theodore Park ***@***.***>
Date: Saturday, April 15, 2023 at 2:01 PM
To: awslabs/cognito-at-edge ***@***.***>
Cc: nagendrakumar02 ***@***.***>, Author ***@***.***>
Subject: Re: [awslabs/cognito-at-edge] How to get the logged in user in the application (Issue #62)
all retrieved information are saved in the cookie. one of them has a value of userId.
—
Reply to this email directly, view it on GitHub<https://www.google.com/url?q=https://github.com/awslabs/cognito-at-edge/issues/62%23issuecomment-1509916115&source=gmail-imap&ust=1682186468000000&usg=AOvVaw0PMOS6CSPA0C9Tf1XNdCxZ>, or unsubscribe<https://www.google.com/url?q=https://github.com/notifications/unsubscribe-auth/AY4N7ZORVHEQR6FU7T4LNOLXBLO6HANCNFSM6AAAAAAWUUBCNE&source=gmail-imap&ust=1682186468000000&usg=AOvVaw39B_wxa-84rWgUq1We1jRV>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
At a high-level, this is the flow of the code in the application at-present. this._cookieBase = `CognitoIdentityServiceProvider.${params.userPoolAppId}`;
_buildCookieAccessTokenKey = (username: string) => `${this._cookieBase}.${username}.accessToken`;
_buildCookieIDTokenKey = (username: string) => `${this._cookieBase}.${username}.idToken`;
_buildCookieRefreshTokenKey = (username: string) => `${this._cookieBase}.${username}.refreshToken`;
_buildCookieScopeKey = (username: string) => `${this._cookieBase}.${username}.tokenScopesString`;
_buildCookieUsernameKey = () => `${this._cookieBase}.LastAuthUser`;
// Assumed that `cookieHeaders[string] => { key: string, value: string, };`
// Bearing in mind that the cookies may not actually exist :)
const cookieUsername = cookieHeaders[this._buildCookieUsernameKey()];
const cookieAccessToken = cookieHeaders[this._buildCookieAccessTokenKey(cookieUsername?.value)];
const cookieIDToken = cookieHeaders[this._buildCookieIDTokenKey(cookieUsername?.value)];
const cookieRefreshToken = cookieHeaders[this._buildCookieRefreshTokenKey(cookieUsername?.value)];
const tokens: Tokens = {
accessToken: cookieAccessToken.value,
idToken: cookieIDToken.value,
refreshToken: cookieRefreshToken.value,
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can we help?
I am currently using cognito@edge and attached it to the CDN. How can I retrieve the userId who has logged into the application?
The text was updated successfully, but these errors were encountered: