From 948e5ad1c5c6e0af611a467563717149777d4c80 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 1 Apr 2016 04:42:13 -0700 Subject: [PATCH 01/13] change register to api/users --- api/user.go | 88 +++++++++++++++++++++++++++++++++++++++++++++++ routers/router.go | 3 +- 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/api/user.go b/api/user.go index 482ab319b..985edf1cb 100644 --- a/api/user.go +++ b/api/user.go @@ -16,8 +16,10 @@ package api import ( + "fmt" "net/http" "strconv" + "strings" "github.com/vmware/harbor/dao" "github.com/vmware/harbor/models" @@ -31,9 +33,18 @@ type UserAPI struct { userID int } +const userNameMaxLen int = 20 +const passwordMaxLen int = 20 +const realNameMaxLen int = 20 +const commentsMaxLen int = 20 + // Prepare validates the URL and parms func (ua *UserAPI) Prepare() { + if ua.Ctx.Input.IsPost() { + return + } + ua.currentUserID = ua.ValidateUser() id := ua.Ctx.Input.Param(":id") if id == "current" { @@ -117,6 +128,44 @@ func (ua *UserAPI) Put() { //currently only for toggle admin, so no request body dao.ToggleUserAdminRole(userQuery) } +// Post ... +func (ua *UserAPI) Post() { + username := strings.TrimSpace(ua.GetString("username")) + password := strings.TrimSpace(ua.GetString("password")) + email := strings.TrimSpace(ua.GetString("email")) + realname := strings.TrimSpace(ua.GetString("realname")) + comment := strings.TrimSpace(ua.GetString("comment")) + + err := validateUserReq(ua) + if err != nil { + log.Errorf("Invalid user request, error: %v", err) + ua.RenderError(http.StatusBadRequest, "Invalid request for creating user") + return + } + + user := models.User{Username: username, Email: email, Realname: realname, Password: password, Comment: comment} + exist, err := dao.UserExists(user, "email") + if err != nil { + log.Errorf("Error occurred in UserExists:", err) + } + if exist { + ua.RenderError(http.StatusConflict, "") + return + } + + userID, err := dao.Register(user) + if err != nil { + log.Errorf("Error occurred in Register:", err) + ua.RenderError(http.StatusInternalServerError, "Internal error.") + return + } + if userID == 0 { + log.Errorf("Error happened on registing new user in db.") + ua.RenderError(http.StatusInternalServerError, "Internal error.") + } + +} + // Delete ... func (ua *UserAPI) Delete() { exist, err := dao.IsAdminRole(ua.currentUserID) @@ -136,3 +185,42 @@ func (ua *UserAPI) Delete() { return } } + +func validateUserReq(ua *UserAPI) error { + userName := ua.GetString("username") + if len(userName) == 0 { + return fmt.Errorf("User name can not be empty") + } + if len(userName) > userNameMaxLen { + return fmt.Errorf("User name is too long") + } + + password := ua.GetString("password") + if len(password) == 0 { + return fmt.Errorf("Password can not be empty") + } + if len(password) >= passwordMaxLen { + return fmt.Errorf("Password can is too long") + } + + realName := ua.GetString("realname") + if len(realName) == 0 { + return fmt.Errorf("Real name can not be empty") + } + if len(realName) >= realNameMaxLen { + return fmt.Errorf("Real name is too long") + } + + email := ua.GetString("email") + if len(email) == 0 { + return fmt.Errorf("Email can not be empty") + } + + comments := ua.GetString("comment") + if len(comments) != 0 { + if len(comments) >= commentsMaxLen { + return fmt.Errorf("Comments is too long") + } + } + return nil +} diff --git a/routers/router.go b/routers/router.go index 764a3c7e6..e8dab001f 100644 --- a/routers/router.go +++ b/routers/router.go @@ -32,7 +32,7 @@ func init() { beego.Router("/login", &controllers.CommonController{}, "post:Login") beego.Router("/logout", &controllers.CommonController{}, "get:Logout") beego.Router("/language", &controllers.CommonController{}, "get:SwitchLanguage") - beego.Router("/signUp", &controllers.CommonController{}, "post:SignUp") + // beego.Router("/signUp", &controllers.CommonController{}, "post:SignUp") beego.Router("/userExists", &controllers.CommonController{}, "post:UserExists") beego.Router("/reset", &controllers.CommonController{}, "post:ResetPassword") beego.Router("/sendEmail", &controllers.CommonController{}, "get:SendEmail") @@ -55,6 +55,7 @@ func init() { beego.Router("/api/projects/:pid/members/?:mid", &api.ProjectMemberAPI{}) beego.Router("/api/projects/?:id", &api.ProjectAPI{}) beego.Router("/api/projects/:id/logs/filter", &api.ProjectAPI{}, "post:FilterAccessLog") + beego.Router("/api/users", &api.UserAPI{}) beego.Router("/api/users/?:id", &api.UserAPI{}) beego.Router("/api/repositories", &api.RepositoryAPI{}) beego.Router("/api/repositories/tags", &api.RepositoryAPI{}, "get:GetTags") From fca2838b332851d322c34cea0658677154415b7c Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 1 Apr 2016 04:56:43 -0700 Subject: [PATCH 02/13] update api/users --- static/resources/js/register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/resources/js/register.js b/static/resources/js/register.js index cbd133671..7f0b21d4a 100644 --- a/static/resources/js/register.js +++ b/static/resources/js/register.js @@ -37,7 +37,7 @@ jQuery(function(){ var realname = $.trim($("#Realname").val()); var comment = $.trim($("#Comment").val()); $.ajax({ - url : '/signUp', + url : "/api/users", data:{username: username, password: password, realname: realname, comment: comment, email: email}, type: "POST", beforeSend: function(e){ From be0d71d61db9dce7b31a45be7d92fa70623659de Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 5 Apr 2016 02:30:23 -0700 Subject: [PATCH 03/13] update /api/users to parse json data --- api/user.go | 37 ++++++++++++++++----------------- static/resources/js/register.js | 5 +++-- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/api/user.go b/api/user.go index 985edf1cb..16decb5f0 100644 --- a/api/user.go +++ b/api/user.go @@ -19,7 +19,7 @@ import ( "fmt" "net/http" "strconv" - "strings" + // "strings" "github.com/vmware/harbor/dao" "github.com/vmware/harbor/models" @@ -33,6 +33,14 @@ type UserAPI struct { userID int } +type userReq struct { + UserName string `json:"username"` + Password string `json:"password"` + Realname string `json:"realname"` + Email string `json:"email"` + Comment string `json:"comment"` +} + const userNameMaxLen int = 20 const passwordMaxLen int = 20 const realNameMaxLen int = 20 @@ -130,20 +138,17 @@ func (ua *UserAPI) Put() { //currently only for toggle admin, so no request body // Post ... func (ua *UserAPI) Post() { - username := strings.TrimSpace(ua.GetString("username")) - password := strings.TrimSpace(ua.GetString("password")) - email := strings.TrimSpace(ua.GetString("email")) - realname := strings.TrimSpace(ua.GetString("realname")) - comment := strings.TrimSpace(ua.GetString("comment")) + var req userReq + ua.DecodeJSONReq(&req) - err := validateUserReq(ua) + err := validateUserReq(req) if err != nil { log.Errorf("Invalid user request, error: %v", err) ua.RenderError(http.StatusBadRequest, "Invalid request for creating user") return } - user := models.User{Username: username, Email: email, Realname: realname, Password: password, Comment: comment} + user := models.User{Username: req.UserName, Email: req.Email, Realname: req.Realname, Password: req.Password, Comment: req.Comment} exist, err := dao.UserExists(user, "email") if err != nil { log.Errorf("Error occurred in UserExists:", err) @@ -186,8 +191,8 @@ func (ua *UserAPI) Delete() { } } -func validateUserReq(ua *UserAPI) error { - userName := ua.GetString("username") +func validateUserReq(req userReq) error { + userName := req.UserName if len(userName) == 0 { return fmt.Errorf("User name can not be empty") } @@ -195,7 +200,7 @@ func validateUserReq(ua *UserAPI) error { return fmt.Errorf("User name is too long") } - password := ua.GetString("password") + password := req.Password if len(password) == 0 { return fmt.Errorf("Password can not be empty") } @@ -203,7 +208,7 @@ func validateUserReq(ua *UserAPI) error { return fmt.Errorf("Password can is too long") } - realName := ua.GetString("realname") + realName := req.Realname if len(realName) == 0 { return fmt.Errorf("Real name can not be empty") } @@ -211,16 +216,10 @@ func validateUserReq(ua *UserAPI) error { return fmt.Errorf("Real name is too long") } - email := ua.GetString("email") + email := req.Email if len(email) == 0 { return fmt.Errorf("Email can not be empty") } - comments := ua.GetString("comment") - if len(comments) != 0 { - if len(comments) >= commentsMaxLen { - return fmt.Errorf("Comments is too long") - } - } return nil } diff --git a/static/resources/js/register.js b/static/resources/js/register.js index 7f0b21d4a..7c4793d35 100644 --- a/static/resources/js/register.js +++ b/static/resources/js/register.js @@ -38,8 +38,9 @@ jQuery(function(){ var comment = $.trim($("#Comment").val()); $.ajax({ url : "/api/users", - data:{username: username, password: password, realname: realname, comment: comment, email: email}, + data: JSON.stringify({username: username, password: password, realname: realname, comment: comment, email: email}), type: "POST", + contentType: "application/json; charset=UTF-8", beforeSend: function(e){ $("#btnPageSignUp").prop("disabled", true); }, @@ -55,7 +56,7 @@ jQuery(function(){ }); } }, - error:function(jqxhr, status, error){ + error:function(xhr, status, error){ $("#dlgModal") .dialogModal({ "title": i18n.getMessage("title_sign_up"), From fb918578992af0fe60cebe45082d3b32c411d536 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 5 Apr 2016 02:35:00 -0700 Subject: [PATCH 04/13] remove disabled import --- api/user.go | 1 - 1 file changed, 1 deletion(-) diff --git a/api/user.go b/api/user.go index 16decb5f0..d20ef9363 100644 --- a/api/user.go +++ b/api/user.go @@ -19,7 +19,6 @@ import ( "fmt" "net/http" "strconv" - // "strings" "github.com/vmware/harbor/dao" "github.com/vmware/harbor/models" From f54b942fd765713dc12c831111b59b85cfc03ea4 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 5 Apr 2016 02:45:47 -0700 Subject: [PATCH 05/13] fix log issue --- api/user.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/user.go b/api/user.go index d20ef9363..4a8101ba8 100644 --- a/api/user.go +++ b/api/user.go @@ -150,7 +150,7 @@ func (ua *UserAPI) Post() { user := models.User{Username: req.UserName, Email: req.Email, Realname: req.Realname, Password: req.Password, Comment: req.Comment} exist, err := dao.UserExists(user, "email") if err != nil { - log.Errorf("Error occurred in UserExists:", err) + log.Errorf("Error occurred in UserExists: %v", err) } if exist { ua.RenderError(http.StatusConflict, "") @@ -159,7 +159,7 @@ func (ua *UserAPI) Post() { userID, err := dao.Register(user) if err != nil { - log.Errorf("Error occurred in Register:", err) + log.Errorf("Error occurred in Register: %v", err) ua.RenderError(http.StatusInternalServerError, "Internal error.") return } From 5139952cb4cf4a92da87e1a18b7a3817be11f402 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 5 Apr 2016 03:01:04 -0700 Subject: [PATCH 06/13] update js error xhr to jQery xhr --- static/resources/js/register.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/resources/js/register.js b/static/resources/js/register.js index 7c4793d35..72d28de86 100644 --- a/static/resources/js/register.js +++ b/static/resources/js/register.js @@ -56,7 +56,7 @@ jQuery(function(){ }); } }, - error:function(xhr, status, error){ + error:function(jqxhr, status, error){ $("#dlgModal") .dialogModal({ "title": i18n.getMessage("title_sign_up"), From b76acb638199fb1126b0c95ce4391e291bbda3b8 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Tue, 5 Apr 2016 20:26:24 -0700 Subject: [PATCH 07/13] remove validate step as the duplication, and user model.User instead of new struct. --- api/user.go | 75 ++------------------------------------------------ models/user.go | 10 +++---- 2 files changed, 8 insertions(+), 77 deletions(-) diff --git a/api/user.go b/api/user.go index 4a8101ba8..4e6136214 100644 --- a/api/user.go +++ b/api/user.go @@ -16,7 +16,6 @@ package api import ( - "fmt" "net/http" "strconv" @@ -32,19 +31,6 @@ type UserAPI struct { userID int } -type userReq struct { - UserName string `json:"username"` - Password string `json:"password"` - Realname string `json:"realname"` - Email string `json:"email"` - Comment string `json:"comment"` -} - -const userNameMaxLen int = 20 -const passwordMaxLen int = 20 -const realNameMaxLen int = 20 -const commentsMaxLen int = 20 - // Prepare validates the URL and parms func (ua *UserAPI) Prepare() { @@ -137,37 +123,15 @@ func (ua *UserAPI) Put() { //currently only for toggle admin, so no request body // Post ... func (ua *UserAPI) Post() { - var req userReq - ua.DecodeJSONReq(&req) + user := models.User{} + ua.DecodeJSONReq(&user) - err := validateUserReq(req) - if err != nil { - log.Errorf("Invalid user request, error: %v", err) - ua.RenderError(http.StatusBadRequest, "Invalid request for creating user") - return - } - - user := models.User{Username: req.UserName, Email: req.Email, Realname: req.Realname, Password: req.Password, Comment: req.Comment} - exist, err := dao.UserExists(user, "email") - if err != nil { - log.Errorf("Error occurred in UserExists: %v", err) - } - if exist { - ua.RenderError(http.StatusConflict, "") - return - } - - userID, err := dao.Register(user) + _, err := dao.Register(user) if err != nil { log.Errorf("Error occurred in Register: %v", err) ua.RenderError(http.StatusInternalServerError, "Internal error.") return } - if userID == 0 { - log.Errorf("Error happened on registing new user in db.") - ua.RenderError(http.StatusInternalServerError, "Internal error.") - } - } // Delete ... @@ -189,36 +153,3 @@ func (ua *UserAPI) Delete() { return } } - -func validateUserReq(req userReq) error { - userName := req.UserName - if len(userName) == 0 { - return fmt.Errorf("User name can not be empty") - } - if len(userName) > userNameMaxLen { - return fmt.Errorf("User name is too long") - } - - password := req.Password - if len(password) == 0 { - return fmt.Errorf("Password can not be empty") - } - if len(password) >= passwordMaxLen { - return fmt.Errorf("Password can is too long") - } - - realName := req.Realname - if len(realName) == 0 { - return fmt.Errorf("Real name can not be empty") - } - if len(realName) >= realNameMaxLen { - return fmt.Errorf("Real name is too long") - } - - email := req.Email - if len(email) == 0 { - return fmt.Errorf("Email can not be empty") - } - - return nil -} diff --git a/models/user.go b/models/user.go index 82b8bc221..29fb41c13 100644 --- a/models/user.go +++ b/models/user.go @@ -22,11 +22,11 @@ import ( // User holds the details of a user. type User struct { UserID int `orm:"column(user_id)" json:"UserId"` - Username string `orm:"column(username)"` - Email string `orm:"column(email)"` - Password string `orm:"column(password)"` - Realname string `orm:"column(realname)"` - Comment string `orm:"column(comment)"` + Username string `orm:"column(username)" json:"username"` + Email string `orm:"column(email)" json:"email"` + Password string `orm:"column(password)" json:"password"` + Realname string `orm:"column(realname)" json:"realname"` + Comment string `orm:"column(comment)" json:"comment"` Deleted int `orm:"column(deleted)"` Rolename string RoleID int `json:"RoleId"` From 943d6ebd4cb6849bddf9fcc7b3c70acf7d1c32a3 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 8 Apr 2016 00:25:52 -0700 Subject: [PATCH 08/13] merge code with api/user; refactor api/users --- api/user.go | 67 ++++++++++++++++++++++++++++++++++------------------ ui/router.go | 1 - 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/api/user.go b/api/user.go index 4e6136214..ed433397a 100644 --- a/api/user.go +++ b/api/user.go @@ -17,7 +17,9 @@ package api import ( "net/http" + "os" "strconv" + "strings" "github.com/vmware/harbor/dao" "github.com/vmware/harbor/models" @@ -27,15 +29,32 @@ import ( // UserAPI handles request to /api/users/{} type UserAPI struct { BaseAPI - currentUserID int - userID int + currentUserID int + userID int + SelfRegistration bool + IsAdmin bool + AuthMode string } // Prepare validates the URL and parms func (ua *UserAPI) Prepare() { + authMode := strings.ToLower(os.Getenv("AUTH_MODE")) + if authMode == "" { + authMode = "db_auth" + } + ua.AuthMode = authMode + + selfRegistration := strings.ToLower(os.Getenv("SELF_REGISTRATION")) + if selfRegistration == "on" { + ua.SelfRegistration = true + } + if ua.Ctx.Input.IsPost() { - return + sessionUserID := ua.GetSession("userId") + if sessionUserID == nil { + return + } } ua.currentUserID = ua.ValidateUser() @@ -60,18 +79,19 @@ func (ua *UserAPI) Prepare() { ua.CustomAbort(http.StatusNotFound, "") } } + + var err error + ua.IsAdmin, err = dao.IsAdminRole(ua.currentUserID) + if err != nil { + log.Errorf("Error occurred in IsAdminRole:%v", err) + ua.CustomAbort(http.StatusInternalServerError, "Internal error.") + } } // Get ... func (ua *UserAPI) Get() { - exist, err := dao.IsAdminRole(ua.currentUserID) - if err != nil { - log.Errorf("Error occurred in IsAdminRole, error: %v", err) - ua.CustomAbort(http.StatusInternalServerError, "Internal error.") - } - if ua.userID == 0 { //list users - if !exist { + if !ua.IsAdmin { log.Errorf("Current user, id: %d does not have admin role, can not list users", ua.currentUserID) ua.RenderError(http.StatusForbidden, "User does not have admin role") return @@ -89,7 +109,7 @@ func (ua *UserAPI) Get() { } ua.Data["json"] = userList - } else if ua.userID == ua.currentUserID || exist { + } else if ua.userID == ua.currentUserID || ua.IsAdmin { userQuery := models.User{UserID: ua.userID} u, err := dao.GetUser(userQuery) if err != nil { @@ -107,12 +127,7 @@ func (ua *UserAPI) Get() { // Put ... func (ua *UserAPI) Put() { //currently only for toggle admin, so no request body - exist, err := dao.IsAdminRole(ua.currentUserID) - if err != nil { - log.Errorf("Error occurred in IsAdminRole, error: %v", err) - ua.CustomAbort(http.StatusInternalServerError, "Internal error.") - } - if !exist { + if !ua.IsAdmin { log.Warningf("current user, id: %d does not have admin role, can not update other user's role", ua.currentUserID) ua.RenderError(http.StatusForbidden, "User does not have admin role") return @@ -123,6 +138,16 @@ func (ua *UserAPI) Put() { //currently only for toggle admin, so no request body // Post ... func (ua *UserAPI) Post() { + + if !(ua.AuthMode == "db_auth") { + ua.CustomAbort(http.StatusForbidden, "") + } + + if !(ua.SelfRegistration || ua.IsAdmin) { + log.Warning("Registration can only be used by admin role user when self-registration is off.") + ua.CustomAbort(http.StatusForbidden, "") + } + user := models.User{} ua.DecodeJSONReq(&user) @@ -136,16 +161,12 @@ func (ua *UserAPI) Post() { // Delete ... func (ua *UserAPI) Delete() { - exist, err := dao.IsAdminRole(ua.currentUserID) - if err != nil { - log.Errorf("Error occurred in IsAdminRole, error: %v", err) - ua.CustomAbort(http.StatusInternalServerError, "Internal error.") - } - if !exist { + if !ua.IsAdmin { log.Warningf("current user, id: %d does not have admin role, can not remove user", ua.currentUserID) ua.RenderError(http.StatusForbidden, "User does not have admin role") return } + var err error err = dao.DeleteUser(ua.userID) if err != nil { log.Errorf("Failed to delete data from database, error: %v", err) diff --git a/ui/router.go b/ui/router.go index 1d7f15d03..a1f9067c1 100644 --- a/ui/router.go +++ b/ui/router.go @@ -32,7 +32,6 @@ func initRouters() { beego.Router("/login", &controllers.CommonController{}, "post:Login") beego.Router("/logout", &controllers.CommonController{}, "get:Logout") beego.Router("/language", &controllers.CommonController{}, "get:SwitchLanguage") - // beego.Router("/signUp", &controllers.CommonController{}, "post:SignUp") beego.Router("/userExists", &controllers.CommonController{}, "post:UserExists") beego.Router("/reset", &controllers.CommonController{}, "post:ResetPassword") beego.Router("/sendEmail", &controllers.CommonController{}, "get:SendEmail") From b404cdfe90d59c2f92fd39a980eb2badd5abefad Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Thu, 14 Apr 2016 15:57:42 +0800 Subject: [PATCH 09/13] update documents --- AUTHORS | 3 ++- README.md | 3 +++ docs/configure_https.md | 10 +++++++--- docs/img/beegoLogo.png | Bin 0 -> 5306 bytes docs/installation_guide.md | 13 ++++++++----- 5 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 docs/img/beegoLogo.png diff --git a/AUTHORS b/AUTHORS index f6e2e7e0e..d292ef8c7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,6 @@ # This file lists all individuals having contributed content to the repository. +Alexander Zeitler Amanda Zhang Benniu Ji Bobby Zhang @@ -9,8 +10,8 @@ Haining Henry Zhang Hao Xia Jack Liu Kun Wang +Peng Zhao Shan Zhu Victoria Zheng Wenkai Yin Yan Wang - diff --git a/README.md b/README.md index 88b93ad34..d94dd1b3c 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,6 @@ Harbor is available under the [Apache 2 license](LICENSE). ### Users MaDaiLiCai + +### Supporting Technologies +Harbor is powered by beego, an open source framework to build and develop applications in the Go way. diff --git a/docs/configure_https.md b/docs/configure_https.md index e366cb5d7..ccb667c35 100644 --- a/docs/configure_https.md +++ b/docs/configure_https.md @@ -1,8 +1,8 @@ -#Configure Harbor with HTTPS Access +#Configuring Harbor with HTTPS Access Because Harbor does not ship with any certificates, it uses HTTP by default to serve registry requests. This makes it relatively simple to configure. However, it is highly recommended that security be enabled for any production environment. Harbor has an Nginx instance as a reverse proxy for all services, you can configure Nginx to enable https. -##Get a certificate +##Getting a certificate Assuming that your registry's **hostname** is **reg.yourdomain.com**, and that its DNS record points to the host where you are running Harbor. You first should get a certificate from a CA. The certificate usually contains a .crt file and a .key file, for example, **yourdomain.com.crt** and **yourdomain.com.key**. @@ -22,7 +22,7 @@ In a test or development environment, you may choose to use a self-signed certif ``` 3) Generate the certificate of your registry host: -You need to configure openssl first. On Ubuntu, the config file locates at /etc/ssl/openssl.cnf. Refer to openssl document for more information. The default CA directory of openssl is called demoCA. Let's create necessary directories and files: +You need to configure openssl first. On Ubuntu, the config file locates at **/etc/ssl/openssl.cnf**. Refer to openssl document for more information. The default CA directory of openssl is called demoCA. Let's create necessary directories and files: ``` mkdir demoCA cd demoCA @@ -41,6 +41,10 @@ After obtaining the **yourdomain.com.crt** and **yourdomain.com.key** files, cha cd Deploy/config/nginx ``` Create a new directory cert/, if it does not exist. Then copy **yourdomain.com.crt** and **yourdomain.com.key** to cert/. +``` + cp yourdomain.com.crt cert/ + cp yourdomain.com.key cert/ +``` Rename the existing configuration file of Nginx: ``` diff --git a/docs/img/beegoLogo.png b/docs/img/beegoLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..4cd801385d7c954d8d6881cdd36303177dc4c1e7 GIT binary patch literal 5306 zcmV;r6h-TaP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!~g&e!~vBn z4jTXf02XvbSad^jWnpw_Z*Cw|X>DZyF)}YPGcPeS>Msy-0000SbVXQnQ*UN;cVTj6 z06}DLVr3vkX>w(EZ*psMAVX6&=)AIw000y9NklQIHARCM0wi|G`BPtX?CQVSg z4nG~S_&t?E;-@QCO$Ph1ok@$;wX4aq-L_(FyLCl_iV{IiXp`*ZOC@;gU5@Cm#dYWg z;-X)p?c(m@zGlbpk517cS+-bxdP{1;8RDMwuRItVD|^ZGFwEx7HI_mUU{s3UG-y|G zhksqH0sW!_<&(esS_#%~KyQxe;jn&i4i_V3_d6$;eeF<~b*uO*(LmH36~H-Ue{sj0 zTG5b$VC6gFJ+w%IcmHnYYMY*%Iw+lz)RBAi5;d{mkL|B_oI3o-<)#6(jO~A=+&y%n=E6%VX zlDhCbarW6OI#@c{QR85`zG!qo9Ve9VleJQF+e~o|KRDXgI=RW0i2vfNXry$sCk`kZ zCOC81MdF_EooHXj32SR{eV2;=!Yg8R@22LsxfDmB9i&T*Waiu?&ThLzJLBWOzC!Z< zd4q(THjCx3YzzGc?H)$g(bDDUzE-YN330Ukc$m+Nd(4rNo;oGk(>~!xpGfZN8^vGp zwAg#@CYd{aE_S!BVq56Z>c2#ZJ-od{zsKs)U2OO{!P~1O_rq!8Kk;-_R2k5hf*_Ss zcIye}=+#q#RnT6gKwqwsWurd))oY@YcbxFcb*RrPG^W?yZX5WOUG)4dmx}};4zo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docs/installation_guide.md +++ b/docs/installation_guide.md @@ -28,7 +28,7 @@ Before installing Harbor, you should configure the parameters in the file **harb At minimum, you need to change the **hostname** attribute in **harbor.cfg**. The description of each attribute is as follows: **hostname**: The hostname for a user to access the user interface and the registry service. It should be the IP address or the fully qualified domain name (FQDN) of your target machine, for example 192.168.1.10 or reg.yourdomain.com . Do NOT use localhost or 127.0.0.1 for the hostname because the registry service needs to be accessed by external clients. -**ui_url_protocol**: The protocol for accessing the user interface and the token/notification service, by default it is http. +**ui_url_protocol**: The protocol for accessing the user interface and the token/notification service, by default it is http. To set up https protocol, refer to [Configuring Harbor with HTTPS](configure_https.md). **Email settings**: the following 5 attributes are used to send an email to reset a user's password, they are not mandatory unless the password reset function is needed in Harbor. * email_server = smtp.mydomain.com * email_server_port = 25 @@ -40,8 +40,9 @@ At minimum, you need to change the **hostname** attribute in **harbor.cfg**. The **auth_mode**: The authentication mode of Harbor. By default it is *db_auth*, i.e. the credentials are stored in a database. Please set it to *ldap_auth* if you want to verify user's credentials against an LDAP server. **ldap_url**: The URL for LDAP endpoint, for example ldaps://ldap.mydomain.com. It is only used when **auth_mode** is set to *ldap_auth*. **ldap_basedn**: The basedn template for verifying the user's credentials against LDAP, for example uid=%s,ou=people,dc=mydomain,dc=com. It is only used when **auth_mode** is set to *ldap_auth*. -**db_password**: The password of root user of mySQL database. +**db_password**: The password of root user of mySQL database. Change this password for any production use. **self_registration**: The flag to turn on or off the user self-registration function. If this flag is turned off, only an admin user can create new users in Harbor. The default value is on. +NOTE: When **auth_mode** is *ldap_auth*, the self-registration feature is always disabled, therefore, this flag is ignored. #### Building and starting Harbor After configuring harbor.cfg, build and start Harbor by the following commands. Because it requires downloading necessary files from the Internet, it may take a while for the docker-compose process to finish. @@ -61,7 +62,7 @@ After configuring harbor.cfg, build and start Harbor by the following commands. If everything works fine, you can open a browser to visit the admin portal at http://reg.yourdomain.com . The default administrator username and password are admin/Harbor12345 . -Create a new project, e.g. myproject, in the admin portal. You can then use docker commands to login and push images. The default port of Harbor registry server is 80: +Log in to the admin portal and create a new project, e.g. myproject. You can then use docker commands to login and push images. The default port of Harbor registry server is 80: ```sh $ docker login reg.yourdomain.com $ docker push reg.yourdomain.com/myproject/myrepo @@ -121,8 +122,10 @@ $ cd ../ $ tar -cvzf harbor_offline-0.1.1.tgz harbor ``` -The file **harbor_offline-0.1.1.tgz** contains the images saved by previously steps and the files required to start Harbor. -You can use tools such as scp to transfer the file **harbor_offline-0.1.1.tgz** to the target machine that does not have Internet connection. On the target machine, you can execute the following commands to start Harbor. Again, before running the **prepare** script, be sure to update **harbor.cfg** to reflect the right configuration of the target machine. (Refer to Section [Configure Harbor](#configuring-harbor) .) +The file **harbor_offline-0.1.1.tgz** contains the images saved by previous steps and the other files required to start Harbor. +You can use tools such as scp to transfer the file **harbor_offline-0.1.1.tgz** to the target machine that does not have Internet connection. +On the target machine, you can execute the following commands to start Harbor. Again, before running the **prepare** script, +be sure to update **harbor.cfg** to reflect the right configuration of the target machine. (Refer to Section [Configuring Harbor](#configuring-harbor) .) ``` $ tar -xzvf harbor_offline-0.1.1.tgz $ cd harbor From a9a12bacfab0298b63b6d29a5eeceee2bba039a8 Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Thu, 14 Apr 2016 17:27:09 +0800 Subject: [PATCH 10/13] update document --- README.md | 4 ++-- docs/configure_https.md | 2 +- docs/img/beegoLogo.png | Bin 5306 -> 4015 bytes docs/installation_guide.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d94dd1b3c..64df2368e 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ The host must be connected to the Internet. If everything works fine, you can open a browser to visit the admin portal at http://reg.yourdomain.com . The default administrator username and password are admin/Harbor12345 . -Create a new project, e.g. myproject, in the admin portal. You can then use docker commands to login and push images. The default port of Harbor registry server is 80: +Log in to the admin portal and create a new project, e.g. myproject. You can then use docker commands to login and push images. The default port of Harbor registry server is 80: ```sh $ docker login reg.yourdomain.com $ docker push reg.yourdomain.com/myproject/myrepo @@ -70,4 +70,4 @@ Harbor is available under the [Apache 2 license](LICENSE). MaDaiLiCai ### Supporting Technologies -Harbor is powered by beego, an open source framework to build and develop applications in the Go way. +beego Harbor is powered by Beego, an open source framework to build and develop applications in the Go way. diff --git a/docs/configure_https.md b/docs/configure_https.md index ccb667c35..003fcfd6a 100644 --- a/docs/configure_https.md +++ b/docs/configure_https.md @@ -40,7 +40,7 @@ After obtaining the **yourdomain.com.crt** and **yourdomain.com.key** files, cha ``` cd Deploy/config/nginx ``` -Create a new directory cert/, if it does not exist. Then copy **yourdomain.com.crt** and **yourdomain.com.key** to cert/. +Create a new directory cert/, if it does not exist. Then copy **yourdomain.com.crt** and **yourdomain.com.key** to cert/, e.g. : ``` cp yourdomain.com.crt cert/ cp yourdomain.com.key cert/ diff --git a/docs/img/beegoLogo.png b/docs/img/beegoLogo.png index 4cd801385d7c954d8d6881cdd36303177dc4c1e7..ada97519d27f5cd1ca4cf3fc9ffb1ec87a47aae4 100644 GIT binary patch delta 3912 zcmV-O54Z5TDX$+PiBL{Q4GJ0x0000DNk~Le0001g0000e2nGNE0M|ApT#+G;e-7$N zL_t(|UhP~7loZ7o{!DPQ@vC~yO)z$y~ z|5c-*2()6Sgxb0l@e3xvT~`dle=-q$au&>8y9A>xhZ+2B#ZCxs*>ZR*SHmobLTxOC zyY#bQBtK|n{?3e02(a1oXA4TM^N3dF|A=4&fAfV_=I`vN!|{AaXRXZNnL%!=iWpRR z1=O|*7*%?22@rBggbGjE3ZHxvf=*9h4_Gz=rc>qrDBEQArZVf5$@ zvr~s)rrcn-t5z#`P4J%!F}ieu5#>X(gtvMv;JSQ54st7U*tRXq&K-k}#!#i3pvuYt zD+i+`^K$J*x310BBDLjvf2gh7>Z_q%Zz0#)Ip}B}DuxUPs;bCjGFXhfutOR={hz)N z9?A2h>CYS>eHA~44n7c(hwg!4QE+mAQF-EM<;4=|c_a^`)EV8o!W!5g_PJwW?9w(E zOpn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zbVT>KZ$ctzt;(nI${t;Vetq@9KwXAz3NkSwDSZE92rx#?e~~|>Ibnj_k;h2t@{9Fc zrO;?)4;{hUy0^Z+O=BF&fi=%T%h896TVgn5qm@0DjdEFjhss7Ha0xv%W)!5MwH3H} z__T0#{COIbqze&L0<8OOx6w!7TdRAsM!Ur%|I52H z%v4uvDPTBfe|qvHvG?6O$`KFVS^mPyBv=P+3{9+eihJOjUE@6F)hLXUjiO7Y~Au_OG%eQ@iSDSYUeN3 ziM3TvN#8KNEFo?N%Z6rdvCNVZ1`QbT2Fq7QCoF^5Wh0^NavqpWO`W1ITjZRrzHSV( zdkt(Gf7U$(p9>-|`Fx2>rG!}Fa=1Pfx(*gGEbl^Jpt}M4lfq#8~gRuAQ}c#HjM#kIWlmZ(@X8 zpWeF6nL3rLL*-L@!f4f^=Ka4F0F}|@_BmojfB)}WTjb8YNZ&skcaT&EG<(gDuM+#f z@?LS3pLwhJOO_gUA(u6h(iRkUM&|Y3Ufgk~!z5Ss5h?%azljEe6~zIaEInzQ*wD!S zlTV5N;G+_(eqWc8>%j))LigbxXjyL3N@|bLb5U79co|(uSCYFR?9Lv8B|Qah7CLGi zf2_j%2Sf8-fznXF3FeS*iLnO{H2!o4@fJL+^U!88JRa=b&Y)ezF5v}?L_-GGer_~e zOxP&)E<1`nY`>E0u^}An$$M)g;1e5dxfUQq$FpJi?4f(>6DF0$U-ps|Zo9*5uwBsJ zeAAD>{S01R4s8lI5Ov0@>`1$*3kCF-f9xcazo+xqaj|gXwreiopNim>*CjvamkSZ zjR^j}S_(J*mkMc}>pC_mb8|{HRiF4pkarhWoGX)06ok1eV3C)2E;lJ}9J|W1NwAlUnRdor!d_?{a Xh6# diff --git a/docs/installation_guide.md b/docs/installation_guide.md index 6b17cc3b5..56d0c5152 100644 --- a/docs/installation_guide.md +++ b/docs/installation_guide.md @@ -28,7 +28,7 @@ Before installing Harbor, you should configure the parameters in the file **harb At minimum, you need to change the **hostname** attribute in **harbor.cfg**. The description of each attribute is as follows: **hostname**: The hostname for a user to access the user interface and the registry service. It should be the IP address or the fully qualified domain name (FQDN) of your target machine, for example 192.168.1.10 or reg.yourdomain.com . Do NOT use localhost or 127.0.0.1 for the hostname because the registry service needs to be accessed by external clients. -**ui_url_protocol**: The protocol for accessing the user interface and the token/notification service, by default it is http. To set up https protocol, refer to [Configuring Harbor with HTTPS](configure_https.md). +**ui_url_protocol**: The protocol for accessing the user interface and the token/notification service, by default it is http. To set up the https protocol, refer to [Configuring Harbor with HTTPS Access](configure_https.md). **Email settings**: the following 5 attributes are used to send an email to reset a user's password, they are not mandatory unless the password reset function is needed in Harbor. * email_server = smtp.mydomain.com * email_server_port = 25 @@ -97,7 +97,7 @@ $ sudo docker-compose up -d ...... ``` -### Deploying Harbor to a target machine that does not have Internet access +### Deploying Harbor to a host which does not have Internet access When you run *docker-compose up* to start Harbor, it will pull base images from Docker Hub and build new images for the containers. This process requires accessing the Internet. If you want to deploy Harbor to a host that is not connected to the Internet, you need to prepare Harbor on a machine that has access to the Internet. After that, you export the images as tgz files and transfer them to the target machine. Then load the tgz file into Docker's local image repo. #### Building and saving images for offline installation From c66edd02d074b3339cd7b2619e6df53ecf7cd2aa Mon Sep 17 00:00:00 2001 From: Henry Zhang Date: Thu, 14 Apr 2016 17:40:03 +0800 Subject: [PATCH 11/13] update docs --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index d292ef8c7..8e9802ff4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -10,7 +10,7 @@ Haining Henry Zhang Hao Xia Jack Liu Kun Wang -Peng Zhao +Peng Zhao Shan Zhu Victoria Zheng Wenkai Yin From 7165156f2d935a879859770bda8b4611ad252864 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Thu, 14 Apr 2016 21:33:48 -0700 Subject: [PATCH 12/13] update per comments, add support for basic auth --- api/user.go | 21 ++++++++++++++++----- controllers/register.go | 28 ---------------------------- static/resources/js/register.js | 33 +++++++++++++++------------------ 3 files changed, 31 insertions(+), 51 deletions(-) diff --git a/api/user.go b/api/user.go index ed433397a..d4c0c1851 100644 --- a/api/user.go +++ b/api/user.go @@ -29,11 +29,14 @@ import ( // UserAPI handles request to /api/users/{} type UserAPI struct { BaseAPI - currentUserID int - userID int - SelfRegistration bool - IsAdmin bool - AuthMode string + currentUserID int + userID int + SelfRegistration bool + IsAdmin bool + AuthMode string + IsBasicAuth bool + UserNameInBasicAuth string + PasswordInBasicAuth string } // Prepare validates the URL and parms @@ -51,6 +54,8 @@ func (ua *UserAPI) Prepare() { } if ua.Ctx.Input.IsPost() { + ua.UserNameInBasicAuth, ua.PasswordInBasicAuth, ua.IsBasicAuth = ua.Ctx.Request.BasicAuth() + sessionUserID := ua.GetSession("userId") if sessionUserID == nil { return @@ -151,12 +156,18 @@ func (ua *UserAPI) Post() { user := models.User{} ua.DecodeJSONReq(&user) + if ua.IsBasicAuth { + user.Username = ua.UserNameInBasicAuth + user.Password = ua.PasswordInBasicAuth + } + _, err := dao.Register(user) if err != nil { log.Errorf("Error occurred in Register: %v", err) ua.RenderError(http.StatusInternalServerError, "Internal error.") return } + } // Delete ... diff --git a/controllers/register.go b/controllers/register.go index dd1a80eab..d8ed05715 100644 --- a/controllers/register.go +++ b/controllers/register.go @@ -17,7 +17,6 @@ package controllers import ( "net/http" - "strings" "github.com/vmware/harbor/dao" "github.com/vmware/harbor/models" @@ -65,33 +64,6 @@ func (ac *AddUserController) Get() { } } -// SignUp insert data into DB based on data in form. -func (cc *CommonController) SignUp() { - - if !(cc.AuthMode == "db_auth") { - cc.CustomAbort(http.StatusForbidden, "") - } - - if !(cc.SelfRegistration || cc.IsAdmin) { - log.Warning("Registration can only be used by admin role user when self-registration is off.") - cc.CustomAbort(http.StatusForbidden, "") - } - - username := strings.TrimSpace(cc.GetString("username")) - email := strings.TrimSpace(cc.GetString("email")) - realname := strings.TrimSpace(cc.GetString("realname")) - password := strings.TrimSpace(cc.GetString("password")) - comment := strings.TrimSpace(cc.GetString("comment")) - - user := models.User{Username: username, Email: email, Realname: realname, Password: password, Comment: comment} - - _, err := dao.Register(user) - if err != nil { - log.Errorf("Error occurred in Register: %v", err) - cc.CustomAbort(http.StatusInternalServerError, "Internal error.") - } -} - // UserExists checks if user exists when user input value in sign in form. func (cc *CommonController) UserExists() { target := cc.GetString("target") diff --git a/static/resources/js/register.js b/static/resources/js/register.js index ebfe60dd0..8f970946f 100644 --- a/static/resources/js/register.js +++ b/static/resources/js/register.js @@ -38,15 +38,25 @@ jQuery(function(){ var comment = $.trim($("#Comment").val()); var isAdmin = $("#isAdmin").val(); - $.ajax({ + new AjaxUtil({ url : "/api/users", - data: JSON.stringify({username: username, password: password, realname: realname, comment: comment, email: email}), + data: {"username": username, "password": password, "realname": realname, "comment": comment, "email": email}, type: "POST", - contentType: "application/json; charset=UTF-8", beforeSend: function(e){ $("#btnPageSignUp").prop("disabled", true); }, - success: function(data, status, xhr){ + error:function(jqxhr, status, error){ + $("#dlgModal") + .dialogModal({ + "title": i18n.getMessage("title_sign_up"), + "content": i18n.getMessage("internal_error"), + "callback": function(){ + return; + } + }); + }, + complete: function(xhr, status){ + $("#btnPageSignUp").prop("disabled", false); if(xhr && xhr.status == 200){ $("#dlgModal") .dialogModal({ @@ -61,21 +71,8 @@ jQuery(function(){ } }); } - }, - error:function(jqxhr, status, error){ - $("#dlgModal") - .dialogModal({ - "title": i18n.getMessage("title_sign_up"), - "content": i18n.getMessage("internal_error"), - "callback": function(){ - return; - } - }); - }, - complete: function(){ - $("#btnPageSignUp").prop("disabled", false); } - }); + }).exec(); }); }); }); \ No newline at end of file From fc24341c1730ffe6d60c9a8587ed8a44affb7c50 Mon Sep 17 00:00:00 2001 From: wy65701436 Date: Fri, 15 Apr 2016 01:55:33 -0700 Subject: [PATCH 13/13] update per comments, add support for basic auth --- api/user.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/api/user.go b/api/user.go index d4c0c1851..58aa29ec3 100644 --- a/api/user.go +++ b/api/user.go @@ -29,14 +29,11 @@ import ( // UserAPI handles request to /api/users/{} type UserAPI struct { BaseAPI - currentUserID int - userID int - SelfRegistration bool - IsAdmin bool - AuthMode string - IsBasicAuth bool - UserNameInBasicAuth string - PasswordInBasicAuth string + currentUserID int + userID int + SelfRegistration bool + IsAdmin bool + AuthMode string } // Prepare validates the URL and parms @@ -54,10 +51,9 @@ func (ua *UserAPI) Prepare() { } if ua.Ctx.Input.IsPost() { - ua.UserNameInBasicAuth, ua.PasswordInBasicAuth, ua.IsBasicAuth = ua.Ctx.Request.BasicAuth() - sessionUserID := ua.GetSession("userId") - if sessionUserID == nil { + _, _, ok := ua.Ctx.Request.BasicAuth() + if sessionUserID == nil && !ok { return } } @@ -91,6 +87,7 @@ func (ua *UserAPI) Prepare() { log.Errorf("Error occurred in IsAdminRole:%v", err) ua.CustomAbort(http.StatusInternalServerError, "Internal error.") } + } // Get ... @@ -156,11 +153,6 @@ func (ua *UserAPI) Post() { user := models.User{} ua.DecodeJSONReq(&user) - if ua.IsBasicAuth { - user.Username = ua.UserNameInBasicAuth - user.Password = ua.PasswordInBasicAuth - } - _, err := dao.Register(user) if err != nil { log.Errorf("Error occurred in Register: %v", err)