oauth.go 1.3 KB

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