mirror of
https://github.com/goharbor/harbor
synced 2025-04-17 20:02:22 +00:00
Merge pull request #3006 from ywk253100/170808_bug_fix
[BAT]Remove useless codes
This commit is contained in:
commit
5ba363657f
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue
Block a user