diff options
Diffstat (limited to 'modules/auth/user_form.go')
-rw-r--r-- | modules/auth/user_form.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/modules/auth/user_form.go b/modules/auth/user_form.go index 3a4df8ea7d..be0f9bf1bf 100644 --- a/modules/auth/user_form.go +++ b/modules/auth/user_form.go @@ -137,6 +137,54 @@ func (f *SignInForm) Validate(ctx *macaron.Context, errs binding.Errors) binding return validate(errs, ctx.Data, f, ctx.Locale) } +// AuthorizationForm form for authorizing oauth2 clients +type AuthorizationForm struct { + ResponseType string `binding:"Required;In(code)"` + ClientID string `binding:"Required"` + RedirectURI string + State string + + // PKCE support + CodeChallengeMethod string // S256, plain + CodeChallenge string +} + +// Validate valideates the fields +func (f *AuthorizationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} + +// GrantApplicationForm form for authorizing oauth2 clients +type GrantApplicationForm struct { + ClientID string `binding:"Required"` + RedirectURI string + State string +} + +// Validate valideates the fields +func (f *GrantApplicationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} + +// AccessTokenForm for issuing access tokens from authorization codes or refresh tokens +type AccessTokenForm struct { + GrantType string + ClientID string + ClientSecret string + RedirectURI string + // TODO Specify authentication code length to prevent against birthday attacks + Code string + RefreshToken string + + // PKCE support + CodeVerifier string +} + +// Validate valideates the fields +func (f *AccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} + // __________________________________________.___ _______ ________ _________ // / _____/\_ _____/\__ ___/\__ ___/| |\ \ / _____/ / _____/ // \_____ \ | __)_ | | | | | |/ | \/ \ ___ \_____ \ @@ -258,6 +306,17 @@ func (f *NewAccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) return validate(errs, ctx.Data, f, ctx.Locale) } +// EditOAuth2ApplicationForm form for editing oauth2 applications +type EditOAuth2ApplicationForm struct { + Name string `binding:"Required;MaxSize(255)" form:"application_name"` + RedirectURI string `binding:"Required" form:"redirect_uri"` +} + +// Validate valideates the fields +func (f *EditOAuth2ApplicationForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} + // TwoFactorAuthForm for logging in with 2FA token. type TwoFactorAuthForm struct { Passcode string `binding:"Required"` |