Compare commits
No commits in common. "7ed63d94cc60c8cf1559b26bcebd419257c5f39b" and "b55c1f7d485fd4352fa608ee2b7cbdcce811c706" have entirely different histories.
7ed63d94cc
...
b55c1f7d48
|
@ -417,10 +417,6 @@ func (a *AccountAPI) Routes() (*httprouter.Router, error) {
|
|||
AllowedMethods: []string{"*"},
|
||||
})
|
||||
|
||||
corsOptionsHandler := func(c jape.Context) {
|
||||
c.ResponseWriter.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
routes := map[string]jape.Handler{
|
||||
// Auth
|
||||
"POST /api/auth/ping": middleware.ApplyMiddlewares(a.ping, corsMw.Handler, pingAuthMw, middleware.ProxyMiddleware),
|
||||
|
@ -438,26 +434,6 @@ func (a *AccountAPI) Routes() (*httprouter.Router, error) {
|
|||
"POST /api/account/update-email": middleware.ApplyMiddlewares(a.updateEmail, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"POST /api/account/update-password": middleware.ApplyMiddlewares(a.updatePassword, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
|
||||
// CORS
|
||||
"OPTIONS /api/auth/ping": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/auth/login": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, loginAuthMw2fa, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/auth/register": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/auth/otp/validate": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/auth/logout": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
|
||||
"OPTIONS /api/account/verify-email": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account/otp/verify": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account/otp/disable": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account/password-reset/request": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account/password-reset/confirm": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account/update-email": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account/update-password": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
|
||||
// Get Routes
|
||||
"OPTIONS /api/upload-limit": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/account": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
"OPTIONS /api/auth/otp/generate": middleware.ApplyMiddlewares(corsOptionsHandler, corsMw.Handler, authMw, middleware.ProxyMiddleware),
|
||||
|
||||
"GET /*path": middleware.ApplyMiddlewares(getHandler, corsMw.Handler),
|
||||
}
|
||||
|
||||
|
|
47
api/s5/s5.go
47
api/s5/s5.go
|
@ -169,17 +169,17 @@ func (s *S5API) Routes() (*httprouter.Router, error) {
|
|||
|
||||
tusHandler := BuildS5TusApi(authMw, s.tusHandler)
|
||||
|
||||
corsOptionsHandler := func(c jape.Context) {
|
||||
tusOptionsHandler := func(c jape.Context) {
|
||||
c.ResponseWriter.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
||||
tusCors := BuildTusCors()
|
||||
|
||||
wrappedTusHandler := middleware.ApplyMiddlewares(corsOptionsHandler, middleware.ProxyMiddleware, tusCors, authMw)
|
||||
wrappedTusHandler := middleware.ApplyMiddlewares(tusOptionsHandler, tusCors, authMw)
|
||||
|
||||
debugCors := cors.Default()
|
||||
|
||||
defaultCors := cors.New(cors.Options{
|
||||
uploadCors := cors.New(cors.Options{
|
||||
AllowOriginFunc: func(origin string) bool {
|
||||
return true
|
||||
},
|
||||
|
@ -190,20 +190,20 @@ func (s *S5API) Routes() (*httprouter.Router, error) {
|
|||
|
||||
routes := map[string]jape.Handler{
|
||||
// Account API
|
||||
"GET /s5/account/register": middleware.ApplyMiddlewares(s.accountRegisterChallenge, middleware.ProxyMiddleware),
|
||||
"POST /s5/account/register": middleware.ApplyMiddlewares(s.accountRegister, middleware.ProxyMiddleware),
|
||||
"GET /s5/account/login": middleware.ApplyMiddlewares(s.accountLoginChallenge, middleware.ProxyMiddleware),
|
||||
"POST /s5/account/login": middleware.ApplyMiddlewares(s.accountLogin, middleware.ProxyMiddleware),
|
||||
"GET /s5/account": middleware.ApplyMiddlewares(s.accountInfo, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/account/stats": middleware.ApplyMiddlewares(s.accountStats, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/account/pins.bin": middleware.ApplyMiddlewares(s.accountPinsBinary, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/account/pins": middleware.ApplyMiddlewares(s.accountPins, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/account/register": s.accountRegisterChallenge,
|
||||
"POST /s5/account/register": s.accountRegister,
|
||||
"GET /s5/account/login": s.accountLoginChallenge,
|
||||
"POST /s5/account/login": s.accountLogin,
|
||||
"GET /s5/account": middleware.ApplyMiddlewares(s.accountInfo, authMw),
|
||||
"GET /s5/account/stats": middleware.ApplyMiddlewares(s.accountStats, authMw),
|
||||
"GET /s5/account/pins.bin": middleware.ApplyMiddlewares(s.accountPinsBinary, authMw),
|
||||
"GET /s5/account/pins": middleware.ApplyMiddlewares(s.accountPins, authMw),
|
||||
|
||||
// Upload API
|
||||
"POST /s5/upload": middleware.ApplyMiddlewares(s.smallFileUpload, middleware.ProxyMiddleware, defaultCors.Handler, authMw),
|
||||
"POST /s5/upload/directory": middleware.ApplyMiddlewares(s.directoryUpload, middleware.ProxyMiddleware, defaultCors.Handler, authMw),
|
||||
"OPTIONS /s5/upload": middleware.ApplyMiddlewares(corsOptionsHandler, middleware.ProxyMiddleware, defaultCors.Handler, authMw),
|
||||
"OPTIONS /s5/upload/directory": middleware.ApplyMiddlewares(corsOptionsHandler, middleware.ProxyMiddleware, defaultCors.Handler, authMw),
|
||||
"POST /s5/upload": middleware.ApplyMiddlewares(s.smallFileUpload, uploadCors.Handler, authMw),
|
||||
"POST /s5/upload/directory": middleware.ApplyMiddlewares(s.directoryUpload, uploadCors.Handler, authMw),
|
||||
"OPTIONS /s5/upload": middleware.ApplyMiddlewares(s.smallFileUpload, uploadCors.Handler, authMw),
|
||||
"OPTIONS /s5/upload/directory": middleware.ApplyMiddlewares(s.directoryUpload, uploadCors.Handler, authMw),
|
||||
|
||||
// Tus API
|
||||
"POST /s5/upload/tus": tusHandler,
|
||||
|
@ -214,25 +214,22 @@ func (s *S5API) Routes() (*httprouter.Router, error) {
|
|||
"OPTIONS /s5/upload/tus/:id": wrappedTusHandler,
|
||||
|
||||
// Download API
|
||||
"GET /s5/blob/:cid": middleware.ApplyMiddlewares(s.downloadBlob, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/blob/:cid": middleware.ApplyMiddlewares(s.downloadBlob, authMw),
|
||||
"GET /s5/metadata/:cid": s.downloadMetadata,
|
||||
"GET /s5/download/:cid": middleware.ApplyMiddlewares(s.downloadFile, middleware.ProxyMiddleware, defaultCors.Handler),
|
||||
"OPTIONS /s5/blob/:cid": middleware.ApplyMiddlewares(corsOptionsHandler, middleware.ProxyMiddleware, defaultCors.Handler, authMw),
|
||||
"OPTIONS /s5/metadata/:cid": middleware.ApplyMiddlewares(corsOptionsHandler, middleware.ProxyMiddleware, defaultCors.Handler),
|
||||
"OPTIONS /s5/download/:cid": middleware.ApplyMiddlewares(corsOptionsHandler, middleware.ProxyMiddleware, defaultCors.Handler),
|
||||
"GET /s5/download/:cid": middleware.ApplyMiddlewares(s.downloadFile, cors.Default().Handler),
|
||||
|
||||
// Pins API
|
||||
"POST /s5/pin/:cid": middleware.ApplyMiddlewares(s.accountPin, middleware.ProxyMiddleware, authMw),
|
||||
"DELETE /s5/delete/:cid": middleware.ApplyMiddlewares(s.accountPinDelete, middleware.ProxyMiddleware, authMw),
|
||||
"POST /s5/pin/:cid": middleware.ApplyMiddlewares(s.accountPin, authMw),
|
||||
"DELETE /s5/delete/:cid": middleware.ApplyMiddlewares(s.accountPinDelete, authMw),
|
||||
|
||||
// Debug API
|
||||
"GET /s5/debug/download_urls/:cid": middleware.ApplyMiddlewares(s.debugDownloadUrls, middleware.ProxyMiddleware, debugCors.Handler),
|
||||
"GET /s5/debug/storage_locations/:hash": middleware.ApplyMiddlewares(s.debugStorageLocations, middleware.ProxyMiddleware, debugCors.Handler),
|
||||
|
||||
// Registry API
|
||||
"GET /s5/registry": middleware.ApplyMiddlewares(s.registryQuery, middleware.ProxyMiddleware, authMw),
|
||||
"POST /s5/registry": middleware.ApplyMiddlewares(s.registrySet, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/registry/subscription": middleware.ApplyMiddlewares(s.registrySubscription, middleware.ProxyMiddleware, authMw),
|
||||
"GET /s5/registry": middleware.ApplyMiddlewares(s.registryQuery, authMw),
|
||||
"POST /s5/registry": middleware.ApplyMiddlewares(s.registrySet, authMw),
|
||||
"GET /s5/registry/subscription": middleware.ApplyMiddlewares(s.registrySubscription, authMw),
|
||||
}
|
||||
|
||||
routes, err := swagger.Swagger(swagSpec, routes)
|
||||
|
|
Loading…
Reference in New Issue