diff options
author | Anthony Wang | 2023-03-04 00:03:38 +0000 |
---|---|---|
committer | Anthony Wang | 2023-03-04 00:03:38 +0000 |
commit | b4640101f3c8938ed689743606a79601201141ca (patch) | |
tree | 8469fc5ef817560db646837b41417d50e2f8ebfc /modules | |
parent | dc20c2832871f6462990751ea802e14b02bf41b0 (diff) | |
parent | 8540fc45b11eff9a73753ca139f8ea5c38509bf5 (diff) |
Merge remote-tracking branch 'origin/main' into forgejo-federation
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/password/hash/pbkdf2.go | 2 | ||||
-rw-r--r-- | modules/avatar/hash.go | 3 | ||||
-rw-r--r-- | modules/avatar/identicon/identicon.go | 3 | ||||
-rw-r--r-- | modules/base/tool.go | 2 | ||||
-rw-r--r-- | modules/context/access_log.go | 2 | ||||
-rw-r--r-- | modules/context/context.go | 2 | ||||
-rw-r--r-- | modules/git/commit.go | 2 | ||||
-rw-r--r-- | modules/git/last_commit_cache.go | 3 | ||||
-rw-r--r-- | modules/lfs/content_store.go | 3 | ||||
-rw-r--r-- | modules/lfs/pointer.go | 3 | ||||
-rw-r--r-- | modules/repository/commits_test.go | 2 | ||||
-rw-r--r-- | modules/repository/init.go | 5 | ||||
-rw-r--r-- | modules/secret/secret.go | 3 | ||||
-rw-r--r-- | modules/setting/config_provider.go | 4 | ||||
-rw-r--r-- | modules/setting/indexer.go | 13 | ||||
-rw-r--r-- | modules/setting/lfs.go | 5 | ||||
-rw-r--r-- | modules/setting/mailer.go | 29 | ||||
-rw-r--r-- | modules/setting/mirror.go | 5 | ||||
-rw-r--r-- | modules/setting/server.go | 18 | ||||
-rw-r--r-- | modules/setting/task.go | 9 | ||||
-rw-r--r-- | modules/structs/user_app.go | 14 | ||||
-rw-r--r-- | modules/templates/helper.go | 5 | ||||
-rw-r--r-- | modules/util/keypair_test.go | 2 |
23 files changed, 73 insertions, 66 deletions
diff --git a/modules/auth/password/hash/pbkdf2.go b/modules/auth/password/hash/pbkdf2.go index 27382fedb..9ff6d162f 100644 --- a/modules/auth/password/hash/pbkdf2.go +++ b/modules/auth/password/hash/pbkdf2.go @@ -4,12 +4,12 @@ package hash import ( - "crypto/sha256" "encoding/hex" "strings" "code.gitea.io/gitea/modules/log" + "github.com/minio/sha256-simd" "golang.org/x/crypto/pbkdf2" ) diff --git a/modules/avatar/hash.go b/modules/avatar/hash.go index 50db9c194..4fc28a773 100644 --- a/modules/avatar/hash.go +++ b/modules/avatar/hash.go @@ -4,9 +4,10 @@ package avatar import ( - "crypto/sha256" "encoding/hex" "strconv" + + "github.com/minio/sha256-simd" ) // HashAvatar will generate a unique string, which ensures that when there's a diff --git a/modules/avatar/identicon/identicon.go b/modules/avatar/identicon/identicon.go index 63926d5f1..9b7a2faf0 100644 --- a/modules/avatar/identicon/identicon.go +++ b/modules/avatar/identicon/identicon.go @@ -7,10 +7,11 @@ package identicon import ( - "crypto/sha256" "fmt" "image" "image/color" + + "github.com/minio/sha256-simd" ) const minImageSize = 16 diff --git a/modules/base/tool.go b/modules/base/tool.go index 994e58ac3..94f19576b 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -6,7 +6,6 @@ package base import ( "crypto/md5" "crypto/sha1" - "crypto/sha256" "encoding/base64" "encoding/hex" "errors" @@ -26,6 +25,7 @@ import ( "code.gitea.io/gitea/modules/util" "github.com/dustin/go-humanize" + "github.com/minio/sha256-simd" ) // EncodeMD5 encodes string to md5 hex value. diff --git a/modules/context/access_log.go b/modules/context/access_log.go index 84663ee8d..1aaba9dc2 100644 --- a/modules/context/access_log.go +++ b/modules/context/access_log.go @@ -6,8 +6,8 @@ package context import ( "bytes" "context" - "html/template" "net/http" + "text/template" "time" "code.gitea.io/gitea/modules/log" diff --git a/modules/context/context.go b/modules/context/context.go index a2088217f..0c8d7411e 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -6,7 +6,6 @@ package context import ( "context" - "crypto/sha256" "encoding/hex" "errors" "fmt" @@ -40,6 +39,7 @@ import ( "gitea.com/go-chi/cache" "gitea.com/go-chi/session" chi "github.com/go-chi/chi/v5" + "github.com/minio/sha256-simd" "github.com/unrolled/render" "golang.org/x/crypto/pbkdf2" ) diff --git a/modules/git/commit.go b/modules/git/commit.go index 1f6289ed0..4a55645d3 100644 --- a/modules/git/commit.go +++ b/modules/git/commit.go @@ -131,7 +131,7 @@ func CommitChangesWithArgs(repoPath string, args TrustedCmdArgs, opts CommitChan if opts.Author != nil { cmd.AddOptionFormat("--author='%s <%s>'", opts.Author.Name, opts.Author.Email) } - cmd.AddOptionValues("-m", opts.Message) + cmd.AddOptionFormat("--message=%s", opts.Message) _, _, err := cmd.RunStdString(&RunOpts{Dir: repoPath}) // No stderr but exit status 1 means nothing to commit. diff --git a/modules/git/last_commit_cache.go b/modules/git/last_commit_cache.go index ec8f1cce6..984561b2c 100644 --- a/modules/git/last_commit_cache.go +++ b/modules/git/last_commit_cache.go @@ -4,11 +4,12 @@ package git import ( - "crypto/sha256" "fmt" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" + + "github.com/minio/sha256-simd" ) // Cache represents a caching interface diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go index 94277a6b8..a4ae21bfd 100644 --- a/modules/lfs/content_store.go +++ b/modules/lfs/content_store.go @@ -4,7 +4,6 @@ package lfs import ( - "crypto/sha256" "encoding/hex" "errors" "hash" @@ -13,6 +12,8 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/storage" + + "github.com/minio/sha256-simd" ) var ( diff --git a/modules/lfs/pointer.go b/modules/lfs/pointer.go index b5e13d56a..f7f225bf1 100644 --- a/modules/lfs/pointer.go +++ b/modules/lfs/pointer.go @@ -4,7 +4,6 @@ package lfs import ( - "crypto/sha256" "encoding/hex" "errors" "fmt" @@ -15,6 +14,8 @@ import ( "strings" "code.gitea.io/gitea/modules/log" + + "github.com/minio/sha256-simd" ) const ( diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go index 2bd8de38a..a407083f3 100644 --- a/modules/repository/commits_test.go +++ b/modules/repository/commits_test.go @@ -106,7 +106,7 @@ func enableGravatar(t *testing.T) { err := system_model.SetSettingNoVersion(db.DefaultContext, system_model.KeyPictureDisableGravatar, "false") assert.NoError(t, err) setting.GravatarSource = "https://secure.gravatar.com/avatar" - err = system_model.Init() + err = system_model.Init(db.DefaultContext) assert.NoError(t, err) } diff --git a/modules/repository/init.go b/modules/repository/init.go index 5705fe5b9..771b68a49 100644 --- a/modules/repository/init.go +++ b/modules/repository/init.go @@ -316,9 +316,8 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi return fmt.Errorf("git add --all: %w", err) } - cmd := git.NewCommand(ctx, "commit"). - AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email). - AddOptionValues("-m", "Initial commit") + cmd := git.NewCommand(ctx, "commit", "--message=Initial commit"). + AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email) sign, keyID, signer, _ := asymkey_service.SignInitialCommit(ctx, tmpPath, u) if sign { diff --git a/modules/secret/secret.go b/modules/secret/secret.go index b84d1cfea..628ae505a 100644 --- a/modules/secret/secret.go +++ b/modules/secret/secret.go @@ -7,11 +7,12 @@ import ( "crypto/aes" "crypto/cipher" "crypto/rand" - "crypto/sha256" "encoding/base64" "encoding/hex" "errors" "io" + + "github.com/minio/sha256-simd" ) // AesEncrypt encrypts text and given key with AES. diff --git a/modules/setting/config_provider.go b/modules/setting/config_provider.go index 67a4e4ded..0244a8d06 100644 --- a/modules/setting/config_provider.go +++ b/modules/setting/config_provider.go @@ -25,9 +25,9 @@ func mustMapSetting(rootCfg ConfigProvider, sectionName string, setting interfac } } -func deprecatedSetting(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey string) { +func deprecatedSetting(rootCfg ConfigProvider, oldSection, oldKey, newSection, newKey, version string) { if rootCfg.Section(oldSection).HasKey(oldKey) { - log.Error("Deprecated fallback `[%s]` `%s` present. Use `[%s]` `%s` instead. This fallback will be removed in v1.19.0", oldSection, oldKey, newSection, newKey) + log.Error("Deprecated fallback `[%s]` `%s` present. Use `[%s]` `%s` instead. This fallback will be/has been removed in %s", oldSection, oldKey, newSection, newKey, version) } } diff --git a/modules/setting/indexer.go b/modules/setting/indexer.go index 528a9eb65..5b10018eb 100644 --- a/modules/setting/indexer.go +++ b/modules/setting/indexer.go @@ -56,12 +56,13 @@ func loadIndexerFrom(rootCfg ConfigProvider) { Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName) // The following settings are deprecated and can be overridden by settings in [queue] or [queue.issue_indexer] - // FIXME: DEPRECATED to be removed in v1.18.0 - deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_TYPE", "queue.issue_indexer", "TYPE") - deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_DIR", "queue.issue_indexer", "DATADIR") - deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_CONN_STR", "queue.issue_indexer", "CONN_STR") - deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_BATCH_NUMBER", "queue.issue_indexer", "BATCH_LENGTH") - deprecatedSetting(rootCfg, "indexer", "UPDATE_BUFFER_LEN", "queue.issue_indexer", "LENGTH") + // DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version + // if these are removed, the warning will not be shown + deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_TYPE", "queue.issue_indexer", "TYPE", "v1.19.0") + deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_DIR", "queue.issue_indexer", "DATADIR", "v1.19.0") + deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_CONN_STR", "queue.issue_indexer", "CONN_STR", "v1.19.0") + deprecatedSetting(rootCfg, "indexer", "ISSUE_INDEXER_QUEUE_BATCH_NUMBER", "queue.issue_indexer", "BATCH_LENGTH", "v1.19.0") + deprecatedSetting(rootCfg, "indexer", "UPDATE_BUFFER_LEN", "queue.issue_indexer", "LENGTH", "v1.19.0") Indexer.RepoIndexerEnabled = sec.Key("REPO_INDEXER_ENABLED").MustBool(false) Indexer.RepoType = sec.Key("REPO_INDEXER_TYPE").MustString("bleve") diff --git a/modules/setting/lfs.go b/modules/setting/lfs.go index e6c9e42f2..e04cde100 100644 --- a/modules/setting/lfs.go +++ b/modules/setting/lfs.go @@ -35,8 +35,9 @@ func loadLFSFrom(rootCfg ConfigProvider) { storageType := lfsSec.Key("STORAGE_TYPE").MustString("") // Specifically default PATH to LFS_CONTENT_PATH - // FIXME: DEPRECATED to be removed in v1.18.0 - deprecatedSetting(rootCfg, "server", "LFS_CONTENT_PATH", "lfs", "PATH") + // DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version + // if these are removed, the warning will not be shown + deprecatedSetting(rootCfg, "server", "LFS_CONTENT_PATH", "lfs", "PATH", "v1.19.0") lfsSec.Key("PATH").MustString( sec.Key("LFS_CONTENT_PATH").String()) diff --git a/modules/setting/mailer.go b/modules/setting/mailer.go index 62a73cb2f..39afce7d4 100644 --- a/modules/setting/mailer.go +++ b/modules/setting/mailer.go @@ -64,16 +64,16 @@ func loadMailerFrom(rootCfg ConfigProvider) { } // Handle Deprecations and map on to new configuration - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "MAILER_TYPE", "mailer", "PROTOCOL") + // DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version + // if these are removed, the warning will not be shown + deprecatedSetting(rootCfg, "mailer", "MAILER_TYPE", "mailer", "PROTOCOL", "v1.19.0") if sec.HasKey("MAILER_TYPE") && !sec.HasKey("PROTOCOL") { if sec.Key("MAILER_TYPE").String() == "sendmail" { sec.Key("PROTOCOL").MustString("sendmail") } } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "HOST", "mailer", "SMTP_ADDR") + deprecatedSetting(rootCfg, "mailer", "HOST", "mailer", "SMTP_ADDR", "v1.19.0") if sec.HasKey("HOST") && !sec.HasKey("SMTP_ADDR") { givenHost := sec.Key("HOST").String() addr, port, err := net.SplitHostPort(givenHost) @@ -89,8 +89,7 @@ func loadMailerFrom(rootCfg ConfigProvider) { sec.Key("SMTP_PORT").MustString(port) } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "IS_TLS_ENABLED", "mailer", "PROTOCOL") + deprecatedSetting(rootCfg, "mailer", "IS_TLS_ENABLED", "mailer", "PROTOCOL", "v1.19.0") if sec.HasKey("IS_TLS_ENABLED") && !sec.HasKey("PROTOCOL") { if sec.Key("IS_TLS_ENABLED").MustBool() { sec.Key("PROTOCOL").MustString("smtps") @@ -99,38 +98,32 @@ func loadMailerFrom(rootCfg ConfigProvider) { } } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "DISABLE_HELO", "mailer", "ENABLE_HELO") + deprecatedSetting(rootCfg, "mailer", "DISABLE_HELO", "mailer", "ENABLE_HELO", "v1.19.0") if sec.HasKey("DISABLE_HELO") && !sec.HasKey("ENABLE_HELO") { sec.Key("ENABLE_HELO").MustBool(!sec.Key("DISABLE_HELO").MustBool()) } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "SKIP_VERIFY", "mailer", "FORCE_TRUST_SERVER_CERT") + deprecatedSetting(rootCfg, "mailer", "SKIP_VERIFY", "mailer", "FORCE_TRUST_SERVER_CERT", "v1.19.0") if sec.HasKey("SKIP_VERIFY") && !sec.HasKey("FORCE_TRUST_SERVER_CERT") { sec.Key("FORCE_TRUST_SERVER_CERT").MustBool(sec.Key("SKIP_VERIFY").MustBool()) } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "USE_CERTIFICATE", "mailer", "USE_CLIENT_CERT") + deprecatedSetting(rootCfg, "mailer", "USE_CERTIFICATE", "mailer", "USE_CLIENT_CERT", "v1.19.0") if sec.HasKey("USE_CERTIFICATE") && !sec.HasKey("USE_CLIENT_CERT") { sec.Key("USE_CLIENT_CERT").MustBool(sec.Key("USE_CERTIFICATE").MustBool()) } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "CERT_FILE", "mailer", "CLIENT_CERT_FILE") + deprecatedSetting(rootCfg, "mailer", "CERT_FILE", "mailer", "CLIENT_CERT_FILE", "v1.19.0") if sec.HasKey("CERT_FILE") && !sec.HasKey("CLIENT_CERT_FILE") { sec.Key("CERT_FILE").MustString(sec.Key("CERT_FILE").String()) } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "KEY_FILE", "mailer", "CLIENT_KEY_FILE") + deprecatedSetting(rootCfg, "mailer", "KEY_FILE", "mailer", "CLIENT_KEY_FILE", "v1.19.0") if sec.HasKey("KEY_FILE") && !sec.HasKey("CLIENT_KEY_FILE") { sec.Key("KEY_FILE").MustString(sec.Key("KEY_FILE").String()) } - // FIXME: DEPRECATED to be removed in v1.19.0 - deprecatedSetting(rootCfg, "mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT") + deprecatedSetting(rootCfg, "mailer", "ENABLE_HTML_ALTERNATIVE", "mailer", "SEND_AS_PLAIN_TEXT", "v1.19.0") if sec.HasKey("ENABLE_HTML_ALTERNATIVE") && !sec.HasKey("SEND_AS_PLAIN_TEXT") { sec.Key("SEND_AS_PLAIN_TEXT").MustBool(!sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false)) } diff --git a/modules/setting/mirror.go b/modules/setting/mirror.go index 875062f52..cd6b8d456 100644 --- a/modules/setting/mirror.go +++ b/modules/setting/mirror.go @@ -27,8 +27,9 @@ var Mirror = struct { func loadMirrorFrom(rootCfg ConfigProvider) { // Handle old configuration through `[repository]` `DISABLE_MIRRORS` // - please note this was badly named and only disabled the creation of new pull mirrors - // FIXME: DEPRECATED to be removed in v1.18.0 - deprecatedSetting(rootCfg, "repository", "DISABLE_MIRRORS", "mirror", "ENABLED") + // DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version + // if these are removed, the warning will not be shown + deprecatedSetting(rootCfg, "repository", "DISABLE_MIRRORS", "mirror", "ENABLED", "v1.19.0") if rootCfg.Section("repository").Key("DISABLE_MIRRORS").MustBool(false) { Mirror.DisableNewPull = true } diff --git a/modules/setting/server.go b/modules/setting/server.go index 6b0f3752e..183906268 100644 --- a/modules/setting/server.go +++ b/modules/setting/server.go @@ -178,38 +178,40 @@ func loadServerFrom(rootCfg ConfigProvider) { switch protocolCfg { case "https": Protocol = HTTPS - // FIXME: DEPRECATED to be removed in v1.18.0 + + // DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version + // if these are removed, the warning will not be shown if sec.HasKey("ENABLE_ACME") { EnableAcme = sec.Key("ENABLE_ACME").MustBool(false) } else { - deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME") + deprecatedSetting(rootCfg, "server", "ENABLE_LETSENCRYPT", "server", "ENABLE_ACME", "v1.19.0") EnableAcme = sec.Key("ENABLE_LETSENCRYPT").MustBool(false) } if EnableAcme { AcmeURL = sec.Key("ACME_URL").MustString("") AcmeCARoot = sec.Key("ACME_CA_ROOT").MustString("") - // FIXME: DEPRECATED to be removed in v1.18.0 + if sec.HasKey("ACME_ACCEPTTOS") { AcmeTOS = sec.Key("ACME_ACCEPTTOS").MustBool(false) } else { - deprecatedSetting(rootCfg, "server", "LETSENCRYPT_ACCEPTTOS", "server", "ACME_ACCEPTTOS") + deprecatedSetting(rootCfg, "server", "LETSENCRYPT_ACCEPTTOS", "server", "ACME_ACCEPTTOS", "v1.19.0") AcmeTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false) } if !AcmeTOS { log.Fatal("ACME TOS is not accepted (ACME_ACCEPTTOS).") } - // FIXME: DEPRECATED to be removed in v1.18.0 + if sec.HasKey("ACME_DIRECTORY") { AcmeLiveDirectory = sec.Key("ACME_DIRECTORY").MustString("https") } else { - deprecatedSetting(rootCfg, "server", "LETSENCRYPT_DIRECTORY", "server", "ACME_DIRECTORY") + deprecatedSetting(rootCfg, "server", "LETSENCRYPT_DIRECTORY", "server", "ACME_DIRECTORY", "v1.19.0") AcmeLiveDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https") } - // FIXME: DEPRECATED to be removed in v1.18.0 + if sec.HasKey("ACME_EMAIL") { AcmeEmail = sec.Key("ACME_EMAIL").MustString("") } else { - deprecatedSetting(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL") + deprecatedSetting(rootCfg, "server", "LETSENCRYPT_EMAIL", "server", "ACME_EMAIL", "v1.19.0") AcmeEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("") } } else { diff --git a/modules/setting/task.go b/modules/setting/task.go index 81732deeb..f75b4f148 100644 --- a/modules/setting/task.go +++ b/modules/setting/task.go @@ -3,15 +3,16 @@ package setting -// FIXME: DEPRECATED to be removed in v1.18.0 +// DEPRECATED should not be removed because users maybe upgrade from lower version to the latest version +// if these are removed, the warning will not be shown // - will need to set default for [queue.task] LENGTH to 1000 though func loadTaskFrom(rootCfg ConfigProvider) { taskSec := rootCfg.Section("task") queueTaskSec := rootCfg.Section("queue.task") - deprecatedSetting(rootCfg, "task", "QUEUE_TYPE", "queue.task", "TYPE") - deprecatedSetting(rootCfg, "task", "QUEUE_CONN_STR", "queue.task", "CONN_STR") - deprecatedSetting(rootCfg, "task", "QUEUE_LENGTH", "queue.task", "LENGTH") + deprecatedSetting(rootCfg, "task", "QUEUE_TYPE", "queue.task", "TYPE", "v1.19.0") + deprecatedSetting(rootCfg, "task", "QUEUE_CONN_STR", "queue.task", "CONN_STR", "v1.19.0") + deprecatedSetting(rootCfg, "task", "QUEUE_LENGTH", "queue.task", "LENGTH", "v1.19.0") switch taskSec.Key("QUEUE_TYPE").MustString("channel") { case "channel": diff --git a/modules/structs/user_app.go b/modules/structs/user_app.go index 3a5ae34df..7f78fbd49 100644 --- a/modules/structs/user_app.go +++ b/modules/structs/user_app.go @@ -11,10 +11,11 @@ import ( // 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"` + ID int64 `json:"id"` + Name string `json:"name"` + Token string `json:"sha1"` + TokenLastEight string `json:"token_last_eight"` + Scopes []string `json:"scopes"` } // AccessTokenList represents a list of API access token. @@ -22,9 +23,10 @@ type AccessToken struct { type AccessTokenList []*AccessToken // CreateAccessTokenOption options when create access token -// swagger:parameters userCreateToken type CreateAccessTokenOption struct { - Name string `json:"name" binding:"Required"` + // required: true + Name string `json:"name" binding:"Required"` + Scopes []string `json:"scopes"` } // CreateOAuth2ApplicationOptions holds options to create an oauth2 application diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 4ffd0a5de..17ac68dc6 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -92,7 +92,7 @@ func NewFuncMap() []template.FuncMap { return setting.AssetVersion }, "DisableGravatar": func(ctx context.Context) bool { - return system_model.GetSettingBool(ctx, system_model.KeyPictureDisableGravatar) + return system_model.GetSettingWithCacheBool(ctx, system_model.KeyPictureDisableGravatar) }, "DefaultShowFullName": func() bool { return setting.UI.DefaultShowFullName @@ -174,8 +174,9 @@ func NewFuncMap() []template.FuncMap { "RenderEmojiPlain": emoji.ReplaceAliases, "ReactionToEmoji": ReactionToEmoji, "RenderNote": RenderNote, - "RenderMarkdownToHtml": func(input string) template.HTML { + "RenderMarkdownToHtml": func(ctx context.Context, input string) template.HTML { output, err := markdown.RenderString(&markup.RenderContext{ + Ctx: ctx, URLPrefix: setting.AppSubURL, }, input) if err != nil { diff --git a/modules/util/keypair_test.go b/modules/util/keypair_test.go index c6f68c845..c9925f798 100644 --- a/modules/util/keypair_test.go +++ b/modules/util/keypair_test.go @@ -7,12 +7,12 @@ import ( "crypto" "crypto/rand" "crypto/rsa" - "crypto/sha256" "crypto/x509" "encoding/pem" "regexp" "testing" + "github.com/minio/sha256-simd" "github.com/stretchr/testify/assert" ) |