2020-02-07 08:04:25 +01:00
// Copyright Project Harbor Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package server
import (
2020-09-30 09:14:00 +02:00
"net/http"
2022-11-24 11:07:42 +01:00
"github.com/beego/beego/v2/server/web"
2022-07-20 05:33:08 +02:00
2020-02-07 08:04:25 +01:00
"github.com/goharbor/harbor/src/common"
"github.com/goharbor/harbor/src/core/api"
"github.com/goharbor/harbor/src/core/controllers"
"github.com/goharbor/harbor/src/core/service/token"
2020-06-16 11:58:58 +02:00
"github.com/goharbor/harbor/src/server/handler"
2020-04-04 14:59:46 +02:00
"github.com/goharbor/harbor/src/server/router"
2020-02-07 08:04:25 +01:00
)
2023-12-19 02:41:26 +01:00
func ignoreNotification ( w http . ResponseWriter , _ * http . Request ) {
2020-12-22 04:48:16 +01:00
w . WriteHeader ( http . StatusOK )
}
2020-02-07 08:04:25 +01:00
func registerRoutes ( ) {
2020-04-04 14:59:46 +02:00
// API version
router . NewRoute ( ) . Method ( http . MethodGet ) . Path ( "/api/version" ) . HandlerFunc ( GetAPIVersion )
2020-02-07 08:04:25 +01:00
// Controller API:
2022-11-24 11:07:42 +01:00
web . Router ( "/c/login" , & controllers . CommonController { } , "post:Login" )
web . Router ( "/c/log_out" , & controllers . CommonController { } , "get:LogOut" )
web . Router ( "/c/userExists" , & controllers . CommonController { } , "post:UserExists" )
web . Router ( common . OIDCLoginPath , & controllers . OIDCController { } , "get:RedirectLogin" )
web . Router ( "/c/oidc/onboard" , & controllers . OIDCController { } , "post:Onboard" )
web . Router ( common . OIDCCallbackPath , & controllers . OIDCController { } , "get:Callback" )
web . Router ( common . AuthProxyRediretPath , & controllers . AuthProxyController { } , "get:HandleRedirect" )
2020-02-07 08:04:25 +01:00
2022-11-24 11:07:42 +01:00
web . Router ( "/api/internal/renameadmin" , & api . InternalAPI { } , "post:RenameAdmin" )
web . Router ( "/api/internal/syncquota" , & api . InternalAPI { } , "post:SyncQuota" )
2020-02-07 08:04:25 +01:00
2020-12-22 04:48:16 +01:00
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/jobs/adminjob/:id([0-9]+)" ) . Handler ( handler . NewJobStatusHandler ( ) ) // legacy job status hook endpoint for adminjob
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/jobs/scan/:uuid" ) . HandlerFunc ( ignoreNotification ) // ignore legacy scan job notifaction
2020-12-10 13:26:54 +01:00
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/schedules/:id([0-9]+)" ) . Handler ( handler . NewJobStatusHandler ( ) ) // legacy job status hook endpoint for scheduler
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/jobs/replication/:id([0-9]+)" ) . Handler ( handler . NewJobStatusHandler ( ) ) // legacy job status hook endpoint for replication scheduler
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/jobs/replication/task/:id([0-9]+)" ) . Handler ( handler . NewJobStatusHandler ( ) ) // legacy job status hook endpoint for replication task
2020-12-27 15:19:19 +01:00
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/jobs/retention/task/:id([0-9]+)" ) . Handler ( handler . NewJobStatusHandler ( ) )
2020-06-16 11:58:58 +02:00
router . NewRoute ( ) . Method ( http . MethodPost ) . Path ( "/service/notifications/tasks/:id" ) . Handler ( handler . NewJobStatusHandler ( ) )
2020-02-07 08:04:25 +01:00
2022-11-24 11:07:42 +01:00
web . Router ( "/service/token" , & token . Handler { } )
2020-02-07 08:04:25 +01:00
// Error pages
2022-11-24 11:07:42 +01:00
web . ErrorController ( & controllers . ErrorController { } )
2020-02-07 08:04:25 +01:00
}