mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 08:02:36 +09:00 
			
		
		
		
	In the Gitea GUI, the user can see the time that _AccessTokens_ and
_PublicKeys_ were last used. This information is not returned by the
_/users/{username}/tokens_ and _/user/keys_ endpoints in the API. This
PR adds the missing data.
The time of last usage for for _tokens_ & _keys_ seem to be stored in
the _Updated_ field of the structs internally. For consistency, I have
used the name _updated_at_ for the new field returned by the _API_.
However, for the _API_ user, I don't think that name reflects the data
returned, as I believe it is the time of last usage. I propose that we
use the name _last_used_at_ instead. Let's hear reviewers opinion on
that.
* PublicKey
  1. _last_used_at_: string($date-time)
* AccessToken
  1. _created_at_: string($date-time) (for parity with public keys)
  2. _last_used_at_: string($date-time)
Fix #34313
		
	
		
			
				
	
	
		
			60 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// Copyright 2014 The Gogs Authors. All rights reserved.
 | 
						|
// Copyright 2019 The Gitea Authors. All rights reserved.
 | 
						|
// SPDX-License-Identifier: MIT
 | 
						|
 | 
						|
package structs
 | 
						|
 | 
						|
import (
 | 
						|
	"time"
 | 
						|
)
 | 
						|
 | 
						|
// AccessToken represents an API access token.
 | 
						|
// swagger:response AccessToken
 | 
						|
type AccessToken struct {
 | 
						|
	ID             int64     `json:"id"`
 | 
						|
	Name           string    `json:"name"`
 | 
						|
	Token          string    `json:"sha1"`
 | 
						|
	TokenLastEight string    `json:"token_last_eight"`
 | 
						|
	Scopes         []string  `json:"scopes"`
 | 
						|
	Created        time.Time `json:"created_at"`
 | 
						|
	Updated        time.Time `json:"last_used_at"`
 | 
						|
}
 | 
						|
 | 
						|
// AccessTokenList represents a list of API access token.
 | 
						|
// swagger:response AccessTokenList
 | 
						|
type AccessTokenList []*AccessToken
 | 
						|
 | 
						|
// CreateAccessTokenOption options when create access token
 | 
						|
// swagger:model CreateAccessTokenOption
 | 
						|
type CreateAccessTokenOption struct {
 | 
						|
	// required: true
 | 
						|
	Name string `json:"name" binding:"Required"`
 | 
						|
	// example: ["all", "read:activitypub","read:issue", "write:misc", "read:notification", "read:organization", "read:package", "read:repository", "read:user"]
 | 
						|
	Scopes []string `json:"scopes"`
 | 
						|
}
 | 
						|
 | 
						|
// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
 | 
						|
type CreateOAuth2ApplicationOptions struct {
 | 
						|
	Name                       string   `json:"name" binding:"Required"`
 | 
						|
	ConfidentialClient         bool     `json:"confidential_client"`
 | 
						|
	SkipSecondaryAuthorization bool     `json:"skip_secondary_authorization"`
 | 
						|
	RedirectURIs               []string `json:"redirect_uris" binding:"Required"`
 | 
						|
}
 | 
						|
 | 
						|
// OAuth2Application represents an OAuth2 application.
 | 
						|
// swagger:response OAuth2Application
 | 
						|
type OAuth2Application struct {
 | 
						|
	ID                         int64     `json:"id"`
 | 
						|
	Name                       string    `json:"name"`
 | 
						|
	ClientID                   string    `json:"client_id"`
 | 
						|
	ClientSecret               string    `json:"client_secret"`
 | 
						|
	ConfidentialClient         bool      `json:"confidential_client"`
 | 
						|
	SkipSecondaryAuthorization bool      `json:"skip_secondary_authorization"`
 | 
						|
	RedirectURIs               []string  `json:"redirect_uris"`
 | 
						|
	Created                    time.Time `json:"created"`
 | 
						|
}
 | 
						|
 | 
						|
// OAuth2ApplicationList represents a list of OAuth2 applications.
 | 
						|
// swagger:response OAuth2ApplicationList
 | 
						|
type OAuth2ApplicationList []*OAuth2Application
 |