-
Notifications
You must be signed in to change notification settings - Fork 349
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
[feature] local emulation of Netlify Identity #440
Comments
Is there any change with this area? I'm using netlify for the first time and feel like maybe I'm missing something obvious. I can't figure out how to develop apps locally using netlify's provided authentication. |
Hi @zachwolf are you experiencing a specific error? |
I am using the widget, have not yet figured out how to get identity to work locally with either |
Hi @allpwrfulroot this might help for debugging functions. If those suggestions are not helpful, can you describe using a step by step guide (possibly with an example repo) your use case. |
So I opened a support ticket for my issue, but they told me to open an issue here since it's related. Some more context for the screenshot: const { identity, user { sub: sellerId } } = context.clientContext
const { url, token } = identity |
Hey team! Adding a comment on behalf of a customer in the Helpdesk (see https://netlify.zendesk.com/agent/tickets/61073).
Works in prod:
This does not work locally:
NOTE: Wondered if you could share your 2c about this! |
Hi @Pieparker, this is a tricky one and there are several issues preventing from this scenario to work.
However, not all is lost, I was able to find a simple workaround using the following code: <head>
<script
type="text/javascript"
src="https://identity.netlify.com/v1/netlify-identity-widget.js"
></script>
<script>
if (
location.hostname === "localhost" ||
location.hostname === "127.0.0.1"
) {
/* Signed using "secret" and decodes to
{
"exp": 1893456000,
"sub": "12345678",
"email": "admin@admin.com",
"app_metadata": {
"authorization": {
"roles": [
"admin"
]
}
},
"user_metadata": {}
}
*/
const fakeJWT =
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE4OTM0NTYwMDAsInN1YiI6IjEyMzQ1Njc4IiwiZW1haWwiOiJhZG1pbkBhZG1pbi5jb20iLCJhcHBfbWV0YWRhdGEiOnsiYXV0aG9yaXphdGlvbiI6eyJyb2xlcyI6WyJhZG1pbiJdfX0sInVzZXJfbWV0YWRhdGEiOnt9fQ.hOSRyH73Ps4poJ4RrB22lLSOHrk25xiwyVPCVyS6XpQ";
netlifyIdentity.on("login", (user) => {
document.cookie = `nf_jwt=${fakeJWT};`;
});
netlifyIdentity.on("logout", () => {
document.cookie = `nf_jwt= ; expires = Thu, 01 Jan 1970 00:00:00 GMT`;
});
}
</script>
</head>
<body>
This is an index page
<div data-netlify-identity-button>Login</div>
</body> Going forward I believe |
Is there already someone aware of what @crock wrote regarding the missing "Authorization" header on requests to the emulated Identity endpoint https://netlify-dev-locally-emulated-identity.netlify.app/.netlify/identity/ ? Even when directly hitting this endpoint with Postman and using the credentials which the netlify dev command serves, the "Authorization" header is totally omitted. It seems, that maybe in a preflight check the server responds with the cors info, that this custom header is not allowed to be used for the endpoint? |
- Do you want to request a feature or report a bug?
feature
- What is the current behavior?
we currently can only do very limited decoding of JWTs but that isnt even a fraction of what we need to do for netlify identity dev.
with the ideal contract, we can offer local emulation of Netlify Identity (having some session state, and just focusing on letting people test signup flows (as well as maybe firing off identity event triggers!))
things to replicate:
/authorize?provider=${provider}&invite_token=${token}
/authorize?provider=${provider}
;`/token
parsinggrant_type=password&username=email&password={password}
/verify
The text was updated successfully, but these errors were encountered: