mirror of https://github.com/gogs/gogs.git
Merge b8a0a6173c
into 4acaaac85a
commit
f942b21b00
|
@ -16,3 +16,6 @@ output*
|
|||
/release
|
||||
.task
|
||||
.envrc
|
||||
go-remote.sh
|
||||
testhome
|
||||
*.patch
|
||||
|
|
21
LICENSE
21
LICENSE
|
@ -1,19 +1,8 @@
|
|||
Copyright (c) The Gogs Authors
|
||||
The MIT License (MIT)
|
||||
Copyright © 2025 宋子桓(Song Zihuan)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
114
README.md
114
README.md
|
@ -1,108 +1,34 @@
|
|||

|
||||
# Huan-Gogs
|
||||
|
||||
[](https://github.com/gogs/gogs/actions?query=branch%3Amain) [](https://discord.gg/9aqdHU7) [](https://sourcegraph.com/github.com/gogs/gogs)
|
||||
[Gogs](https://gogs.io)(`/gɑgz/`)是一款极易搭建的自助 Git 服务。
|
||||
|
||||
[简体中文](README_ZH.md)
|
||||
[Huan-Gogs](https://github.com/SongZihuan/HuanGogs) 是根据 Gogs 按需改进而来。
|
||||
|
||||
## 🔮 Vision
|
||||
例如增加了功能:
|
||||
|
||||
The Gogs (`/gɑgz/`) project aims to build a simple, stable and extensible self-hosted Git service that can be set up in the most painless way. With Go, this can be done with an independent binary distribution across all platforms that Go supports, including Linux, macOS, Windows and ARM-based systems.
|
||||
- 公共邮件和主邮件分开。
|
||||
- 优化邮件服务TLS握手过程。
|
||||
- 更新用户权限、登录逻辑判断。
|
||||
- 更新用户仓库创建逻辑(例如可以开启允许管理员无限制创建,而一般注册用户只能查看)。
|
||||
- 允许限制用户探索其他用户的逻辑(Explore 发现页面 可以对一般用户不展示其他用户)。
|
||||
- 修复了一些Bug。
|
||||
|
||||
## 📡 Overview
|
||||
## 关于 Gogs
|
||||
|
||||
- Please visit [our home page](https://gogs.io) for user documentation.
|
||||
- Please refer to [CHANGELOG.md](CHANGELOG.md) for list of changes in each releases.
|
||||
- Want to try it before doing anything else? Do it [online](https://try.gogs.io/gogs/gogs)!
|
||||
- Having trouble? Help yourself with [troubleshooting](https://gogs.io/docs/intro/troubleshooting.html) or ask questions in [Discussions](https://github.com/gogs/gogs/discussions).
|
||||
- Want to help with localization? Check out the [localization documentation](https://gogs.io/docs/features/i18n.html).
|
||||
- Ready to get hands dirty? Read our [contributing guide](.github/CONTRIBUTING.md).
|
||||
- Hmm... What about APIs? We have experimental support with [documentation](https://github.com/gogs/docs-api).
|
||||
可以访问 Gogs 的官网获得更多介绍:[gogs.io](https://gogs.io/)。
|
||||
|
||||
## 💌 Features
|
||||
也可以访问其 Github 仓库获取更多介绍:[github.com/gogs/gogs](https://github.com/gogs/gogs)。
|
||||
|
||||
- User dashboard, user profile and activity timeline.
|
||||
- Access repositories via SSH, HTTP and HTTPS protocols.
|
||||
- User, organization and repository management.
|
||||
- Repository and organization webhooks, including Slack, Discord and Dingtalk.
|
||||
- Repository Git hooks, deploy keys and Git LFS.
|
||||
- Repository issues, pull requests, wiki, protected branches and collaboration.
|
||||
- Migrate and mirror repositories with wiki from other code hosts.
|
||||
- Web editor for quick editing repository files and wiki.
|
||||
- Jupyter Notebook and PDF rendering.
|
||||
- Authentication via SMTP, LDAP, reverse proxy, GitHub.com and GitHub Enterprise with 2FA.
|
||||
- Customize HTML templates, static files and many others.
|
||||
- Rich database backend support, including PostgreSQL, MySQL, SQLite3 or any database backend that speaks one of those protocols.
|
||||
- Have localization over [31 languages](https://crowdin.com/project/gogs).
|
||||
## 使用文档
|
||||
|
||||
## 💾 Hardware requirements
|
||||
文档请查看此处:[点击前往](./docs/README.md)。
|
||||
|
||||
- A Raspberry Pi or $5 Digital Ocean Droplet is more than enough to get you started. Some even use 64MB RAM Docker [CaaS](https://www.docker.com/blog/containers-as-a-service-caas/).
|
||||
- 2 CPU cores and 512MB RAM would be the baseline for teamwork.
|
||||
- Increase CPU cores when your team size gets significantly larger, memory footprint remains low.
|
||||
## 授权许可
|
||||
|
||||
## 💻 Browser support
|
||||
Gogs 项目采用 MIT 开源授权许可证,完整的授权说明已放置在 [LICENSE.gogs](/LICENSE.gogs) 文件中。
|
||||
|
||||
- Please see [Semantic UI](https://github.com/Semantic-Org/Semantic-UI#browser-support) for specific versions of supported browsers.
|
||||
- The smallest resolution officially supported is **1024*768**, however the UI may still look right in smaller resolutions, but no promises or fixes.
|
||||
## 协议
|
||||
|
||||
## 📜 Installation
|
||||
本项目基于 [MIT LICENSE](/LICENSE) 发布。
|
||||
了解更多关于 MIT LICENSE , 请 [点击此处](https://mit-license.song-zh.com) 。
|
||||
|
||||
Make sure you install the [prerequisites](https://gogs.io/docs/installation) first.
|
||||
|
||||
There are 6 ways to install Gogs:
|
||||
|
||||
- [Install from binary](https://gogs.io/docs/installation/install_from_binary.html)
|
||||
- [Install from source](https://gogs.io/docs/installation/install_from_source.html)
|
||||
- [Install from packages](https://gogs.io/docs/installation/install_from_packages.html)
|
||||
- [Ship with Docker](https://github.com/gogs/gogs/tree/main/docker)
|
||||
- [Try with Vagrant](https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/gogs)
|
||||
|
||||
### Deploy to cloud
|
||||
|
||||
- [Cloudron](https://www.cloudron.io/store/io.gogs.cloudronapp.html)
|
||||
- [YunoHost](https://github.com/YunoHost-Apps/gogs_ynh)
|
||||
- [alwaysdata](https://www.alwaysdata.com/en/marketplace/gogs/)
|
||||
|
||||
### Tutorials
|
||||
|
||||
- [Private Git Web Portal in Raspberry PI With Gogs](https://peppe8o.com/private-git-web-portal-in-raspberry-pi-with-gogs/)
|
||||
- [How To Set Up Gogs on Ubuntu 14.04](https://www.digitalocean.com/community/tutorials/how-to-set-up-gogs-on-ubuntu-14-04)
|
||||
- [Run your own GitHub-like service with the help of Docker](https://blog.hypriot.com/post/run-your-own-github-like-service-with-docker/)
|
||||
- [Dockerized Gogs git server and alpine postgres in 20 minutes or less](https://garthwaite.org/docker-gogs.html)
|
||||
- [Host Your Own Private GitHub with Gogs](https://eladnava.com/host-your-own-private-github-with-gogs-io/)
|
||||
- [使用 Gogs 搭建自己的 Git 服务器](https://blog.mynook.info/post/host-your-own-git-server-using-gogs/) (Chinese)
|
||||
- [阿里云上 Ubuntu 14.04 64 位安装 Gogs](https://my.oschina.net/luyao/blog/375654) (Chinese)
|
||||
- [Installing Gogs on FreeBSD](https://www.codejam.info/2015/03/installing-gogs-on-freebsd.html)
|
||||
- [How to install Gogs on a Linux Server (DigitalOcean)](https://www.youtube.com/watch?v=deSfX0gqefE)
|
||||
|
||||
## 📦 Software, service and product support
|
||||
|
||||
- [Jenkins](https://plugins.jenkins.io/gogs-webhook/) (CI)
|
||||
- [Puppet](https://forge.puppet.com/modules/Siteminds/gogs) (IT)
|
||||
- [Synology](https://www.synology.com) (Docker)
|
||||
- [Syncloud](https://syncloud.org/) (App Store)
|
||||
|
||||
## 🙇♂️ Acknowledgments
|
||||
|
||||
<p>This project is proudly supported by:</p>
|
||||
<p>
|
||||
<a href="https://www.digitalocean.com/">
|
||||
<img src="https://opensource.nyc3.cdn.digitaloceanspaces.com/attribution/assets/SVG/DO_Logo_horizontal_blue.svg" width="201px">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Other acknowledgments:
|
||||
|
||||
- Thanks [Egon Elbre](https://twitter.com/egonelbre) for designing the original version of the logo.
|
||||
- Thanks [Crowdin](https://crowdin.com/project/gogs) for sponsoring open source translation plan.
|
||||
- Thanks [MonoVM](https://monovm.com/linux-vps/) for sponsoring VPS services.
|
||||
- Thanks [Buildkite](https://buildkite.com) for sponsoring open source CI/CD plan.
|
||||
|
||||
## 👋 Contributors
|
||||
|
||||
- See [contributors page](https://github.com/gogs/gogs/graphs/contributors) for top 100 contributors.
|
||||
- See [TRANSLATORS](conf/locale/TRANSLATORS) for public list of translators.
|
||||
|
||||
## ⚖️ License
|
||||
|
||||
This project is under the MIT License. See the [LICENSE](https://github.com/gogs/gogs/blob/main/LICENSE) file for the full license text.
|
||||
|
|
|
@ -65,7 +65,7 @@ tasks:
|
|||
cmds:
|
||||
- rm -rf {{.RELEASE_GOGS}}
|
||||
- mkdir -p {{.RELEASE_GOGS}}
|
||||
- cp -r gogs{{.BINARY_EXT}} LICENSE README.md README_ZH.md scripts {{.RELEASE_GOGS}}
|
||||
- cp -r gogs{{.BINARY_EXT}} LICENSE LICENSE.gogs README.md scripts {{.RELEASE_GOGS}}
|
||||
- cd {{.RELEASE_ROOT}} && zip -r gogs.zip "gogs"
|
||||
vars:
|
||||
RELEASE_ROOT: release
|
||||
|
|
|
@ -15,6 +15,8 @@ RUN_MODE = dev
|
|||
EXTERNAL_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
|
||||
; The public-facing domain name for the application.
|
||||
DOMAIN = localhost
|
||||
; Use TCP Proxy Proto
|
||||
PROXY_PROTO = false
|
||||
; The protocol that is used to serve direct traffic to the application.
|
||||
; Currently supports "http", "https", "fcgi" and "unix".
|
||||
PROTOCOL = http
|
||||
|
@ -102,6 +104,10 @@ SCRIPT_TYPE = bash
|
|||
ANSI_CHARSET =
|
||||
; Whether to force every new repository to be private.
|
||||
FORCE_PRIVATE = false
|
||||
; Administrators are not restricted from creating repositories
|
||||
ADMIN_NOT_CREATION_LIMIT = false
|
||||
; Organizations can create an unlimited number of repositories (only works if admin.DISABLE_REGULAR_ORG_CREATION is true)
|
||||
ORGANIZATION_NOT_CREATION_LIMIT = false
|
||||
; The global limit of number of repositories a user can create, -1 means no limit.
|
||||
MAX_CREATION_LIMIT = -1
|
||||
; Preferred Licenses to place at the top of the list.
|
||||
|
@ -344,6 +350,8 @@ ANGLED_QUOTES = true
|
|||
[admin]
|
||||
; Whether to disable regular (non-admin) users to create organizations.
|
||||
DISABLE_REGULAR_ORG_CREATION = false
|
||||
; Whether to disable regular (non-admin) users to explore other user.
|
||||
DISABLE_REGULAR_EXPLORE_USER = false
|
||||
|
||||
[webhook]
|
||||
; The list of enabled types for users to use, can be "gogs", "slack", "discord", "dingtalk".
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2022 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2022 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ signed_in_as=已登录用户
|
|||
|
||||
username=用户名
|
||||
email=邮箱
|
||||
pubemail=公开邮箱
|
||||
password=密码
|
||||
re_type=确认密码
|
||||
captcha=验证码
|
||||
|
@ -310,9 +311,13 @@ password_change_disabled=非本地类型的用户被禁止修改密码。
|
|||
|
||||
emails=邮箱地址
|
||||
manage_emails=管理邮箱地址
|
||||
email_desc=您的主要邮箱地址将被用于通知提醒和其它操作。
|
||||
email_desc=您的主要邮箱地址将被用于通知提醒和其它操作,公开邮件地址用于公开展示用途。
|
||||
primary=主要
|
||||
public=公开
|
||||
anonymous=匿名
|
||||
primary_email=设为主要
|
||||
public_email=设为公开
|
||||
anonymous_email=使用匿名
|
||||
delete_email=删除
|
||||
email_deletion=邮箱删除操作
|
||||
email_deletion_desc=删除该邮箱地址将会移除所有相关的信息。是否继续?
|
||||
|
@ -637,7 +642,7 @@ pulls.nothing_merge_base=由于两个分支各自拥有完全不同的提交历
|
|||
pulls.has_pull_request=`已经存在目标分支的合并请求:<a href="%[1]s/pulls/%[3]d">%[2]s#%[3]d</a>`
|
||||
pulls.create=创建合并请求
|
||||
pulls.title_desc=请求将 %[1]d 次代码提交从 <code>%[2]s</code> 合并至 <code>%[3]s</code>
|
||||
pulls.merged_title_desc=于 %[4]s 将 %[1]d 次代码提交从 <code>%[2]s</code>合并至 <code>%[3]s</code>
|
||||
pulls.merged_title_desc=于 %[4]s 将 %[1]d 次代码提交从 <code>%[2]s</code>合并至 <code>%[3]s</code>
|
||||
pulls.tab_conversation=对话内容
|
||||
pulls.tab_commits=代码提交
|
||||
pulls.tab_files=文件变动
|
||||
|
@ -819,7 +824,7 @@ settings.githook_edit_desc=如果钩子未启动,则会显示样例文件中
|
|||
settings.githook_name=钩子名称
|
||||
settings.githook_content=钩子文本
|
||||
settings.update_githook=更新钩子设置
|
||||
settings.add_webhook_desc=我们会通过 <code>POST</code> 请求将订阅事件信息发送至向指定 URL 地址。您可以设置不同的数据接收方式(JSON 或 <code>x-www-form-urlencoded</code>)。 请查阅 <a target="_blank" href="%s">Webhooks 文档</a> 获取更多信息。
|
||||
settings.add_webhook_desc=我们会通过 <code>POST</code> 请求将订阅事件信息发送至向指定 URL 地址。您可以设置不同的数据接收方式(JSON 或 <code>x-www-form-urlencoded</code>)。 请查阅 <a target="_blank" href="%s">Webhooks 文档</a> 获取更多信息。
|
||||
settings.payload_url=推送地址
|
||||
settings.content_type=数据格式
|
||||
settings.secret=密钥文本
|
||||
|
@ -1180,6 +1185,7 @@ config.brand_name=品牌名称
|
|||
config.run_user=运行用户
|
||||
config.run_mode=运行模式
|
||||
config.server.external_url=外部网址
|
||||
config.server.proxy_proto=支持TCP转发服务
|
||||
config.server.domain=域名
|
||||
config.server.protocol=协议
|
||||
config.server.http_addr=HTTP 地址
|
||||
|
@ -1213,11 +1219,17 @@ config.ssh.server_ciphers=服务端加密套件
|
|||
config.ssh.server_macs=服务器 MAC 地址
|
||||
config.ssh.server_algorithms=服务器算法
|
||||
|
||||
config.admin_config=用户管理配置
|
||||
config.admin.disable_regular_org_creation="禁止非管理员创建组织"
|
||||
config.admin.disable_regularExploreUser="禁止非管理员探索其他用户"
|
||||
|
||||
config.repo_config=仓库配置
|
||||
config.repo.root_path=根目录
|
||||
config.repo.script_type=脚本类型
|
||||
config.repo.ansi_chatset=ANSI 字符集
|
||||
config.repo.force_private=强制设为私有
|
||||
config.repo.admin_not_creation_limit=管理员创建仓库无限制
|
||||
config.repo.organization_not_creation_limit=组织创建仓库无限制
|
||||
config.repo.max_creation_limit=最大创建限制
|
||||
config.repo.preferred_licenses=推荐的许可证
|
||||
config.repo.disable_http_git=禁用 HTTP Git
|
||||
|
|
|
@ -18,6 +18,7 @@ signed_in_as=已登錄用戶
|
|||
|
||||
username=用戶名稱
|
||||
email=電子郵件
|
||||
pubemail=公开電子郵件地址
|
||||
password=密碼
|
||||
re_type=確認密碼
|
||||
captcha=驗證碼
|
||||
|
@ -310,9 +311,13 @@ password_change_disabled=不允許非本地類型使用者,更改其密碼。
|
|||
|
||||
emails=電子郵件地址
|
||||
manage_emails=管理電子郵件地址
|
||||
email_desc=您的主要邮箱地址将被用于通知提醒和其它操作。
|
||||
email_desc=您的主要電子郵件地址将被用于通知提醒和其它操作,公开電子郵件地址用于公开展示用途。
|
||||
primary=主要
|
||||
public=公开
|
||||
anonymous=匿名
|
||||
primary_email=设为主要
|
||||
public_email=设为公开
|
||||
anonymous_email=使用匿名
|
||||
delete_email=刪除
|
||||
email_deletion=刪除郵箱
|
||||
email_deletion_desc=刪除該郵箱地址將會移除所有相關的信息。是否繼續?
|
||||
|
@ -1179,6 +1184,7 @@ config.brand_name=Brand name
|
|||
config.run_user=執行用戶
|
||||
config.run_mode=執行模式
|
||||
config.server.external_url=External URL
|
||||
config.server.proxy_proto=Proxy Protocol
|
||||
config.server.domain=Domain
|
||||
config.server.protocol=Protocol
|
||||
config.server.http_addr=HTTP address
|
||||
|
@ -1212,11 +1218,17 @@ config.ssh.server_ciphers=Server ciphers
|
|||
config.ssh.server_macs=Server MACs
|
||||
config.ssh.server_algorithms=Server algorithms
|
||||
|
||||
config.admin_config=Admin configuration
|
||||
config.admin.disable_regular_org_creation=Only admin can create organization
|
||||
config.admin.disable_regularExploreUser=Only admin can explore user
|
||||
|
||||
config.repo_config=Repository configuration
|
||||
config.repo.root_path=Root path
|
||||
config.repo.script_type=Script type
|
||||
config.repo.ansi_chatset=ANSI charset
|
||||
config.repo.force_private=Force private
|
||||
config.repo.admin_not_creation_limit=Admin creation unlimited
|
||||
config.repo.organization_not_creation_limit=Organization creation unlimited
|
||||
config.repo.max_creation_limit=Max creation limit
|
||||
config.repo.preferred_licenses=Preferred licenses
|
||||
config.repo.disable_http_git=Disable HTTP Git
|
||||
|
|
|
@ -18,6 +18,7 @@ signed_in_as=已登入用戶
|
|||
|
||||
username=用戶名稱
|
||||
email=電子郵件
|
||||
pubemail=公开電子郵件地址
|
||||
password=密碼
|
||||
re_type=確認密碼
|
||||
captcha=驗證碼
|
||||
|
@ -310,9 +311,13 @@ password_change_disabled=不允許非本地類型使用者,更改其密碼。
|
|||
|
||||
emails=電子郵件地址
|
||||
manage_emails=管理電子郵件地址
|
||||
email_desc=您的主要邮箱地址将被用于通知提醒和其它操作。
|
||||
email_desc=您的主要電子郵件地址将被用于通知提醒和其它操作,公开電子郵件地址用于公开展示用途。
|
||||
primary=主要
|
||||
public=公开
|
||||
anonymous=匿名
|
||||
primary_email=设为主要
|
||||
public_email=设为公开
|
||||
anonymous_email=使用匿名
|
||||
delete_email=刪除
|
||||
email_deletion=刪除郵箱
|
||||
email_deletion_desc=刪除該郵箱地址將會移除所有相關的信息。是否繼續?
|
||||
|
@ -1179,6 +1184,7 @@ config.brand_name=Brand name
|
|||
config.run_user=執行用戶
|
||||
config.run_mode=執行模式
|
||||
config.server.external_url=External URL
|
||||
config.server.proxy_proto=Proxy Protocol
|
||||
config.server.domain=網域
|
||||
config.server.protocol=協定
|
||||
config.server.http_addr=HTTP address
|
||||
|
@ -1212,11 +1218,17 @@ config.ssh.server_ciphers=Server ciphers
|
|||
config.ssh.server_macs=Server MACs
|
||||
config.ssh.server_algorithms=Server algorithms
|
||||
|
||||
config.admin_config=使用者管理配置
|
||||
config.admin.disable_regular_org_creation=禁止非管理員創建組織
|
||||
config.admin.disable_regularExploreUser=禁止非管理員探索其他用戶
|
||||
|
||||
config.repo_config=Repository 設定
|
||||
config.repo.root_path=根路徑
|
||||
config.repo.script_type=Script type
|
||||
config.repo.ansi_chatset=ANSI charset
|
||||
config.repo.force_private=Force private
|
||||
config.repo.admin_not_creation_limit=Admin creation unlimited
|
||||
config.repo.organization_not_creation_limit=Organization creation unlimited
|
||||
config.repo.max_creation_limit=Max creation limit
|
||||
config.repo.preferred_licenses=Preferred licenses
|
||||
config.repo.disable_http_git=Disable HTTP Git
|
||||
|
|
2
gen.go
2
gen.go
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2022 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package main
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -73,6 +73,7 @@ require (
|
|||
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/denisenkom/go-mssqldb v0.12.0 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/djherbis/buffer v1.2.0 // indirect
|
||||
github.com/djherbis/nio/v3 v3.0.1 // indirect
|
||||
|
@ -109,6 +110,7 @@ require (
|
|||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||
github.com/ncruces/go-strftime v0.1.9 // indirect
|
||||
github.com/pires/go-proxyproto v0.8.0 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.62.0 // indirect
|
||||
|
|
4
go.sum
4
go.sum
|
@ -58,6 +58,8 @@ github.com/denisenkom/go-mssqldb v0.12.0 h1:VtrkII767ttSPNRfFekePK3sctr+joXgO58s
|
|||
github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU=
|
||||
github.com/derision-test/go-mockgen v1.3.7 h1:b/DXAXL2FkaRPpnbYK3ODdZzklmJAwox0tkc6yyXx74=
|
||||
github.com/derision-test/go-mockgen v1.3.7/go.mod h1:/TXUePlhtHmDDCaDAi/a4g6xOHqMDz3Wf0r2NPGskB4=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/djherbis/buffer v1.1.0/go.mod h1:VwN8VdFkMY0DCALdY8o00d3IZ6Amz/UNVMWcSaJT44o=
|
||||
|
@ -342,6 +344,8 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ
|
|||
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
|
||||
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKpXEe0=
|
||||
github.com/pires/go-proxyproto v0.8.0/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY=
|
||||
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
|
||||
github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
// Gogs is a painless self-hosted Git Service.
|
||||
package main
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package app
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package app
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package app
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package auth
|
||||
|
||||
|
@ -69,6 +69,8 @@ type ExternalAccount struct {
|
|||
FullName string
|
||||
// The email address of the account.
|
||||
Email string
|
||||
// The public email address of the account.
|
||||
PublicEmail string
|
||||
// The location of the account.
|
||||
Location string
|
||||
// The website of the account.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package github
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package github
|
||||
|
||||
|
@ -31,12 +31,13 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||
return nil, err
|
||||
}
|
||||
return &auth.ExternalAccount{
|
||||
Login: login,
|
||||
Name: login,
|
||||
FullName: fullname,
|
||||
Email: email,
|
||||
Location: location,
|
||||
Website: website,
|
||||
Login: login,
|
||||
Name: login,
|
||||
FullName: fullname,
|
||||
Email: email,
|
||||
PublicEmail: "",
|
||||
Location: location,
|
||||
Website: website,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
// Package ldap provide functions & structure to query a LDAP ldap directory.
|
||||
// For now, it's mainly tested again an MS Active Directory service, see README.md for more information.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package ldap
|
||||
|
||||
|
@ -53,11 +53,12 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||
}
|
||||
|
||||
return &auth.ExternalAccount{
|
||||
Login: login,
|
||||
Name: username,
|
||||
FullName: composeFullName(fn, sn, username),
|
||||
Email: email,
|
||||
Admin: isAdmin,
|
||||
Login: login,
|
||||
Name: username,
|
||||
FullName: composeFullName(fn, sn, username),
|
||||
Email: email,
|
||||
PublicEmail: "",
|
||||
Admin: isAdmin,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package pam
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package pam
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package pam
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package pam
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package smtp
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/smtp"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"net"
|
||||
"net/smtp"
|
||||
)
|
||||
|
||||
// Config contains configuration for SMTP authentication.
|
||||
|
@ -25,17 +25,34 @@ type Config struct {
|
|||
}
|
||||
|
||||
func (c *Config) doAuth(auth smtp.Auth) error {
|
||||
client, err := smtp.Dial(fmt.Sprintf("%s:%d", c.Host, c.Port))
|
||||
addr := fmt.Sprintf("%s:%d", c.Host, c.Port)
|
||||
conn, err := net.Dial("tcp", addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
_ = conn.Close()
|
||||
}()
|
||||
|
||||
isSecureConn := false
|
||||
if c.Port == 465 {
|
||||
isSecureConn = true
|
||||
conn = tls.Client(conn, &tls.Config{
|
||||
InsecureSkipVerify: c.SkipVerify,
|
||||
ServerName: c.Host,
|
||||
})
|
||||
}
|
||||
|
||||
client, err := smtp.NewClient(conn, c.Host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
if err = client.Hello("gogs"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if c.TLS {
|
||||
if c.TLS && !isSecureConn {
|
||||
if ok, _ := client.Extension("STARTTLS"); ok {
|
||||
if err = client.StartTLS(&tls.Config{
|
||||
InsecureSkipVerify: c.SkipVerify,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package smtp
|
||||
|
||||
|
@ -66,8 +66,9 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||
|
||||
// Check standard error format first, then fallback to the worse case.
|
||||
tperr, ok := err.(*textproto.Error)
|
||||
if (ok && tperr.Code == 535) ||
|
||||
strings.Contains(err.Error(), "Username and Password not accepted") {
|
||||
if (ok && (tperr.Code == 526 || tperr.Code == 530 || tperr.Code == 534 || tperr.Code == 535 || tperr.Code == 536)) ||
|
||||
strings.Contains(err.Error(), "Username and Password not accepted") ||
|
||||
strings.Contains(err.Error(), "Authentication failure") {
|
||||
return nil, auth.ErrBadCredentials{Args: map[string]any{"login": login}}
|
||||
}
|
||||
return nil, err
|
||||
|
@ -82,9 +83,10 @@ func (p *Provider) Authenticate(login, password string) (*auth.ExternalAccount,
|
|||
}
|
||||
|
||||
return &auth.ExternalAccount{
|
||||
Login: login,
|
||||
Name: username,
|
||||
Email: login,
|
||||
Login: login,
|
||||
Name: username,
|
||||
Email: login,
|
||||
PublicEmail: "",
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package authutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package authutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package avatar
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package avatar
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
@ -152,16 +152,11 @@ func runCreateUser(c *cli.Context) error {
|
|||
return errors.Wrap(err, "set engine")
|
||||
}
|
||||
|
||||
user, err := database.Handle.Users().Create(
|
||||
context.Background(),
|
||||
c.String("name"),
|
||||
c.String("email"),
|
||||
database.CreateUserOptions{
|
||||
Password: c.String("password"),
|
||||
Activated: true,
|
||||
Admin: c.Bool("admin"),
|
||||
},
|
||||
)
|
||||
user, err := database.Handle.Users().Create(context.Background(), c.String("name"), c.String("email"), database.CreateUserOptions{
|
||||
Password: c.String("password"),
|
||||
Activated: true,
|
||||
Admin: c.Bool("admin"),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create user")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cmd
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ package cmd
|
|||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"github.com/pires/go-proxyproto"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -14,6 +15,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/go-macaron/binding"
|
||||
"github.com/go-macaron/cache"
|
||||
|
@ -181,6 +183,7 @@ func runWeb(c *cli.Context) error {
|
|||
|
||||
m.Group("", func() {
|
||||
m.Get("/", ignSignIn, route.Home)
|
||||
m.Get("/home", ignSignIn, route.Home)
|
||||
m.Group("/explore", func() {
|
||||
m.Get("", func(c *context.Context) {
|
||||
c.Redirect(conf.Server.Subpath + "/explore/repos")
|
||||
|
@ -715,7 +718,32 @@ func runWeb(c *cli.Context) error {
|
|||
|
||||
switch conf.Server.Protocol {
|
||||
case "http":
|
||||
err = http.ListenAndServe(listenAddr, m)
|
||||
server := http.Server{
|
||||
Addr: listenAddr,
|
||||
Handler: m,
|
||||
}
|
||||
|
||||
var ln net.Listener
|
||||
ln, err = net.Listen("tcp", server.Addr)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to start server: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
var proxyListener net.Listener
|
||||
if conf.Server.ProxyProto {
|
||||
proxyListener = &proxyproto.Listener{
|
||||
Listener: ln,
|
||||
ReadHeaderTimeout: 10 * time.Second,
|
||||
}
|
||||
} else {
|
||||
proxyListener = ln
|
||||
}
|
||||
defer func() {
|
||||
_ = proxyListener.Close()
|
||||
}()
|
||||
|
||||
err = server.Serve(proxyListener)
|
||||
|
||||
case "https":
|
||||
tlsMinVersion := tls.VersionTLS12
|
||||
|
@ -729,23 +757,55 @@ func runWeb(c *cli.Context) error {
|
|||
case "TLS10":
|
||||
tlsMinVersion = tls.VersionTLS10
|
||||
}
|
||||
server := &http.Server{
|
||||
Addr: listenAddr,
|
||||
TLSConfig: &tls.Config{
|
||||
MinVersion: uint16(tlsMinVersion),
|
||||
CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256, tls.CurveP384, tls.CurveP521},
|
||||
PreferServerCipherSuites: true,
|
||||
CipherSuites: []uint16{
|
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
||||
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
|
||||
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
|
||||
},
|
||||
}, Handler: m,
|
||||
|
||||
var cert tls.Certificate
|
||||
cert, err = tls.LoadX509KeyPair(conf.Server.CertFile, conf.Server.KeyFile)
|
||||
if err != nil {
|
||||
log.Fatal("Failed to start server: %v", err)
|
||||
return nil
|
||||
}
|
||||
err = server.ListenAndServeTLS(conf.Server.CertFile, conf.Server.KeyFile)
|
||||
|
||||
tlsConfig := &tls.Config{
|
||||
MinVersion: uint16(tlsMinVersion),
|
||||
CurvePreferences: []tls.CurveID{tls.X25519, tls.CurveP256, tls.CurveP384, tls.CurveP521},
|
||||
Certificates: []tls.Certificate{cert},
|
||||
CipherSuites: []uint16{
|
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
||||
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
|
||||
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
|
||||
},
|
||||
}
|
||||
|
||||
server := http.Server{
|
||||
Addr: listenAddr,
|
||||
Handler: m,
|
||||
}
|
||||
|
||||
var ln net.Listener
|
||||
ln, err = net.Listen("tcp", server.Addr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var proxyListener net.Listener
|
||||
if conf.Server.ProxyProto {
|
||||
proxyListener = &proxyproto.Listener{
|
||||
Listener: ln,
|
||||
ReadHeaderTimeout: 10 * time.Second,
|
||||
}
|
||||
} else {
|
||||
proxyListener = ln
|
||||
}
|
||||
|
||||
tlsListener := tls.NewListener(proxyListener, tlsConfig)
|
||||
defer func() {
|
||||
_ = tlsListener.Close()
|
||||
}()
|
||||
|
||||
err = server.Serve(tlsListener)
|
||||
|
||||
case "fcgi":
|
||||
err = fcgi.Serve(nil, m)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
@ -213,7 +213,7 @@ func Init(customConf string) error {
|
|||
if err != nil {
|
||||
return errors.Wrapf(err, "parse mail address %q", Email.From)
|
||||
}
|
||||
Email.FromEmail = parsed.Address
|
||||
Email.FromEmail = parsed
|
||||
}
|
||||
|
||||
// ***********************************
|
||||
|
@ -375,8 +375,6 @@ func Init(customConf string) error {
|
|||
return errors.Wrap(err, "mapping [ui] section")
|
||||
} else if err = File.Section("prometheus").MapTo(&Prometheus); err != nil {
|
||||
return errors.Wrap(err, "mapping [prometheus] section")
|
||||
} else if err = File.Section("other").MapTo(&Other); err != nil {
|
||||
return errors.Wrap(err, "mapping [other] section")
|
||||
}
|
||||
|
||||
HasRobotsTxt = osutil.IsFile(filepath.Join(CustomDir(), "robots.txt"))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
import (
|
||||
"net/mail"
|
||||
"net/url"
|
||||
"os"
|
||||
"time"
|
||||
|
@ -68,7 +69,7 @@ var (
|
|||
AddPlainTextAlt bool
|
||||
|
||||
// Derived from other static values
|
||||
FromEmail string `ini:"-"` // Parsed email address of From without person's name.
|
||||
FromEmail *mail.Address `ini:"-"` // Parsed email address of From without person's name.
|
||||
}
|
||||
|
||||
// User settings
|
||||
|
@ -157,7 +158,8 @@ var (
|
|||
|
||||
// Admin settings
|
||||
Admin struct {
|
||||
DisableRegularOrgCreation bool
|
||||
DisableRegularOrgCreation bool `ini:"DISABLE_REGULAR_ORG_CREATION"`
|
||||
DisableRegularExploreUser bool `ini:"DISABLE_REGULAR_EXPLORE_USER"`
|
||||
}
|
||||
|
||||
// Cron tasks
|
||||
|
@ -220,12 +222,6 @@ var (
|
|||
BasicAuthPassword string
|
||||
}
|
||||
|
||||
// Other settings
|
||||
Other struct {
|
||||
ShowFooterBranding bool
|
||||
ShowFooterTemplateLoadTime bool
|
||||
}
|
||||
|
||||
// Global setting
|
||||
HasRobotsTxt bool
|
||||
)
|
||||
|
@ -260,6 +256,7 @@ var Auth AuthOpts
|
|||
|
||||
type ServerOpts struct {
|
||||
ExternalURL string `ini:"EXTERNAL_URL"`
|
||||
ProxyProto bool `ini:"PROXY_PROTO"`
|
||||
Domain string
|
||||
Protocol string
|
||||
HTTPAddr string `ini:"HTTP_ADDR"`
|
||||
|
@ -312,17 +309,19 @@ type SSHOpts struct {
|
|||
var SSH SSHOpts
|
||||
|
||||
type RepositoryOpts struct {
|
||||
Root string
|
||||
ScriptType string
|
||||
ANSICharset string `ini:"ANSI_CHARSET"`
|
||||
ForcePrivate bool
|
||||
MaxCreationLimit int
|
||||
PreferredLicenses []string
|
||||
DisableHTTPGit bool `ini:"DISABLE_HTTP_GIT"`
|
||||
EnableLocalPathMigration bool
|
||||
EnableRawFileRenderMode bool
|
||||
CommitsFetchConcurrency int
|
||||
DefaultBranch string
|
||||
Root string
|
||||
ScriptType string
|
||||
ANSICharset string `ini:"ANSI_CHARSET"`
|
||||
ForcePrivate bool
|
||||
AdminNotCreationLimit bool `ini:"ADMIN_NOT_CREATION_LIMIT"`
|
||||
OrganizationNotCreationLimit bool `ini:"ORGANIZATION_NOT_CREATION_LIMIT"`
|
||||
MaxCreationLimit int
|
||||
PreferredLicenses []string
|
||||
DisableHTTPGit bool `ini:"DISABLE_HTTP_GIT"`
|
||||
EnableLocalPathMigration bool
|
||||
EnableRawFileRenderMode bool
|
||||
CommitsFetchConcurrency int
|
||||
DefaultBranch string
|
||||
|
||||
// Repository editor settings
|
||||
Editor struct {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ RUN_MODE=test
|
|||
[server]
|
||||
EXTERNAL_URL=http://localhost:3080/
|
||||
DOMAIN=localhost
|
||||
PROXY_PROTO=true
|
||||
PROTOCOL=http
|
||||
HTTP_ADDR=0.0.0.0
|
||||
HTTP_PORT=3000
|
||||
|
@ -39,6 +40,9 @@ ROOT=/tmp/gogs-repositories
|
|||
SCRIPT_TYPE=bash
|
||||
ANSI_CHARSET=
|
||||
FORCE_PRIVATE=false
|
||||
ADMIN_NOT_CREATION_LIMIT=true
|
||||
ONLY_ADMIN_CAN_CREATE_ORGANIZATION=true
|
||||
ORGANIZATION_NOT_CREATION_LIMIT=true
|
||||
MAX_CREATION_LIMIT=-1
|
||||
PREFERRED_LICENSES=Apache License 2.0,MIT License
|
||||
DISABLE_HTTP_GIT=false
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package conf
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
@ -125,7 +125,7 @@ type AuthStore interface {
|
|||
// allowed as a username, or database.ErrUserAlreadyExist when a user with same
|
||||
// name already exists, or database.ErrEmailAlreadyUsed if the email has been
|
||||
// verified by another user.
|
||||
CreateUser(ctx context.Context, username, email string, opts database.CreateUserOptions) (*database.User, error)
|
||||
CreateUser(ctx context.Context, username, email, publicEmail string, opts database.CreateUserOptions) (*database.User, error)
|
||||
// AuthenticateUser validates username and password via given login source ID.
|
||||
// It returns database.ErrUserNotExist when the user was not found.
|
||||
//
|
||||
|
@ -220,10 +220,12 @@ func authenticatedUser(store AuthStore, ctx *macaron.Context, sess session.Store
|
|||
|
||||
// Check if enabled auto-registration.
|
||||
if conf.Auth.EnableReverseProxyAutoRegistration {
|
||||
email := gouuid.NewV4().String() + "@fake.localhost"
|
||||
user, err = store.CreateUser(
|
||||
ctx.Req.Context(),
|
||||
webAuthUser,
|
||||
gouuid.NewV4().String()+"@localhost",
|
||||
email,
|
||||
"",
|
||||
database.CreateUserOptions{
|
||||
Activated: true,
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
@ -169,6 +169,22 @@ func (c *Context) RenderWithErr(msg, tpl string, f any) {
|
|||
c.HTML(http.StatusOK, tpl)
|
||||
}
|
||||
|
||||
func (c *Context) Wait(err error, msg string, refresh bool) {
|
||||
c.Flash.ErrorMsg = msg
|
||||
c.Data["Refresh"] = refresh
|
||||
c.Data["Flash"] = c.Flash.ErrorMsg
|
||||
|
||||
if err != nil {
|
||||
log.ErrorDepth(4, "%s: %v", msg, err)
|
||||
c.Data["ErrorMsg"] = err.Error()
|
||||
} else {
|
||||
c.Data["ErrorMsg"] = ""
|
||||
}
|
||||
|
||||
c.Title("status.page_not_found")
|
||||
c.HTML(http.StatusOK, "status/wait")
|
||||
}
|
||||
|
||||
// NotFound renders the 404 page.
|
||||
func (c *Context) NotFound() {
|
||||
c.Title("status.page_not_found")
|
||||
|
@ -269,6 +285,9 @@ func Contexter(store Store) macaron.Handler {
|
|||
c.Data["LoggedUserID"] = c.User.ID
|
||||
c.Data["LoggedUserName"] = c.User.Name
|
||||
c.Data["IsAdmin"] = c.User.IsAdmin
|
||||
c.Data["IsCanCreate"] = c.User.CanCreateRepo() || c.User.CanCreateOrganization()
|
||||
c.Data["IsCanCreateRepo"] = c.User.CanCreateRepo()
|
||||
c.Data["IsCanCreateOrg"] = c.User.CanCreateOrganization()
|
||||
} else {
|
||||
c.Data["LoggedUserID"] = 0
|
||||
c.Data["LoggedUserName"] = ""
|
||||
|
@ -292,7 +311,6 @@ func Contexter(store Store) macaron.Handler {
|
|||
log.Trace("CSRF Token: %v", c.Data["CSRFToken"])
|
||||
|
||||
c.Data["ShowRegistrationButton"] = !conf.Auth.DisableRegistration
|
||||
c.Data["ShowFooterBranding"] = conf.Other.ShowFooterBranding
|
||||
|
||||
c.renderNoticeBanner()
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2019 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
@ -229,7 +229,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
|||
if repo.IsMirror {
|
||||
c.Repo.Mirror, err = database.GetMirrorByRepoID(repo.ID)
|
||||
if err != nil {
|
||||
c.Error(err, "get mirror by repository ID")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Data["MirrorEnablePrune"] = c.Repo.Mirror.EnablePrune
|
||||
|
@ -239,14 +239,14 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
|||
|
||||
gitRepo, err := git.Open(database.RepoPath(ownerName, repoName))
|
||||
if err != nil {
|
||||
c.Error(err, "open repository")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Repo.GitRepo = gitRepo
|
||||
|
||||
tags, err := c.Repo.GitRepo.Tags()
|
||||
if err != nil {
|
||||
c.Error(err, "get tags")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Data["Tags"] = tags
|
||||
|
@ -277,7 +277,7 @@ func RepoAssignment(pages ...bool) macaron.Handler {
|
|||
c.Data["TagName"] = c.Repo.TagName
|
||||
branches, err := c.Repo.GitRepo.Branches()
|
||||
if err != nil {
|
||||
c.Error(err, "get branches")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Data["Branches"] = branches
|
||||
|
@ -317,7 +317,7 @@ func RepoRef() macaron.Handler {
|
|||
repoPath := database.RepoPath(c.Repo.Owner.Name, c.Repo.Repository.Name)
|
||||
c.Repo.GitRepo, err = git.Open(repoPath)
|
||||
if err != nil {
|
||||
c.Error(err, "open repository")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -328,14 +328,14 @@ func RepoRef() macaron.Handler {
|
|||
if !c.Repo.GitRepo.HasBranch(refName) {
|
||||
branches, err := c.Repo.GitRepo.Branches()
|
||||
if err != nil {
|
||||
c.Error(err, "get branches")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
refName = branches[0]
|
||||
}
|
||||
c.Repo.Commit, err = c.Repo.GitRepo.BranchCommit(refName)
|
||||
if err != nil {
|
||||
c.Error(err, "get branch commit")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Repo.CommitID = c.Repo.Commit.ID.String()
|
||||
|
@ -366,7 +366,7 @@ func RepoRef() macaron.Handler {
|
|||
|
||||
c.Repo.Commit, err = c.Repo.GitRepo.BranchCommit(refName)
|
||||
if err != nil {
|
||||
c.Error(err, "get branch commit")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Repo.CommitID = c.Repo.Commit.ID.String()
|
||||
|
@ -375,7 +375,7 @@ func RepoRef() macaron.Handler {
|
|||
c.Repo.IsViewTag = true
|
||||
c.Repo.Commit, err = c.Repo.GitRepo.TagCommit(refName)
|
||||
if err != nil {
|
||||
c.Error(err, "get tag commit")
|
||||
c.Wait(err, "The Git repository has not been loaded yet, please refresh and try again later!", true)
|
||||
return
|
||||
}
|
||||
c.Repo.CommitID = c.Repo.Commit.ID.String()
|
||||
|
|
|
@ -28,7 +28,7 @@ type Store interface {
|
|||
// allowed as a username, or database.ErrUserAlreadyExist when a user with same
|
||||
// name already exists, or database.ErrEmailAlreadyUsed if the email has been
|
||||
// verified by another user.
|
||||
CreateUser(ctx context.Context, username, email string, opts database.CreateUserOptions) (*database.User, error)
|
||||
CreateUser(ctx context.Context, username, email, publicEmail string, opts database.CreateUserOptions) (*database.User, error)
|
||||
// AuthenticateUser validates username and password via given login source ID.
|
||||
// It returns database.ErrUserNotExist when the user was not found.
|
||||
//
|
||||
|
@ -67,7 +67,7 @@ func (*store) GetUserByUsername(ctx context.Context, username string) (*database
|
|||
return database.Handle.Users().GetByUsername(ctx, username)
|
||||
}
|
||||
|
||||
func (*store) CreateUser(ctx context.Context, username, email string, opts database.CreateUserOptions) (*database.User, error) {
|
||||
func (*store) CreateUser(ctx context.Context, username, email, publicEmail string, opts database.CreateUserOptions) (*database.User, error) {
|
||||
return database.Handle.Users().Create(ctx, username, email, opts)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package context
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cron
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cryptoutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cryptoutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cryptoutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cryptoutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cryptoutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package cryptoutil
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2022 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2015 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package errors
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package errors
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
@ -15,7 +15,6 @@ import (
|
|||
"gogs.io/gogs/internal/conf"
|
||||
"gogs.io/gogs/internal/email"
|
||||
"gogs.io/gogs/internal/markup"
|
||||
"gogs.io/gogs/internal/userutil"
|
||||
)
|
||||
|
||||
func (issue *Issue) MailSubject() string {
|
||||
|
@ -39,14 +38,8 @@ func (this mailerUser) Email() string {
|
|||
return this.user.Email
|
||||
}
|
||||
|
||||
func (this mailerUser) GenerateEmailActivateCode(email string) string {
|
||||
return userutil.GenerateActivateCode(
|
||||
this.user.ID,
|
||||
email,
|
||||
this.user.Name,
|
||||
this.user.Password,
|
||||
this.user.Rands,
|
||||
)
|
||||
func (this mailerUser) PublicEmail() string {
|
||||
return this.user.PublicEmail
|
||||
}
|
||||
|
||||
func NewMailerUser(u *User) email.User {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2020 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -52,17 +52,23 @@ var migrations = []Migration{
|
|||
// v18 -> v19:v0.11.55
|
||||
// NewMigration("clean unlinked webhook and hook_tasks", cleanUnlinkedWebhookAndHookTasks),
|
||||
|
||||
// v19 -> v20:v0.13.0
|
||||
// v19 -> v20:v0.13.0(Gogs)
|
||||
NewMigration("migrate access tokens to store SHA56", migrateAccessTokenToSHA256),
|
||||
// v20 -> v21:v0.13.0
|
||||
// v20 -> v21:v0.13.0(Gogs)
|
||||
NewMigration("add index to action.user_id", addIndexToActionUserID),
|
||||
// v21 -> v22:v0.13.0
|
||||
// v21 -> v22:v0.13.0(Gogs)
|
||||
//
|
||||
// NOTE: There was a bug in calculating the value of the `version.version`
|
||||
// column after a migration is done, thus some instances are on v21 but some are
|
||||
// on v22. Let's make a noop v22 to make sure every instance will not miss a
|
||||
// real future migration.
|
||||
NewMigration("noop", func(*gorm.DB) error { return nil }),
|
||||
// v22 -> v23:v0.14.0(Gogs)
|
||||
NewMigration("add user.public_email column", addUserPublicEmail),
|
||||
// v23 -> v24:v0.14.0(Gogs)
|
||||
NewMigration("add user.local_email column", addUserLocalEmail),
|
||||
// v24 -> v25:v0.14.0(Gogs) v24:v1.0.0(Gogs)
|
||||
NewMigration("insert user primary to database", insertUserPrimaryEmail),
|
||||
}
|
||||
|
||||
var errMigrationSkipped = errors.New("the migration has been skipped")
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func addUserPublicEmail(db *gorm.DB) error {
|
||||
type User struct {
|
||||
PublicEmail string // 不能使用NOT NULL
|
||||
}
|
||||
|
||||
type UserNotNull struct {
|
||||
PublicEmail string `xorm:"NOT NULL" gorm:"not null"`
|
||||
}
|
||||
|
||||
if db.Migrator().HasColumn(&User{}, "PublicEmail") {
|
||||
return errMigrationSkipped
|
||||
}
|
||||
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
err := tx.Migrator().AddColumn(&User{}, "PublicEmail")
|
||||
if err != nil {
|
||||
return fmt.Errorf("add column user.public_email error: %s", err.Error())
|
||||
}
|
||||
|
||||
err = tx.Exec("UPDATE `user` SET `public_email` = `email` WHERE `public_email` = '' AND `type` = 0").Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("update public_email error: %s", err.Error())
|
||||
}
|
||||
|
||||
err = tx.Debug().Migrator().AlterColumn(&UserNotNull{}, "PublicEmail")
|
||||
if err != nil {
|
||||
return fmt.Errorf("alter column user.public_email error: %s", err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
gouuid "github.com/satori/go.uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func addUserLocalEmail(db *gorm.DB) error {
|
||||
type User struct {
|
||||
ID int64 `gorm:"primaryKey"`
|
||||
LocalEmail string
|
||||
}
|
||||
|
||||
type UserNotNULL struct {
|
||||
ID int64 `gorm:"primaryKey"`
|
||||
LocalEmail string
|
||||
}
|
||||
|
||||
if db.Migrator().HasColumn(&User{}, "LocalEmail") {
|
||||
return errMigrationSkipped
|
||||
}
|
||||
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
err := tx.Migrator().AddColumn(&User{}, "LocalEmail")
|
||||
if err != nil {
|
||||
return fmt.Errorf("add column user.local_email error: %s", err.Error())
|
||||
}
|
||||
|
||||
const limit = 100
|
||||
for {
|
||||
var res []User
|
||||
err := tx.Table("user").Where("type = ?", 0).Where("local_email = ''").Limit(limit).Find(&res).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("query user error: %s", err.Error())
|
||||
}
|
||||
|
||||
for _, r := range res {
|
||||
r.LocalEmail = gouuid.NewV4().String() + "@fake.localhost"
|
||||
err = tx.Save(&r).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("save column user.local_email error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) < limit {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
err = tx.Migrator().AlterColumn(&User{}, "LocalEmail")
|
||||
if err != nil {
|
||||
return fmt.Errorf("alter column user.local_email error: %s", err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package migrations
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func insertUserPrimaryEmail(db *gorm.DB) error {
|
||||
type EmailAddress struct {
|
||||
ID int64 `gorm:"primaryKey"`
|
||||
UserID int64 `xorm:"uid INDEX NOT NULL" gorm:"column:uid;index;uniqueIndex:email_address_user_email_unique;not null"`
|
||||
Email string `xorm:"UNIQUE NOT NULL" gorm:"uniqueIndex:email_address_user_email_unique;not null;size:254"`
|
||||
IsActivated bool `gorm:"not null;default:FALSE"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int64 `gorm:"primaryKey"`
|
||||
Email string `xorm:"NOT NULL" gorm:"not null"`
|
||||
IsActive bool // Activate primary email
|
||||
}
|
||||
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
const limit = 100
|
||||
var offset = 0
|
||||
for {
|
||||
var res []User
|
||||
err := tx.Table("user").Where("type = ?", 0).Offset(offset).Limit(limit).Find(&res).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("query user error: %s", err.Error())
|
||||
}
|
||||
|
||||
for _, r := range res {
|
||||
record := &EmailAddress{
|
||||
UserID: r.ID,
|
||||
Email: r.Email,
|
||||
IsActivated: r.IsActive,
|
||||
}
|
||||
err := tx.Table("email_address").Where("uid = ? AND email = ?", record.UserID, record.Email).FirstOrCreate(record).Error
|
||||
if err != nil {
|
||||
return fmt.Errorf("insert email error: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
if len(res) < limit {
|
||||
break
|
||||
} else {
|
||||
offset += len(res)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2016 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2017 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2023 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2023 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// license that can be found in the LICENSE.gogs file.
|
||||
|
||||
package database
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue