webauthn

package
v0.0.0-...-a4f6240 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttestationStatement

type AttestationStatement interface {
	Verify(authData AuthData, clienDataHash []byte) error
}

type AuthData

type AuthData struct {
	Raw                    []byte
	RPIDHash               []byte
	Flags                  AuthFlags
	SignCount              []byte
	AAGUID                 []byte
	CredentialID           []byte
	RawCredentialPublicKey []byte
	CredentialPublicKey    PublicKey
}

type AuthFlags

type AuthFlags byte

func (AuthFlags) Verify

func (flags AuthFlags) Verify() error

type AuthenticationController

type AuthenticationController struct {
	// contains filtered or unexported fields
}

func NewAuthenticationController

func NewAuthenticationController(service *AuthenticationService) *AuthenticationController

func (*AuthenticationController) RegisterRoutes

func (c *AuthenticationController) RegisterRoutes(router gin.IRoutes)

type AuthenticationSelection

type AuthenticationSelection struct {
	AuthenticatorAttachment string `json:"authenticatorAttachment"`
	RequireResidentKey      bool   `json:"requireResidentKey"`
	UserVerification        string `json:"userVerification"`
}

type AuthenticationService

type AuthenticationService struct {
	// contains filtered or unexported fields
}

func NewAuthenticationService

func NewAuthenticationService(
	initAuthenticationStore core.KeyValueStore[string, CredentialOptions],
	authenticationVerifierStore core.KeyValueStore[string, []byte],
	userService *domain.UserService,
	credentialService *domain.CredentialService,
) *AuthenticationService

func (*AuthenticationService) InitiateAuthentication

func (s *AuthenticationService) InitiateAuthentication(ctx context.Context, request *InitiateAuthenticationRequest) (CredentialOptions, error)

func (*AuthenticationService) IssueGrant

func (s *AuthenticationService) IssueGrant(ctx context.Context, user *domain.User) (*Success, error)

func (*AuthenticationService) Login

func (*AuthenticationService) Register

type CreateCredentialRequest

type CreateCredentialRequest struct {
	AuthenticationID string                      `json:"authenticationId"`
	Id               string                      `json:"id"`
	RawID            []byte                      `json:"rawId"`
	Type             string                      `json:"type"`
	Response         RawCreateCredentialResponse `json:"response"`
}

type CreationCredentialResponse

type CreationCredentialResponse struct {
	ClientData        clientData
	AttestationObject attestationObject
}

func (*CreationCredentialResponse) Validate

func (response *CreationCredentialResponse) Validate(options PublicKeyCredentialOptions, credential *domain.Credential) error

type CredentialCreationOptions

type CredentialCreationOptions struct {
	AuthenticationId string                             `json:"authenticationId"`
	Type             string                             `json:"type"`
	Options          PublicKeyCredentialCreationOptions `json:"publicKey"`
}

func (*CredentialCreationOptions) GetAuthenticationID

func (options *CredentialCreationOptions) GetAuthenticationID() string

func (*CredentialCreationOptions) GetOptions

func (*CredentialCreationOptions) GetUserID

func (options *CredentialCreationOptions) GetUserID() []byte

func (*CredentialCreationOptions) IsCreationOptions

func (options *CredentialCreationOptions) IsCreationOptions() bool

type CredentialOptions

type CredentialOptions interface {
	GetUserID() []byte
	GetAuthenticationID() string
	IsCreationOptions() bool
	GetOptions() PublicKeyCredentialOptions
}

type CredentialRequestOptions

type CredentialRequestOptions struct {
	AuthenticationId string                            `json:"authenticationId"`
	Type             string                            `json:"type"`
	Options          PublicKeyCredentialRequestOptions `json:"publicKey"`
}

func (*CredentialRequestOptions) GetAuthenticationID

func (options *CredentialRequestOptions) GetAuthenticationID() string

func (*CredentialRequestOptions) GetOptions

func (*CredentialRequestOptions) GetUserID

func (options *CredentialRequestOptions) GetUserID() []byte

func (*CredentialRequestOptions) IsCreationOptions

func (options *CredentialRequestOptions) IsCreationOptions() bool

type CredentialResponse

type CredentialResponse interface {
	Validate(options CredentialOptions, credential *domain.Credential) error
}

type InitiateAuthenticationRequest

type InitiateAuthenticationRequest struct {
	// The unique identifier selected by the user
	//
	// Never print this value in plain text
	UserId string `json:"userId"`
}

Request object to initiate an authentication flow,

type PublicKey

type PublicKey interface {
	Algorithm() int
	Verify(signature []byte, value []byte) bool
}

type PublicKeyCredentialCreationOptions

