Documentation ¶
Index ¶
- Variables
- func AssembleUncompressedECPoint(xCoord []byte, yCoord []byte) ([]byte, error)
- func CreateChallenge(len int) ([]byte, error)
- func CreateCredential(c *Credential) error
- func DeleteCredentialByID(credentialID string) error
- func FormatPublicKey(pk PublicKey) (ecdsa.PublicKey, error)
- func GetPublicKeyForCredential(c *Credential) (ecdsa.PublicKey, error)
- func PutRelyingParty(rp *RelyingParty) error
- func PutSession(sd *SessionData) error
- func PutUser(u *User) error
- func Setup() error
- func UpdateCredential(c *Credential) error
- type Credential
- func GetCredentialForUser(user *User, credentialID string) (Credential, error)
- func GetCredentialForUserAndRelyingParty(user *User, rp *RelyingParty) (Credential, error)
- func GetCredentialsForUser(user *User) ([]Credential, error)
- func GetCredentialsForUserAndRelyingParty(user *User, rp *RelyingParty) ([]Credential, error)
- type PublicKey
- type RelyingParty
- type SessionData
- func CreateNewSession(u *User, rp *RelyingParty, st string) (SessionData, error)
- func GetSessionData(id int64) (SessionData, error)
- func GetSessionForRequest(r *http.Request, store *sessions.CookieStore) (SessionData, error)
- func GetSessionsByUsernameAndRelyingParty(uid int64, rpid string) (SessionData, error)
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSessionType = errors.New("SessionType needs to be 'reg' or 'att'")
ErrInvalidSessionType is thrown when an invalid session type is created
var ErrUsernameTaken = errors.New("username already taken")
ErrUsernameTaken is thrown when a user attempts to register a username that is taken.
Logger is a global logger used to show informational, warning, and error messages
Functions ¶
func AssembleUncompressedECPoint ¶
AssembleUncompressedECPoint will properly format the EC coordinates into
func CreateChallenge ¶
CreateChallenge - Create a new challenge to be sent to the authenticator
func CreateCredential ¶
func CreateCredential(c *Credential) error
CreateCredential creates a new credential object
func DeleteCredentialByID ¶
DeleteCredentialByID gets a credential by its ID. In practice, this would be a bad function without some other checks (like what user is logged in) because someone could hypothetically delete ANY credential.
func FormatPublicKey ¶
FormatPublicKey formats a `models.PublicKey` into an `ecdsa.PublicKey`
func GetPublicKeyForCredential ¶
func GetPublicKeyForCredential(c *Credential) (ecdsa.PublicKey, error)
GetPublicKeyForCredential gets the formatted `models.PublicKey` for a provided credential
func PutRelyingParty ¶
func PutRelyingParty(rp *RelyingParty) error
PutRelyingParty creates or updates a Relying Party
func Setup ¶
func Setup() error
Setup initializes the Conn object It also populates the Config object
func UpdateCredential ¶
func UpdateCredential(c *Credential) error
UpdateCredential updates the credential with new attributes.
Types ¶
type Credential ¶
type Credential struct { ID int64 `json:"id"` CreatedAt time.Time Counter []byte `json:"sign_count"` RelyingParty RelyingParty `json:"rp" storm:"inline"` RelyingPartyID string `json:"rp_id"` User User `json:"user" storm:"inline"` UserID int64 `json:"user_id"` Type string `json:"type,omitempty"` Format string `json:"format,omitempty"` Flags []byte `json:"flags,omitempty"` CredID string `json:"credential_id,omitempty"` PublicKey PublicKey `json:"public_key,omitempty" storm:"inline"` }
Credential is the stored credential for Auth
func GetCredentialForUser ¶
func GetCredentialForUser(user *User, credentialID string) (Credential, error)
GetCredentialForUser retrieves a specific credential for a user.
func GetCredentialForUserAndRelyingParty ¶
func GetCredentialForUserAndRelyingParty(user *User, rp *RelyingParty) (Credential, error)
GetCredentialForUserAndRelyingParty retrieves the first credential for a provided user and relying party.
func GetCredentialsForUser ¶
func GetCredentialsForUser(user *User) ([]Credential, error)
GetCredentialsForUser retrieves all credentials for a provided user regardless of relying party.
func GetCredentialsForUserAndRelyingParty ¶
func GetCredentialsForUserAndRelyingParty(user *User, rp *RelyingParty) ([]Credential, error)
GetCredentialsForUserAndRelyingParty retrieves all credentials for a provided user for a relying party.
type PublicKey ¶
type PublicKey struct { KeyType int8 `codec:"1"` Type int8 `codec:"3"` XCoord []byte `codec:"-2"` YCoord []byte `codec:"-3"` Curve int8 `codec:"-1"` CredentialID int64 `codec:"-,omitempty"` // contains filtered or unexported fields }
PublicKey is parsed from the credential creation response
func GetUnformattedPublicKeyForCredential ¶
func GetUnformattedPublicKeyForCredential(c *Credential) (PublicKey, error)
GetUnformattedPublicKeyForCredential gives you the raw PublicKey model for a credential
type RelyingParty ¶
type RelyingParty struct { ID string `json:"id" storm:"id"` DisplayName string `json:"display_name"` Icon string `json:"icon,omitempty"` Users []User `json:"users,omitempty" storm:"unique"` }
RelyingParty is the group the User is authenticating with
func GetDefaultRelyingParty ¶
func GetDefaultRelyingParty() (RelyingParty, error)
GetDefaultRelyingParty gets the RP associated with the configured hostname
func GetRelyingPartyByHost ¶
func GetRelyingPartyByHost(hostname string) (RelyingParty, error)
GetRelyingPartyByHost gets the RP by hostname which in this case is the ID
type SessionData ¶
type SessionData struct { ID int64 `json:"id" storm:"id,increment"` Challenge []byte `json:"challenge"` Origin string `json:"origin"` SessionType string `json:"session_type"` User User `json:"user"` UserID int64 `json:"user_id"` RelyingParty RelyingParty `json:"rp"` RelyingPartyID string `json:"rp_id"` }
SessionData is the Model
func CreateNewSession ¶
func CreateNewSession(u *User, rp *RelyingParty, st string) (SessionData, error)
CreateNewSession - Create new user/rp session
func GetSessionData ¶
func GetSessionData(id int64) (SessionData, error)
GetSessionData returns the SessionData that the given id corresponds to. If no user is found, an error is thrown.
func GetSessionForRequest ¶
func GetSessionForRequest(r *http.Request, store *sessions.CookieStore) (SessionData, error)
GetSessionForRequest gets the stored session data for a provided request.
func GetSessionsByUsernameAndRelyingParty ¶
func GetSessionsByUsernameAndRelyingParty(uid int64, rpid string) (SessionData, error)
GetSessionsByUsernameAndRelyingParty - Get the last recorded SessionData for a user/rp
type User ¶
type User struct { ID int64 `json:"id" storm:"id,increment"` Name string `json:"name"` DisplayName string `json:"display_name"` Icon string `json:"icon,omitempty"` Credentials []Credential `json:"credentials,omitempty"` RelyingParties []RelyingParty }
User represents the user model.
func GetSessionByUsername ¶
GetSessionByUsername returns the user that the given username corresponds to. If no user is found, an error is thrown.
func GetUser ¶
GetUser returns the user that the given id corresponds to. If no user is found, an error is thrown.
func GetUserByUsername ¶
GetUserByUsername returns the user that the given username corresponds to. If no user is found, an error is thrown.