Quickstart: Embedded Login

Go from zero to fully passwordless authentication in just a few minutes.

Estimated Time: 7 minutes

You can follow along with one of our sample apps found on GitHub.

Embedded User Authentication with Passage

Here's what is covered in this quick start guide:

  1. Create an app in the Passage Console

  2. Add Passage Element to your frontend

  3. Implement authorization middleware using backend SDK

  4. Done!

Create an app in the Passage Console

To create an app, first login or create an account for the Passage Console at https://console.passage.id/register. When you first sign up, you will be redirected to your homepage that includes an example application to explore. To create your first new application, select the "Create New App" button on the home page and the "Embedded login experience" option.

Give your application a name and then provide the following fields:

  • Authentication Origin - the domain that Passage will run on

  • Redirect URL - the path you want to direct users to after successful login

For example, if you are building a local test app, your settings will probably look something like this:

  • Authentication Origin - http://localhost:8080

  • Redirect URL - /dashboard or /

Once you've created your application, copy the Application ID from the dashboard.

Add a Passage Element to your frontend

A Passage Element provides a complete UI/UX for users to register and login with biometrics or magic links.

In your web app, add the following code wherever you want your users to register or login. If you created a Passage account, you can include your Application ID that you copied in the last step:

<passage-auth app-id="PASTE PASSAGE APP ID HERE"></passage-auth>
<script src="https://psg.so/web.js"></script>

You can now reload your webpage to see fully functional user authentication!

Implement authorization middleware

After your users sign in with a Passage Element, you can use a Passage backend library to authenticate their requests. The code snippets below demonstrate how to use Passage to authenticate requests:

To use Passage in your Go application, run:

go get github.com/passageidentity/passage-go

at the command line.

import (
	"net/http"

	"github.com/passageidentity/passage-go"
)

func exampleHandler(w http.ResponseWriter, r *http.Request) {

	// Authenticate this request using the Passage SDK:
	psg, _ := passage.New("<PASSAGE_APP_ID>", nil)
	_, err := psg.AuthenticateRequest(r)
	if err != nil {
		// 🚨 Authentication failed!
		w.WriteHeader(http.StatusUnauthorized)
		return
	}

	// ✅ Authentication successful. Proceed...

}

You just implemented awesome user authentication! 🎉

Visit your website in a browser to see how easy Passage is for your users.

What's Next?

Once you have your application set up, you can:

If you created a test app, users are ephemeral and are not persisted outside of your browser. To use Passage in production, claim your Passage app with the unique link in the Passage element or create a new app in the Passage Console.

Passage is always seeking feedback on the product. If you have feedback, bug reports, or feature requests, we would love to hear from you. You can email me at [email protected] or fill out this form.

Last updated