oauth.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. AutoRegister *bool `json:"auto_register"`
  23. PkceEnable *bool `json:"pkce_enable"`
  24. PkceMethod string `json:"pkce_method"`
  25. }
  26. func (of *OauthForm) ToOauth() *model.Oauth {
  27. oa := &model.Oauth{
  28. Op: of.Op,
  29. OauthType: of.OauthType,
  30. ClientId: of.ClientId,
  31. ClientSecret: of.ClientSecret,
  32. AutoRegister: of.AutoRegister,
  33. Issuer: of.Issuer,
  34. Scopes: of.Scopes,
  35. PkceEnable: of.PkceEnable,
  36. PkceMethod: of.PkceMethod,
  37. }
  38. oa.Id = of.Id
  39. return oa
  40. }