fix: simplify auth handling

This commit is contained in:
garethgeorge
2024-09-09 00:36:03 -07:00
parent 5dfd1abf3c
commit 4dc8e51e5b
5 changed files with 3 additions and 37 deletions
+1 -3
View File
@@ -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
View File
@@ -1 +0,0 @@
oplog.*
+1 -11
View File
@@ -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")
}
+1 -1
View File
@@ -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
}
-21
View File
@@ -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,