-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sytle: further comment auth relative
- Loading branch information
1 parent
7f4ef73
commit f0fb2c7
Showing
5 changed files
with
58 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
package auth | ||
|
||
import ( | ||
"github.com/filebrowser/filebrowser/v2/settings" | ||
"github.com/filebrowser/filebrowser/v2/users" | ||
"net/http" | ||
) | ||
|
||
// Auther is the authentication interface. | ||
type Auther interface { | ||
// Auth is called to authenticate a request. | ||
Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error) | ||
// LoginPage indicates if this auther needs a login page. | ||
LoginPage() bool | ||
} | ||
//type Auther interface { | ||
// // Auth is called to authenticate a request. | ||
// Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error) | ||
// // LoginPage indicates if this auther needs a login page. | ||
// LoginPage() bool | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
package auth | ||
|
||
import ( | ||
"github.com/filebrowser/filebrowser/v2/settings" | ||
"github.com/filebrowser/filebrowser/v2/users" | ||
"net/http" | ||
) | ||
|
||
// MethodNoAuth is used to identify no auth. | ||
const MethodNoAuth settings.AuthMethod = "noauth" | ||
|
||
// NoAuth is no auth implementation of auther. | ||
type NoAuth struct{} | ||
|
||
// Auth uses authenticates user 1. | ||
func (a NoAuth) Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error) { | ||
return usr.Get(srv.Root, uint(1)) | ||
} | ||
|
||
// LoginPage tells that no auth doesn't require a login page. | ||
func (a NoAuth) LoginPage() bool { | ||
return false | ||
} | ||
//const MethodNoAuth settings.AuthMethod = "noauth" | ||
// | ||
//// NoAuth is no auth implementation of auther. | ||
//type NoAuth struct{} | ||
// | ||
//// Auth uses authenticates user 1. | ||
//func (a NoAuth) Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error) { | ||
// return usr.Get(srv.Root, uint(1)) | ||
//} | ||
// | ||
//// LoginPage tells that no auth doesn't require a login page. | ||
//func (a NoAuth) LoginPage() bool { | ||
// return false | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,29 @@ | ||
package auth | ||
|
||
import ( | ||
"github.com/filebrowser/filebrowser/v2/settings" | ||
"github.com/filebrowser/filebrowser/v2/users" | ||
) | ||
|
||
// StorageBackend is a storage backend for auth storage. | ||
type StorageBackend interface { | ||
Get(settings.AuthMethod) (Auther, error) | ||
Save(Auther) error | ||
} | ||
|
||
// Storage is a auth storage. | ||
type Storage struct { | ||
back StorageBackend | ||
users *users.Storage | ||
} | ||
|
||
// NewStorage creates a auth storage from a backend. | ||
func NewStorage(back StorageBackend, userStore *users.Storage) *Storage { | ||
return &Storage{back: back, users: userStore} | ||
} | ||
|
||
// Get wraps a StorageBackend.Get. | ||
func (s *Storage) Get(t settings.AuthMethod) (Auther, error) { | ||
return s.back.Get(t) | ||
} | ||
|
||
// Save wraps a StorageBackend.Save. | ||
func (s *Storage) Save(a Auther) error { | ||
return s.back.Save(a) | ||
} | ||
// | ||
//// StorageBackend is a storage backend for auth storage. | ||
//type StorageBackend interface { | ||
// Get(settings.AuthMethod) (Auther, error) | ||
// Save(Auther) error | ||
//} | ||
// | ||
//// Storage is a auth storage. | ||
//type Storage struct { | ||
// back StorageBackend | ||
// users *users.Storage | ||
//} | ||
// | ||
//// NewStorage creates a auth storage from a backend. | ||
//func NewStorage(back StorageBackend, userStore *users.Storage) *Storage { | ||
// return &Storage{back: back, users: userStore} | ||
//} | ||
// | ||
//// Get wraps a StorageBackend.Get. | ||
//func (s *Storage) Get(t settings.AuthMethod) (Auther, error) { | ||
// return s.back.Get(t) | ||
//} | ||
// | ||
//// Save wraps a StorageBackend.Save. | ||
//func (s *Storage) Save(a Auther) error { | ||
// return s.back.Save(a) | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
package storage | ||
|
||
import ( | ||
"github.com/filebrowser/filebrowser/v2/auth" | ||
"github.com/filebrowser/filebrowser/v2/settings" | ||
"github.com/filebrowser/filebrowser/v2/users" | ||
) | ||
|
||
// Storage is a storage powered by a Backend which makes the necessary | ||
// verifications when fetching and saving data to ensure consistency. | ||
type Storage struct { | ||
Users users.Store | ||
Auth *auth.Storage | ||
Users users.Store | ||
//Auth *auth.Storage | ||
Settings *settings.Storage | ||
} |