gitea源码

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2019 The Gitea Authors. All rights reserved.
  3. // SPDX-License-Identifier: MIT
  4. package structs
  5. import (
  6. "time"
  7. )
  8. // AccessToken represents an API access token.
  9. // swagger:response AccessToken
  10. type AccessToken struct {
  11. // The unique identifier of the access token
  12. ID int64 `json:"id"`
  13. // The name of the access token
  14. Name string `json:"name"`
  15. // The SHA1 hash of the access token
  16. Token string `json:"sha1"`
  17. // The last eight characters of the token
  18. TokenLastEight string `json:"token_last_eight"`
  19. // The scopes granted to this access token
  20. Scopes []string `json:"scopes"`
  21. // The timestamp when the token was created
  22. Created time.Time `json:"created_at"`
  23. // The timestamp when the token was last used
  24. Updated time.Time `json:"last_used_at"`
  25. }
  26. // AccessTokenList represents a list of API access token.
  27. // swagger:response AccessTokenList
  28. type AccessTokenList []*AccessToken
  29. // CreateAccessTokenOption options when create access token
  30. // swagger:model CreateAccessTokenOption
  31. type CreateAccessTokenOption struct {
  32. // required: true
  33. Name string `json:"name" binding:"Required"`
  34. // example: ["all", "read:activitypub","read:issue", "write:misc", "read:notification", "read:organization", "read:package", "read:repository", "read:user"]
  35. Scopes []string `json:"scopes"`
  36. }
  37. // CreateOAuth2ApplicationOptions holds options to create an oauth2 application
  38. type CreateOAuth2ApplicationOptions struct {
  39. // The name of the OAuth2 application
  40. Name string `json:"name" binding:"Required"`
  41. // Whether the client is confidential
  42. ConfidentialClient bool `json:"confidential_client"`
  43. // Whether to skip secondary authorization
  44. SkipSecondaryAuthorization bool `json:"skip_secondary_authorization"`
  45. // The list of allowed redirect URIs
  46. RedirectURIs []string `json:"redirect_uris" binding:"Required"`
  47. }
  48. // OAuth2Application represents an OAuth2 application.
  49. // swagger:response OAuth2Application
  50. type OAuth2Application struct {
  51. // The unique identifier of the OAuth2 application
  52. ID int64 `json:"id"`
  53. // The name of the OAuth2 application
  54. Name string `json:"name"`
  55. // The client ID of the OAuth2 application
  56. ClientID string `json:"client_id"`
  57. // The client secret of the OAuth2 application
  58. ClientSecret string `json:"client_secret"`
  59. // Whether the client is confidential
  60. ConfidentialClient bool `json:"confidential_client"`
  61. // Whether to skip secondary authorization
  62. SkipSecondaryAuthorization bool `json:"skip_secondary_authorization"`
  63. // The list of allowed redirect URIs
  64. RedirectURIs []string `json:"redirect_uris"`
  65. // The timestamp when the application was created
  66. Created time.Time `json:"created"`
  67. }
  68. // OAuth2ApplicationList represents a list of OAuth2 applications.
  69. // swagger:response OAuth2ApplicationList
  70. type OAuth2ApplicationList []*OAuth2Application