mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-09-28 19:05:33 +00:00
fix: simplify auth handling
This commit is contained in:
@@ -62,9 +62,6 @@ func main() {
|
||||
zap.S().Fatalf("error loading config: %v", err)
|
||||
}
|
||||
|
||||
// Create the authenticator
|
||||
authenticator := auth.NewAuthenticator(getSecret(), configStore)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// Create / load the operation log
|
||||
@@ -110,6 +107,7 @@ func main() {
|
||||
logStore,
|
||||
)
|
||||
|
||||
authenticator := auth.NewAuthenticator(getSecret(), configStore)
|
||||
apiAuthenticationHandler := api.NewAuthenticationHandler(authenticator)
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
oplog.*
|
||||
+1
-11
@@ -12,16 +12,6 @@ import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var (
|
||||
anonymousUser = &v1.User{
|
||||
Name: "default",
|
||||
Password: &v1.User_PasswordBcrypt{PasswordBcrypt: "JDJhJDEwJDNCdzJoNFlhaWFZQy9TSDN3ZGxSRHVPZHdzV2lsNmtBSHdFSmtIWHk1dS8wYjZuUWJrMGFx"}, // default password is "password"
|
||||
}
|
||||
defaultUsers = []*v1.User{
|
||||
anonymousUser,
|
||||
}
|
||||
)
|
||||
|
||||
type Authenticator struct {
|
||||
config config.ConfigStore
|
||||
key []byte
|
||||
@@ -43,7 +33,7 @@ func (a *Authenticator) Login(username, password string) (*v1.User, error) {
|
||||
return nil, fmt.Errorf("get config: %w", err)
|
||||
}
|
||||
auth := config.GetAuth()
|
||||
if auth.GetDisabled() {
|
||||
if auth == nil || auth.GetDisabled() {
|
||||
return nil, errors.New("authentication is disabled")
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ func validatePlan(plan *v1.Plan, repos map[string]*v1.Repo) error {
|
||||
}
|
||||
|
||||
func validateAuth(auth *v1.Auth) error {
|
||||
if auth.Disabled {
|
||||
if auth == nil || auth.Disabled {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -11,27 +11,6 @@ export const LoginModal = () => {
|
||||
const [form] = Form.useForm();
|
||||
const alertApi = useAlertApi()!;
|
||||
|
||||
useEffect(() => {
|
||||
authenticationService
|
||||
.login(
|
||||
new LoginRequest({
|
||||
username: "default",
|
||||
password: "password",
|
||||
})
|
||||
)
|
||||
.then((loginResponse) => {
|
||||
alertApi.success(
|
||||
"No users configured yet, logged in with default credentials",
|
||||
5
|
||||
);
|
||||
setAuthToken(loginResponse.token);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 500);
|
||||
})
|
||||
.catch((e) => {});
|
||||
}, []);
|
||||
|
||||
const onFinish = async (values: any) => {
|
||||
const loginReq = new LoginRequest({
|
||||
username: values.username,
|
||||
|
||||
Reference in New Issue
Block a user