diff --git a/internal/api/client/auth/token.go b/internal/api/client/auth/token.go index 798a88d19..7e590aa1f 100644 --- a/internal/api/client/auth/token.go +++ b/internal/api/client/auth/token.go @@ -31,6 +31,7 @@ type tokenBody struct { Code *string `form:"code" json:"code" xml:"code"` GrantType *string `form:"grant_type" json:"grant_type" xml:"grant_type"` RedirectURI *string `form:"redirect_uri" json:"redirect_uri" xml:"redirect_uri"` + Scope *string `form:"scope" json:"scope" xml:"scope"` } // TokenPOSTHandler should be served as a POST at https://example.org/oauth/token @@ -58,6 +59,9 @@ func (m *Module) TokenPOSTHandler(c *gin.Context) { if form.RedirectURI != nil { c.Request.Form.Set("redirect_uri", *form.RedirectURI) } + if form.Scope != nil { + c.Request.Form.Set("scope", *form.Scope) + } } if err := m.server.HandleTokenRequest(c.Writer, c.Request); err != nil { diff --git a/internal/gtsmodel/token.go b/internal/gtsmodel/token.go index 5fa96e915..8058d9edf 100644 --- a/internal/gtsmodel/token.go +++ b/internal/gtsmodel/token.go @@ -26,7 +26,7 @@ type Token struct { CreatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item created UpdatedAt time.Time `validate:"-" bun:"type:timestamp,nullzero,notnull,default:current_timestamp"` // when was item last updated ClientID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // ID of the client who owns this token - UserID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"` // ID of the user who owns this token + UserID string `validate:"required,ulid" bun:"type:CHAR(26),nullzero"` // ID of the user who owns this token RedirectURI string `validate:"required,uri" bun:",nullzero,notnull"` // Oauth redirect URI for this token Scope string `validate:"required" bun:",nullzero,notnull"` // Oauth scope Code string `validate:"-" bun:",pk,nullzero,notnull,default:''"` // Code, if present diff --git a/internal/gtsmodel/user.go b/internal/gtsmodel/user.go index 28156cfdd..b49a8b28b 100644 --- a/internal/gtsmodel/user.go +++ b/internal/gtsmodel/user.go @@ -38,7 +38,7 @@ type User struct { CurrentSignInIP net.IP `validate:"-" bun:",nullzero"` // What's the most recent IP of this user LastSignInAt time.Time `validate:"-" bun:"type:timestamp,nullzero"` // When did this user last sign in? LastSignInIP net.IP `validate:"-" bun:",nullzero"` // What's the previous IP of this user? - SignInCount int `validate:"min=0" bun:",nullzero,notnull,default:0"` // How many times has this user signed in? + SignInCount int `validate:"min=0" bun:",notnull,default:0"` // How many times has this user signed in? InviteID string `validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"` // id of the user who invited this user (who let this joker in?) ChosenLanguages []string `validate:"-" bun:",nullzero"` // What languages does this user want to see? FilteredLanguages []string `validate:"-" bun:",nullzero"` // What languages does this user not want to see?