-
Notifications
You must be signed in to change notification settings - Fork 24
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
need some real world examples #61
Comments
Hi , I have created a very simple Auth Deno Api using this same repo and some other tools. https://github.com/Anstroy/deno-api/ I invite you to take a look at it, I am updating some of the README.md file for documentation, Thanks |
Check out https://github.com/authcompanion/authcompanion - recently updated for the latest djwt apis |
please add a importKey example: const key = await crypto.subtle.importKey(
"raw",
new TextEncoder().encode("your secret string"),
{ name: "HMAC", hash: "SHA-256" },
true,
["sign", "verify"],
) |
@transtone if this is not enough you can find other examples here or on mdn. |
for someone who not know much about a fine example like https://jwt.io does is very nice. |
Switching from this : import {
create,
verify
} from 'https://deno.land/x/[email protected]/mod.ts';
export const
signJwt = async (
data,
secret
) => await create(
{
alg: 'HS256',
typ: 'JWT'
},
data,
secret
),
verifyJwt = async (
jwt,
secret
) => await verify(
jwt,
secret,
'HS256'
); To this : import {
create,
verify
} from 'https://deno.land/x/[email protected]/mod.ts';
const
cryptoArgs = [
{ name: 'HMAC', hash: 'SHA-256' },
true,
['sign', 'verify']
],
keyToSecret = async key => (await crypto.subtle.exportKey(
'jwk',
key
)).k,
secretToKey = secret => crypto.subtle.importKey(
'raw',
new TextEncoder().encode(secret),
...cryptoArgs
);
export const
generateSecret = async () => await keyToSecret(await crypto.subtle.generateKey(...cryptoArgs)),
signJwt = async (
data,
secret
) => await create(
{
alg: 'HS256',
typ: 'JWT'
},
data,
await secretToKey(secret)
),
verifyJwt = async (
jwt,
secret
) => await verify(
jwt,
await secretToKey(secret)
); took me much more time than it would have if all of those methods were documented on the README. Also, PR #54, which introduced those changes, should have been released as a new major version according to article 8 of SemVer specification :
Thanks |
PRs are welcome!
Good point, thank you! |
All the tutorials out there I could find seem to use an outdated api for djwt.
I'm looking to just authetnicate a user upon login and validate them for authorized api calls.
The text was updated successfully, but these errors were encountered: