From 75b27becf26516a65549a00378155437e4acce4e Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 16 Oct 2023 16:10:14 +0200 Subject: Fix CORS by allowing everything --- main.go | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 5895b12..cf7e8a1 100644 --- a/main.go +++ b/main.go @@ -3,17 +3,18 @@ package main import ( "context" "fmt" - "git.deuxfleurs.fr/Deuxfleurs/bagage/s3" - "git.deuxfleurs.fr/Deuxfleurs/bagage/sftp" - "github.com/minio/minio-go/v7" - "github.com/minio/minio-go/v7/pkg/credentials" - "golang.org/x/crypto/ssh" "io" "io/ioutil" "log" "net" "net/http" "os" + + "git.deuxfleurs.fr/Deuxfleurs/bagage/s3" + "git.deuxfleurs.fr/Deuxfleurs/bagage/sftp" + "github.com/minio/minio-go/v7" + "github.com/minio/minio-go/v7/pkg/credentials" + "golang.org/x/crypto/ssh" ) func main() { @@ -176,17 +177,23 @@ func handleSSHConn(nConn net.Conn, dconfig *Config, config *ssh.ServerConfig) { func httpServer(config *Config, done chan error) { // Assemble components to handle WebDAV requests http.Handle(config.DavPath+"/", - BasicAuthExtract{ - OnNotFound: NotAuthorized{}, - OnCreds: LdapPreAuth{ - WithConfig: config, - OnWrongPassword: NotAuthorized{}, - OnFailure: InternalError{}, - OnCreds: S3Auth{ + CorsAllowAllOrigins{ + AndThen: BasicAuthExtract{ + OnNotFound: OptionsNoError{ + NotAuthorized{}, + }, + OnCreds: LdapPreAuth{ WithConfig: config, - OnFailure: InternalError{}, - OnMinioClient: WebDav{ + OnWrongPassword: OptionsNoError{ + Error: NotAuthorized{}, + }, + OnFailure: InternalError{}, + OnCreds: S3Auth{ WithConfig: config, + OnFailure: InternalError{}, + OnMinioClient: WebDav{ + WithConfig: config, + }, }, }, }, -- cgit v1.2.3