An atproto PDS written in Go
103
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v0.7.2 83 lines 2.3 kB view raw
1package provider 2 3import ( 4 "database/sql/driver" 5 "encoding/json" 6 "fmt" 7 "time" 8 9 "gorm.io/gorm" 10) 11 12type ClientAuth struct { 13 Method string 14 Alg string 15 Kid string 16 Jkt string 17 Jti string 18 Exp *float64 19} 20 21func (ca *ClientAuth) Scan(value any) error { 22 b, ok := value.([]byte) 23 if !ok { 24 return fmt.Errorf("failed to unmarshal OauthParRequest value") 25 } 26 return json.Unmarshal(b, ca) 27} 28 29func (ca ClientAuth) Value() (driver.Value, error) { 30 return json.Marshal(ca) 31} 32 33type ParRequest struct { 34 AuthenticateClientRequestBase 35 ResponseType string `form:"response_type" json:"response_type" validate:"required"` 36 CodeChallenge *string `form:"code_challenge" json:"code_challenge" validate:"required"` 37 CodeChallengeMethod string `form:"code_challenge_method" json:"code_challenge_method" validate:"required"` 38 State string `form:"state" json:"state" validate:"required"` 39 RedirectURI string `form:"redirect_uri" json:"redirect_uri" validate:"required"` 40 Scope string `form:"scope" json:"scope" validate:"required"` 41 LoginHint *string `form:"login_hint" json:"login_hint,omitempty"` 42 DpopJkt *string `form:"dpop_jkt" json:"dpop_jkt,omitempty"` 43} 44 45func (opr *ParRequest) Scan(value any) error { 46 b, ok := value.([]byte) 47 if !ok { 48 return fmt.Errorf("failed to unmarshal OauthParRequest value") 49 } 50 return json.Unmarshal(b, opr) 51} 52 53func (opr ParRequest) Value() (driver.Value, error) { 54 return json.Marshal(opr) 55} 56 57type OauthToken struct { 58 gorm.Model 59 ClientId string `gorm:"index"` 60 ClientAuth ClientAuth `gorm:"type:json"` 61 Parameters ParRequest `gorm:"type:json"` 62 ExpiresAt time.Time `gorm:"index"` 63 DeviceId string 64 Sub string `gorm:"index"` 65 Code string `gorm:"index"` 66 Token string `gorm:"uniqueIndex"` 67 RefreshToken string `gorm:"uniqueIndex"` 68 Ip string 69} 70 71type OauthAuthorizationRequest struct { 72 gorm.Model 73 RequestId string `gorm:"primaryKey"` 74 ClientId string `gorm:"index"` 75 ClientAuth ClientAuth `gorm:"type:json"` 76 Parameters ParRequest `gorm:"type:json"` 77 ExpiresAt time.Time `gorm:"index"` 78 DeviceId *string 79 Sub *string 80 Code *string 81 Accepted *bool 82 Ip string 83}