You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* [Create a new `Passkey` instance and mount the routes](#create-a-new-passkey-instance-and-mount-the-routes)
27
-
* [Client-side](#client-side)
23
+
*[Implement storages: `UserStore` and two `SessionStore` one for WebAuthn and one for general session](#implement-storages-userstore-and-two-sessionstore-one-for-webauthn-and-one-for-general-session)
24
+
*[Create a new `Passkey` instance and mount the routes](#create-a-new-passkey-instance-and-mount-the-routes)
25
+
*[Client-side](#client-side)
28
26
*[Example Application](#example-application)
29
-
*[API](#api)
27
+
*[API](#api)
30
28
*[Middleware](#middleware)
31
-
*[Development](#development)
29
+
*[Development](#development)
32
30
*[Common tasks](#common-tasks)
33
31
*[Mocks](#mocks)
34
32
*[Troubleshooting](#troubleshooting)
35
-
*[FAQ](#faq)
36
-
*[Contributing](#contributing)
37
-
*[License](#license)
38
-
33
+
*[FAQ](#faq)
34
+
*[Contributing](#contributing)
35
+
*[License](#license)
39
36
<!-- TOC -->
40
37
41
38
## Features
42
39
43
40
-**User Management**: Handle user information and credentials.
44
41
-**WebAuthn Integration**: Easily integrate with WebAuthn for authentication.
45
42
-**Session Management**: Manage user sessions securely.
46
-
-**Middleware Support**: Implement middleware for authenticated routes.
43
+
-**Middleware Support**: Middleware for authenticated routes.
47
44
48
45
> [!WARNING]
49
46
> Stable version is not released yet. The API and the lib are under development.
@@ -74,61 +71,73 @@ go get github.com/egregors/passkey
74
71
75
72
## Usage
76
73
77
-
## Terminology
78
-
79
-
-**WebAuthn Credential ID** – is a unique ID generated by the authenticator (e.g. your smartphone, laptop or hardware
80
-
security key like YubiKey) during the registration (sign-up) process of a new credential (passkey).
81
-
-**WebAuthn User ID (user.id)** – is an ID specified by the relying party (RP) to represent a user account within their
82
-
system. In the context of passkeys, the User ID (user.id) plays a crucial role in linking a particular user with their
83
-
credentials (passkeys).
84
-
85
74
### Library Usage
86
75
87
-
To add a passkey service to your application, you need to do two things:
76
+
To add a passkey service to your application, you need to do a few simple steps:
88
77
89
-
#### Implement the`UserStore` and `SessionStore`interfaces
78
+
#### Implement storages:`UserStore` and two `SessionStore`one for WebAuthn and one for general session
|`New(cfg Config, opts ...Option) (*Passkey, error)`| Creates a new Passkey instance. |
251
+
|`MountRoutes(mux *http.ServeMux, path string)`| Mounts the Passkey routes onto a given HTTP multiplexer. |
252
+
|`Auth(userIDKey string, onSuccess, onFail http.HandlerFunc) func(next http.Handler) http.Handler`| Middleware to protect routes that require authentication. |
253
+
|`UserIDFromCtx(ctx context.Context, pkUserKey string) ([]byte, bool)`| Returns the user ID from the request context. If the userID is not found, it returns nil and false. |
0 commit comments