remove useless codes

This commit is contained in:
Wenkai Yin 2017-08-09 15:13:51 +08:00
parent 3c64ae340e
commit 7fedca3a4a
2 changed files with 2 additions and 30 deletions

View File

@ -141,20 +141,7 @@ func convertRoles(roles []string) []int {
// GetAuthCtx returns the auth context of the current user
func GetAuthCtx(client *http.Client, url, token string) (*AuthContext, error) {
return get(client, url, token)
}
// get the user's auth context, if the username is not provided
// get the default auth context of the token
func get(client *http.Client, url, token string, username ...string) (*AuthContext, error) {
endpoint := ""
if len(username) > 0 && len(username[0]) > 0 {
endpoint = buildSpecificUserAuthCtxURL(url, username[0])
} else {
endpoint = buildCurrentUserAuthCtxURL(url)
}
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
req, err := http.NewRequest(http.MethodGet, buildCurrentUserAuthCtxURL(url), nil)
if err != nil {
return nil, err
}
@ -218,11 +205,6 @@ func buildCurrentUserAuthCtxURL(url string) string {
return strings.TrimRight(url, "/") + "/auth/session"
}
func buildSpecificUserAuthCtxURL(url, principalID string) string {
return fmt.Sprintf("%s/auth/idm/principals/%s/security-context",
strings.TrimRight(url, "/"), principalID)
}
func buildLoginURL(url, principalID string) string {
return fmt.Sprintf("%s/auth/idm/principals/%s/security-context",
strings.TrimRight(url, "/"), principalID)

View File

@ -21,8 +21,6 @@ import (
"github.com/vmware/harbor/src/common/dao"
"github.com/vmware/harbor/src/common/models"
"github.com/vmware/harbor/src/common/utils/log"
"github.com/vmware/harbor/src/common/utils/registry/auth"
"github.com/vmware/harbor/src/jobservice/config"
"github.com/vmware/harbor/src/jobservice/job"
"github.com/vmware/harbor/src/jobservice/utils"
)
@ -42,15 +40,7 @@ func (isj *ImageScanJob) Post() {
var data models.ImageScanReq
isj.DecodeJSONReq(&data)
log.Debugf("data: %+v", data)
regURL, err := config.LocalRegURL()
if err != nil {
log.Errorf("Failed to read regURL, error: %v", err)
isj.RenderError(http.StatusInternalServerError, "Failed to read registry URL from config")
return
}
c := &http.Cookie{Name: models.UISecretCookie, Value: config.JobserviceSecret()}
repoClient, err := utils.NewRepositoryClient(regURL, false, auth.NewCookieCredential(c),
config.InternalTokenServiceEndpoint(), data.Repo)
repoClient, err := utils.NewRepositoryClientForJobservice(data.Repo)
if err != nil {
log.Errorf("An error occurred while creating repository client: %v", err)
isj.RenderError(http.StatusInternalServerError, "Failed to repository client")