Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Revolutionise Authentication using Hanko
sonu sharma
sonu sharma

Posted on

Revolutionise Authentication using Hanko

Hanko Memes

  • It is an AI-based fun project which lets anyone create memes.
  • This project is part of a hackathon to create any functioning app that can be hosted online with Hanko auth integrated.
  • In this project OpenAI chat completion model generates a caption given a topic and audience.
  • Once the caption is generated user can use a meme template to add the generated caption thus producing a sharable meme.
  • Technologies: NextJs, Hanko Authentication, Supabase, ui.shadcn , Deployed on Netlify and Vercel

Working Application :https://hanko-memes.vercel.app

Run the project

Just clone [hanko-memes](https://github.com/sonu0702/ repo

Install all packages

   yarninstall
Enter fullscreen modeExit fullscreen mode

.env file , generate yourhanko api url

   copy content of .env.example into .env
Enter fullscreen modeExit fullscreen mode

Run the server

   npm run dev
Enter fullscreen modeExit fullscreen mode

The application connects with the backend server deployed on Netlify.
You can find the code inhanko-memes-be
If you want to check out just the frontend integration of
Hanko Authentication just check my frontend repohanko-memes

For the frontend integration of the Hanko Authentication, I usedhanko-nextjs-starter. It is very helpful and I would recommend this since it will give a clear picture of the authentication flow. The other which developers have isHanko documentation.

So Hanko is a hands-down winner in enhancing experience user authentication and security.
This is my first time using a biometric authentication integration into a web application and Hanko made it very simple.

Application using Hanko

Login

This is the interface of login for users, they can login in using email or passkey, which will open an interface to use the finger biometric of your device,
in my case laptop.

Meme template, MyMemes and Generate meme are other features which I have added.

Hanko login Interface

Meme Templates

Meme Template page lists all the meme templates which a user can use to write captions and personalise the meme.

Once you click on any of the Memes you will be redirected to theMeme Generator page.

Meme Templates

Meme Generator

This is the most interesting feature actually. You just have to fill in Topic and Audience as shown in the screenshot and click onAI Captions, AI will generate captions for you.
or you can just type in top and bottom captions and then click on Generate Meme to create a shareable meme.

image

My Memes

Since you are logged into the application, the application stores the memes generated by you to be visible only to you.

image

Backend Integration of Hanko Auth

I have my backend code inhanko-memes-be. The most significant peace of code which I want to briefly touch upon is how to handle / very Hanko Auth Token.

Let me paste the code here

constjwt=require('jsonwebtoken');constjwksClient=require('jwks-rsa');authenticatedUserId:async(event)=>{if(event.headers.authorization&&event.headers.authorization.split("")[0]==="Bearer"){lettoken=event.headers.authorization.split("")[1];letclient=jwksClient({jwksUri:`${process.env.HANKO_API_URL}/.well-known/jwks.json`})letsignkey=awaitclient.getSigningKey()letpublicKey=signkey.getPublicKey();letverified=jwt.verify(token,publicKey,{})returnverified.sub;}else{thrownewError(`Invalid user`)}}
Enter fullscreen modeExit fullscreen mode

It is as simple as it looks. Hanko has followed JWT token standards for user authentication.

I have used standardjsonwebtoken andjwks-rsa libraries. These libraries helped me get the public key using that I have verifed the JWT token to extract userId.

By participating inhanko hackathon hackathon I got to explore Hanko Authentication an awesome authentication library, OpenAI to generate meme captions and Next.Js 13.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Full Stack developer, actively programming in golang, reactJS, typeScript ...
  • Location
    karnataka,India
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp