src

package
v0.0.0-...-c11cde9 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserNotFound = echo.NewHTTPError(http.StatusNotFound, "user not found")
View Source
var Sessions = map[string]*webauthn.SessionData{}
View Source
var Users = map[string]*User{}

Functions

func GetSession

func GetSession(id string) (*webauthn.SessionData, error)

func InsertSession

func InsertSession(id string, session *webauthn.SessionData)

func InsertUser

func InsertUser(id string, user *User)

func Main

func Main()

func RandomString

func RandomString(n int) string

Types

type Handler

type Handler struct {
	WebAuthn *webauthn.WebAuthn
}

func (*Handler) BeginCreateHandler

func (h *Handler) BeginCreateHandler(c echo.Context) error

WebAuthnを新規に登録するためのチャレンジを返す。 ユーザーとセッションはDBに保存し、クッキーにセッションIDを保存している。

func (*Handler) BeginLoginHandler

func (h *Handler) BeginLoginHandler(c echo.Context) error

ログイン用のチャレンジを返す ログインページで毎回生成する。 セッションはDBに保存して、IDをクッキーに保存している。

func (*Handler) CreateHandler

func (h *Handler) CreateHandler(c echo.Context) error

WebAuthのクレデンシャルを検証して成功の場合は、新規にクレデンシャルを登録する。 CookieからセッションIDを取得し、DBからユーザーとセッションを取得する。

func (*Handler) DebugDatabase

func (h *Handler) DebugDatabase(c echo.Context) error

func (*Handler) LoginHandler

func (h *Handler) LoginHandler(c echo.Context) error

type User

type User struct {
	ID          []byte `json:"id"`
	Name        string `json:"name"`
	DisplayName string `json:"display_name,omitempty"`

	Credentials []webauthn.Credential `json:"-"`
}

func GetUser

func GetUser(name string) (*User, error)

func GetUserById

func GetUserById(id []byte) (*User, error)

func (*User) WebAuthnCredentials

func (u *User) WebAuthnCredentials() []webauthn.Credential

func (*User) WebAuthnDisplayName

func (u *User) WebAuthnDisplayName() string

func (*User) WebAuthnID

func (u *User) WebAuthnID() []byte

func (*User) WebAuthnIcon

func (u *User) WebAuthnIcon() string

func (*User) WebAuthnName

func (u *User) WebAuthnName() string

Jump to

Keyboard shortcuts

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