mirror of
https://github.com/1f349/jasmine.git
synced 2024-11-21 11:01:32 +00:00
Add nullauth for testing
This commit is contained in:
parent
c4c2d8bd33
commit
c2ed5662a7
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.22
|
||||
|
||||
require (
|
||||
git.sr.ht/~sircmpwn/tokidoki v0.0.0-20240419154046-4ca7d8c4e7ca
|
||||
github.com/1f349/cardcaldav v0.0.3
|
||||
github.com/1f349/cardcaldav v0.0.4
|
||||
github.com/1f349/violet v0.0.13
|
||||
github.com/charmbracelet/log v0.4.0
|
||||
github.com/emersion/go-webdav v0.5.1-0.20240419143909-21f251fa1de2
|
||||
|
4
go.sum
4
go.sum
@ -2,8 +2,8 @@ filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
git.sr.ht/~sircmpwn/tokidoki v0.0.0-20240419154046-4ca7d8c4e7ca h1:HBRu4nwicaaZ4oqwTis2qy4Gb/CKLA2OSlibdKpMhb8=
|
||||
git.sr.ht/~sircmpwn/tokidoki v0.0.0-20240419154046-4ca7d8c4e7ca/go.mod h1:/1jsi+vx9b/T8UHrDRJXwoY8td9JUXd9UajtVCpVoeg=
|
||||
github.com/1f349/cardcaldav v0.0.3 h1:c2/wmOf+hwgKdaWLlKm5v8l0g9brD+Seqcp+xIDUXJI=
|
||||
github.com/1f349/cardcaldav v0.0.3/go.mod h1:MCoGRimM7p/rLWtaJxYO91tsvgXZ47M69X3lldb5dfk=
|
||||
github.com/1f349/cardcaldav v0.0.4 h1:byhhQOFJ2JItbMBp9mUc1hn8KAE22iem8ico4/piyyA=
|
||||
github.com/1f349/cardcaldav v0.0.4/go.mod h1:MCoGRimM7p/rLWtaJxYO91tsvgXZ47M69X3lldb5dfk=
|
||||
github.com/1f349/violet v0.0.13 h1:lJpTz15Ea83Uc1VAISXTjtKuzr8Pe8NM4cMGp3Aiyhk=
|
||||
github.com/1f349/violet v0.0.13/go.mod h1:Ga5/hWqI+EkR6J1mAMNzs7aJhuGcA89XFqgQaDXC7Jo=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
|
22
nullauth.go
Normal file
22
nullauth.go
Normal file
@ -0,0 +1,22 @@
|
||||
//go:build nullauth
|
||||
|
||||
package jasmine
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type nullAuth struct{}
|
||||
|
||||
func (n *nullAuth) Middleware(next http.Handler) http.Handler {
|
||||
return next
|
||||
}
|
||||
|
||||
func (n *nullAuth) CurrentUserPrincipal(ctx context.Context) (string, error) {
|
||||
return "/jane@example.com/", nil
|
||||
}
|
||||
|
||||
func NullAuth(_ AuthProvider) AuthProvider {
|
||||
return &nullAuth{}
|
||||
}
|
7
nullauth_stub.go
Normal file
7
nullauth_stub.go
Normal file
@ -0,0 +1,7 @@
|
||||
//go:build !nullauth
|
||||
|
||||
package jasmine
|
||||
|
||||
func NullAuth(provider AuthProvider) AuthProvider {
|
||||
return provider
|
||||
}
|
@ -16,7 +16,7 @@ type Conf struct {
|
||||
}
|
||||
|
||||
type jasmineHandler struct {
|
||||
auth *cardcaldav.Auth
|
||||
auth AuthProvider
|
||||
backend caldav.Backend
|
||||
}
|
||||
|
||||
@ -55,9 +55,14 @@ func (j *jasmineHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
http.NotFound(rw, req)
|
||||
}
|
||||
|
||||
type AuthProvider interface {
|
||||
cardcaldav.ProviderMiddleware
|
||||
webdav.UserPrincipalBackend
|
||||
}
|
||||
|
||||
func NewHttpServer(conf Conf, wd string) *http.Server {
|
||||
cardcaldav.SetupLogger(Logger)
|
||||
principle := cardcaldav.NewAuth(conf.DB, Logger)
|
||||
principle := NullAuth(cardcaldav.NewAuth(conf.DB, Logger))
|
||||
|
||||
calStorage, _, err := storage.NewFilesystem(filepath.Join(wd, "storage"), "/calendar/", "/contacts/", principle)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user