passkey

package
v1.15.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package passkey implements the support of Webauthn credentials for authentication. It is based on the W3C's "Web Authentication: An API for accessing Public Key Credentials" https://www.w3.org/TR/webauthn-2/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientData

type ClientData struct {
	Challenge string `json:"challenge"`
	Origin    string `json:"origin"`
	CredType  string `json:"type"`
}

Client data for signature: https://www.w3.org/TR/webauthn-1/#sec-client-data

type Credential

type Credential struct {
	Id        string
	Rp        string
	UserName  string
	Algorithm string
	SecretKey *ecdsa.PrivateKey
	Counter   uint32
	Flags     CredentialFlags
}

Structure to store information and key of public key credential.

func CreateCredential

func CreateCredential(rp string, user string, flags CredentialFlags) (*Credential, error)

Implementation of the authenticatorMakeCredential Operation: https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred

func (*Credential) GetAssertion

func (cred *Credential) GetAssertion(challenge string, origin string) (*Response, error)

Implementation of the authenticatorGetAssertion Operation: https://www.w3.org/TR/webauthn-2/#authenticatorgetassertion

type CredentialFlags

type CredentialFlags struct {
	UserPresent     bool
	UserVerified    bool
	AttestationData bool
	ExtensionData   bool
}

Flags for the credential parameters: https://www.w3.org/TR/webauthn-2/#flags

type Response

type Response struct {
	AuthenticatorData []byte `json:"authdata"`
	ClientDataJSON    []byte `json:"client_data_json"`
	Signature         []byte `json:"signature"`
	Login             string `json:"login"`
}

Response from a GetAssertion: https://www.w3.org/TR/webauthn-1/#authenticatorGetAssertion-return-values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL