feat: add support for Postgres database provider (#79)

This commit is contained in:
Elias Schneider
2024-12-12 17:21:28 +01:00
committed by GitHub
parent e9d83dd6c3
commit 9d20a98dbb
38 changed files with 433 additions and 81 deletions

View File

@@ -2,6 +2,7 @@ package datatype
import (
"database/sql/driver"
"github.com/stonith404/pocket-id/backend/internal/common"
"time"
)
@@ -14,7 +15,11 @@ func (date *DateTime) Scan(value interface{}) (err error) {
}
func (date DateTime) Value() (driver.Value, error) {
return time.Time(date).Unix(), nil
if common.EnvConfig.DbProvider == common.DbProviderSqlite {
return time.Time(date).Unix(), nil
} else {
return time.Time(date), nil
}
}
func (date DateTime) UTC() time.Time {

View File

@@ -33,7 +33,7 @@ func (u User) WebAuthnCredentials() []webauthn.Credential {
for i, credential := range u.Credentials {
credentials[i] = webauthn.Credential{
ID: []byte(credential.CredentialID),
ID: credential.CredentialID,
AttestationType: credential.AttestationType,
PublicKey: credential.PublicKey,
Transport: credential.Transport,

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"github.com/go-webauthn/webauthn/protocol"
datatype "github.com/stonith404/pocket-id/backend/internal/model/types"
"time"
)
@@ -12,7 +13,7 @@ type WebauthnSession struct {
Base
Challenge string
ExpiresAt time.Time
ExpiresAt datatype.DateTime
UserVerification string
}
@@ -20,7 +21,7 @@ type WebauthnCredential struct {
Base
Name string
CredentialID string
CredentialID []byte
PublicKey []byte
AttestationType string
Transport AuthenticatorTransportList