Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

user_app.go 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package structs
  6. import (
  7. "encoding/base64"
  8. "time"
  9. )
  10. // BasicAuthEncode generate base64 of basic auth head
  11. func BasicAuthEncode(user, pass string) string {
  12. return base64.StdEncoding.EncodeToString([]byte(user + ":" + pass))
  13. }
  14. // AccessToken represents an API access token.
  15. // swagger:response AccessToken
  16. type AccessToken struct {
  17. ID int64 `json:"id"`
  18. Name string `json:"name"`
  19. Token string `json:"sha1"`
  20. TokenLastEight string `json:"token_last_eight"`
  21. }
  22. // AccessTokenList represents a list of API access token.
  23. // swagger:response AccessTokenList
  24. type AccessTokenList []*AccessToken
  25. // CreateAccessTokenOption options when create access token
  26. // swagger:parameters userCreateToken
  27. type CreateAccessTokenOption struct {
  28. Name string `json:"name" binding:"Required"`
  29. }
  30. // CreateOAuth2ApplicationOptions holds options to create an oauth2 application
  31. type CreateOAuth2ApplicationOptions struct {
  32. Name string `json:"name" binding:"Required"`
  33. RedirectURIs []string `json:"redirect_uris" binding:"Required"`
  34. }
  35. // OAuth2Application represents an OAuth2 application.
  36. // swagger:response OAuth2Application
  37. type OAuth2Application struct {
  38. ID int64 `json:"id"`
  39. Name string `json:"name"`
  40. ClientID string `json:"client_id"`
  41. ClientSecret string `json:"client_secret"`
  42. RedirectURIs []string `json:"redirect_uris"`
  43. Created time.Time `json:"created"`
  44. }
  45. // OAuth2ApplicationList represents a list of OAuth2 applications.
  46. // swagger:response OAuth2ApplicationList
  47. type OAuth2ApplicationList []*OAuth2Application