Skip to content

This repository contains the code that shows how to implement credential based authentication using Paradym

Notifications You must be signed in to change notification settings

animo/paradym-example-user-authentication

Repository files navigation

User authentication using credentials with Paradym


 Demo of the application that shows a QR code to login using a credential.

Check out the YouTube video for a complete walkthrough of the demo application and its workflows.

This demo uses Paradym, a workflow builder for developers that provides the infrastructure you need to use verifiable credentials in your solution. If you don't have an account yet, you can start with our quick start guide.

This demo also uses the Paradym Wallet, an open-source companion app to the Paradym platform available on the Apple App Store and Google Play Store.

Prerequisites

Setup your workflows

Register the credential

First, we need to register the credential template. In this template, we define the properties of the credential we want to issue in our application.

  • Create a new workflow in Paradym and navigate to the Templates tab.
  • Look for the 'Register Credential Template' workflow, and click on 'use template'.
  • Publish and run the workflow with the following attributes:
    • Name: Bank account credential
    • Version: 1.0
    • Attributes: (Make sure to capitalize the first character!)
      • Name
      • Email
  • Open the result of the createCredentialDefinition action and copy the credentialDefinitionId. Save the value for later.

User sign-up workflow

Now that we have the required credential definition Id, we can set up the sign-up workflow.

  • Start on the Paradym dashboard and create a new workflow.
  • Copy the contents from the sign-up-user.yaml file from the Paradym directory.
  • Replace the <YOUR_CREDENTIAL_DEFINITION_ID> value with the credentialDefinitionId value from the first workflow.
  • Publish the workflow.

User login workflow

Great, we now have a way to sign up new users. The last workflow will handle the login requests for existing users.

  • Start on the Paradym dashboard and create a new workflow.
  • Copy the contents from the login-user.yaml file from the Paradym directory.
  • Replace the <YOUR_CREDENTIAL_DEFINITION_ID> value with the credentialDefinitionId value from the first workflow.
  • Publish the workflow.

Step 3: Set your Paradym Project ID

You can find your Paradym Project ID in the settings tab on the Paradym dashboard as described here.

Step 4: Create your Paradym API Key

You can generate your API key in the settings tab on the Paradym dashboard as described here.

Step 5: Set the environment variables

The environment variables consist of your Paradym API Key, Paradym project ID, and the ID's of the workflows just created. Once you have created the workflows in the Paradym dashboard, you can copy the workflow ID's from Paradym and set them as environment variables.

cp .env.example .env
Variable Description
PARADYM_API_KEY This is the API key used to send request to Paradym. You can generate your API key in the settings tab on the Paradym dashboard as described in here.
PARADYM_PROJECT_ID This is your Paradym project identifier. It can be located in the settings tab on the Paradym dashboard as described here.
SIGN_UP_WORKFLOW_ID This is the ID of the issue course credential workflow. Once you have created the workflow in Paradym you can copy the ID from the executions tab.
LOGIN_WORKFLOW_ID This is the ID of the verify course credential workflow. Once you have created the workflow in Paradym you can copy the ID from the executions tab.

Running the demo

Make sure to install the dependencies:

# bun
bun install

Initiate the data storage

npm exec drizzle-kit push:sqlite

You can then run the development server:

# bun
bun run dev

Open http://localhost:3000 with your browser to see the result.

About

This repository contains the code that shows how to implement credential based authentication using Paradym

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published