type PublicKeyCredentialCreationOptions struct {
	Challenge                 []byte                          `json:"challenge"`
	RelyingParty              PublicKeyCredentialRpEntity     `json:"rp"`
	User                      PublicKeyCredentialUserEntity   `json:"user"`
	PublicKeyCredentialParams []PublicKeyCredentialParameters `json:"pubKeyCredParams"`
	AuthenticationSelection   AuthenticationSelection         `json:"authenticatorSelection"`
	Timeout                   uint64                          `json:"timeout"`
	Attestation               string                          `json:"attestation"`
	AttestationFormats        []string                        `json:"attestationFormats"`
}

func (*PublicKeyCredentialCreationOptions) ValidateAttestationObject

func (options *PublicKeyCredentialCreationOptions) ValidateAttestationObject(attestationObject attestationObject) error

func (*PublicKeyCredentialCreationOptions) ValidateAuthenticatorData

func (options *PublicKeyCredentialCreationOptions) ValidateAuthenticatorData(authenticatorData AuthData) error

func (*PublicKeyCredentialCreationOptions) ValidateClientData

func (options *PublicKeyCredentialCreationOptions) ValidateClientData(clientData clientData) error

type PublicKeyCredentialDescriptor

type PublicKeyCredentialDescriptor struct {
	Type       string   `json:"type"`
	ID         []byte   `json:"id"`
	Transports []string `json:"transports"`
}

type PublicKeyCredentialOptions

type PublicKeyCredentialOptions interface {
	ValidateClientData(clientData clientData) error
	ValidateAttestationObject(attestationObject attestationObject) error
	ValidateAuthenticatorData(authenticatorData AuthData) error
}

type PublicKeyCredentialParameters

type PublicKeyCredentialParameters struct {
	Type string `json:"type"`
	Alg  int    `json:"alg"`
}

type PublicKeyCredentialRequestOptions

type PublicKeyCredentialRequestOptions struct {
	UserId             []byte                          `json:"-"`
	Challenge          []byte                          `json:"challenge"`
	RpID               string                          `json:"rpId"`
	Timeout            uint64                          `json:"timeout"`
	UserVerification   string                          `json:"userVerification"`
	Attestation        string                          `json:"attestation"`
	AttestationFormats []string                        `json:"attestationFormats"`
	AllowCredentials   []PublicKeyCredentialDescriptor `json:"allowCredentials"`
}

func (*PublicKeyCredentialRequestOptions) ValidateAttestationObject

func (options *PublicKeyCredentialRequestOptions) ValidateAttestationObject(attestationObject attestationObject) error

func (*PublicKeyCredentialRequestOptions) ValidateAuthenticatorData

func (options *PublicKeyCredentialRequestOptions) ValidateAuthenticatorData(authenticatorData AuthData) error

func (*PublicKeyCredentialRequestOptions) ValidateClientData

func (options *PublicKeyCredentialRequestOptions) ValidateClientData(clientData clientData) error

type PublicKeyCredentialRpEntity

type PublicKeyCredentialRpEntity struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

type PublicKeyCredentialUserEntity

type PublicKeyCredentialUserEntity struct {
	Id          []byte `json:"id"`
	Name        string `json:"name"`
	DisplayName string `json:"displayName"`
}

type RawAttestationObject

type RawAttestationObject []byte

func (RawAttestationObject) Decode

func (attestation RawAttestationObject) Decode() (*attestationObject, error)

type RawClientDataJSON

type RawClientDataJSON []byte

type RawCreateCredentialResponse

type RawCreateCredentialResponse struct {
	ClientDataJSON    RawClientDataJSON    `json:"clientDataJSON"`
	AttestationObject RawAttestationObject `json:"attestationObject"`
}

type RawRequestCredentialResponse

type RawRequestCredentialResponse struct {
	ClientDataJSON    RawClientDataJSON `json:"clientDataJSON"`
	AuthenticatorData []byte            `json:"authenticatorData"`
	Signature         []byte            `json:"signature"`
	UserHandle        []byte            `json:"userHandle"`
}

type RequestCredentialRequest

type RequestCredentialRequest struct {
	AuthenticationID string                       `json:"authenticationId"`
	Id               string                       `json:"id"`
	RawID            []byte                       `json:"rawId"`
	Type             string                       `json:"type"`
	Response         RawRequestCredentialResponse `json:"response"`
}

type RequestCredentialResponse

type RequestCredentialResponse struct {
	ClientData        clientData
	AuthenticatorData AuthData
	Signature         []byte
	UserHandle        []byte
}

func (*RequestCredentialResponse) Validate

func (response *RequestCredentialResponse) Validate(options PublicKeyCredentialOptions, credential *domain.Credential) error

type Success

type Success struct {
	AccessToken  *domain.AccessToken  `json:"accessToken"`
	RefreshToken *domain.RefreshToken `json:"refreshToken"`
}

Jump to

Keyboard shortcuts

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