oauth.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package admin
  2. import (
  3. "github.com/lejianwen/rustdesk-api/v2/model"
  4. )
  5. type BindOauthForm struct {
  6. Op string `json:"op" binding:"required"`
  7. }
  8. type OauthConfirmForm struct {
  9. Code string `json:"code" binding:"required"`
  10. }
  11. type UnBindOauthForm struct {
  12. Op string `json:"op" binding:"required"`
  13. }
  14. type OauthForm struct {
  15. Id uint `json:"id"`
  16. Op string `json:"op" validate:"omitempty"`
  17. OauthType string `json:"oauth_type" validate:"required"`
  18. Issuer string `json:"issuer" validate:"omitempty,url"`
  19. Scopes string `json:"scopes" validate:"omitempty"`
  20. ClientId string `json:"client_id" validate:"required"`
  21. ClientSecret string `json:"client_secret" validate:"required"`
  22. RedirectUrl string `json:"redirect_url" validate:"required"`
  23. AutoRegister *bool `json:"auto_register"`
  24. }
  25. func (of *OauthForm) ToOauth() *model.Oauth {
  26. oa := &model.Oauth{
  27. Op: of.Op,
  28. OauthType: of.OauthType,
  29. ClientId: of.ClientId,
  30. ClientSecret: of.ClientSecret,
  31. RedirectUrl: of.RedirectUrl,
  32. AutoRegister: of.AutoRegister,
  33. Issuer: of.Issuer,
  34. Scopes: of.Scopes,
  35. }
  36. oa.Id = of.Id
  37. return oa
  38. }