progress
server is launchable and passkey support works
This commit is contained in:
parent
ee172d84a8
commit
c572066571
21 changed files with 857 additions and 40 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/go-webauthn/webauthn/webauthn"
|
||||
"github.com/google/uuid"
|
||||
"github.com/mstarongithub/passkey"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/linstrom/ap"
|
||||
|
@ -197,12 +198,15 @@ func (s *Storage) NewEmptyAccount() (*Account, error) {
|
|||
log.Debug().Msg("Creating new empty account")
|
||||
acc := Account{}
|
||||
// Generate the 64 bit id for passkey and webauthn stuff
|
||||
log.Debug().Msg("Creating webauthn id for new account")
|
||||
data := make([]byte, 64)
|
||||
c, err := rand.Read(data)
|
||||
for err != nil || c != len(data) || c < 64 {
|
||||
data = make([]byte, 64)
|
||||
c, err = rand.Read(data)
|
||||
}
|
||||
log.Debug().Msg("Random webauthn id for new account created")
|
||||
acc.ID = uuid.NewString()
|
||||
acc.WebAuthnId = data
|
||||
acc.Followers = []string{}
|
||||
acc.Tags = []string{}
|
||||
|
@ -211,7 +215,8 @@ func (s *Storage) NewEmptyAccount() (*Account, error) {
|
|||
acc.CustomFields = []uint{}
|
||||
acc.IdentifiesAs = []Being{}
|
||||
acc.PasskeyCredentials = []webauthn.Credential{}
|
||||
res := s.db.Save(acc)
|
||||
log.Debug().Any("account", &acc).Msg("Saving new account in db")
|
||||
res := s.db.Save(&acc)
|
||||
if res.Error != nil {
|
||||
log.Error().Err(res.Error).Msg("Failed to safe new account")
|
||||
return nil, res.Error
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue