SSL enable config option

This commit is contained in:
Unknown 2014-03-23 08:40:40 -04:00
parent 97e82a0ff6
commit 97debac185
12 changed files with 22 additions and 9 deletions

View file

@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language
![Demo](http://gowalker.org/public/gogs_demo.gif) ![Demo](http://gowalker.org/public/gogs_demo.gif)
##### Current version: 0.1.6 Alpha ##### Current version: 0.1.7 Alpha
#### Other language version #### Other language version
@ -27,7 +27,7 @@ More importantly, Gogs only needs one binary to setup your own project hosting o
## Features ## Features
- Activity timeline - Activity timeline
- SSH protocol support. - SSH/HTTPS protocol support.
- Register/delete account. - Register/delete account.
- Create/delete/watch public repository. - Create/delete/watch public repository.
- User profile page. - User profile page.

View file

@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
![Demo](http://gowalker.org/public/gogs_demo.gif) ![Demo](http://gowalker.org/public/gogs_demo.gif)
##### 当前版本0.1.6 Alpha ##### 当前版本0.1.7 Alpha
## 开发目的 ## 开发目的
@ -23,7 +23,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
## 功能特性 ## 功能特性
- 活动时间线 - 活动时间线
- SSH 协议支持 - SSH/HTTPS 协议支持
- 注册/删除用户 - 注册/删除用户
- 创建/删除/关注公开仓库 - 创建/删除/关注公开仓库
- 用户个人信息页面 - 用户个人信息页面

View file

@ -32,6 +32,8 @@ PATH = data/gogs.db
[admin] [admin]
[security] [security]
; Use HTTPS to clone repository, otherwise use HTTP.
ENABLE_HTTPS_CLONE = false
; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! ; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!!
SECRET_KEY = !#@FDEWREWR&*( SECRET_KEY = !#@FDEWREWR&*(
; Auto-login remember days ; Auto-login remember days

View file

@ -20,7 +20,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition. // Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true const go12tag = true
const APP_VER = "0.1.6.0323.1" const APP_VER = "0.1.7.0323.1"
func init() { func init() {
base.AppVer = APP_VER base.AppVer = APP_VER

View file

@ -208,7 +208,7 @@ func UpdateUser(user *User) (err error) {
user.Website = user.Website[:255] user.Website = user.Website[:255]
} }
_, err = orm.Id(user.Id).UseBool().Cols("website", "location").Update(user) _, err = orm.Id(user.Id).UseBool().Cols("website", "location", "is_active", "is_admin").Update(user)
return err return err
} }

View file

@ -38,6 +38,8 @@ var (
RunUser string RunUser string
RepoRootPath string RepoRootPath string
EnableHttpsClone bool
LogInRememberDays int LogInRememberDays int
CookieUserName string CookieUserName string
CookieRememberName string CookieRememberName string
@ -260,6 +262,8 @@ func NewConfigContext() {
SecretKey = Cfg.MustValue("security", "SECRET_KEY") SecretKey = Cfg.MustValue("security", "SECRET_KEY")
RunUser = Cfg.MustValue("", "RUN_USER") RunUser = Cfg.MustValue("", "RUN_USER")
EnableHttpsClone = Cfg.MustBool("security", "ENABLE_HTTPS_CLONE", false)
LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS") LogInRememberDays = Cfg.MustInt("security", "LOGIN_REMEMBER_DAYS")
CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME") CookieUserName = Cfg.MustValue("security", "COOKIE_USERNAME")
CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME") CookieRememberName = Cfg.MustValue("security", "COOKIE_REMEMBER_NAME")

View file

@ -519,7 +519,7 @@ func ActionDesc(act Actioner, avatarLink string) string {
buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n") buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, avatarLink, actUserName, repoName, commit[0], commit[0][:7], commit[1]) + "\n")
} }
if push.Len > 3 { if push.Len > 3 {
buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits">%d other commits >></a></div>`, actUserName, repoName, push.Len)) buf.WriteString(fmt.Sprintf(`<div><a href="/%s/%s/commits/%s">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
} }
return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, branch, branch, actUserName, repoName, actUserName, repoName, return fmt.Sprintf(TPL_COMMIT_REPO, actUserName, actUserName, actUserName, repoName, branch, branch, actUserName, repoName, actUserName, repoName,
buf.String()) buf.String())

View file

@ -69,8 +69,12 @@ func RepoAssignment(redirect bool) martini.Handler {
ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id) ctx.Repo.IsWatching = models.IsWatching(ctx.User.Id, repo.Id)
} }
ctx.Repo.Repository = repo ctx.Repo.Repository = repo
scheme := "http"
if base.EnableHttpsClone {
scheme = "https"
}
ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName) ctx.Repo.CloneLink.SSH = fmt.Sprintf("git@%s:%s/%s.git", base.Domain, user.LowerName, repo.LowerName)
ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("https://%s/%s/%s.git", base.Domain, user.LowerName, repo.LowerName) ctx.Repo.CloneLink.HTTPS = fmt.Sprintf("%s://%s/%s/%s.git", scheme, base.Domain, user.LowerName, repo.LowerName)
ctx.Data["IsRepositoryValid"] = true ctx.Data["IsRepositoryValid"] = true
ctx.Data["Repository"] = repo ctx.Data["Repository"] = repo

View file

@ -141,6 +141,7 @@ func Config(ctx *middleware.Context) {
ctx.Data["Domain"] = base.Domain ctx.Data["Domain"] = base.Domain
ctx.Data["RunUser"] = base.RunUser ctx.Data["RunUser"] = base.RunUser
ctx.Data["RunMode"] = strings.Title(martini.Env) ctx.Data["RunMode"] = strings.Title(martini.Env)
ctx.Data["EnableHttpsClone"] = base.EnableHttpsClone
ctx.Data["RepoRootPath"] = base.RepoRootPath ctx.Data["RepoRootPath"] = base.RepoRootPath
ctx.Data["Service"] = base.Service ctx.Data["Service"] = base.Service

View file

@ -26,6 +26,6 @@ func Help(ctx *middleware.Context) {
func NotFound(ctx *middleware.Context) { func NotFound(ctx *middleware.Context) {
ctx.Data["PageIsNotFound"] = true ctx.Data["PageIsNotFound"] = true
ctx.Data["Title"] = 404 ctx.Data["Title"] = "Page Not Found"
ctx.Handle(404, "home.NotFound", nil) ctx.Handle(404, "home.NotFound", nil)
} }

View file

@ -17,6 +17,7 @@
<div><b>Run User:</b> {{.RunUser}}</div> <div><b>Run User:</b> {{.RunUser}}</div>
<div><b>Run Mode:</b> {{.RunMode}}</div> <div><b>Run Mode:</b> {{.RunMode}}</div>
<hr/> <hr/>
<div><b>Enable HTTPS Clone</b> <i class="fa fa{{if .EnableHttpsClone}}-check{{end}}-square-o"></i></div>
<div><b>Repository Root Path:</b> {{.RepoRootPath}}</div> <div><b>Repository Root Path:</b> {{.RepoRootPath}}</div>
</div> </div>
</div> </div>

View file

@ -4,5 +4,6 @@
<p style="margin-top: 80px"><img src="/img/404.png" alt="404"/></p> <p style="margin-top: 80px"><img src="/img/404.png" alt="404"/></p>
<hr/> <hr/>
<p>Application Version: {{AppVer}}</p> <p>Application Version: {{AppVer}}</p>
<p>If you think it is an error, please open an issue on <a href="https://github.com/gogits/gogs/issues/new">GitHub</a>.</p>
</div> </div>
{{template "base/footer" .}} {{template "base/footer" .}}