-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Basic RBAC using the gauth library #243
Conversation
Sigrid maintainability feedback✅ You wrote maintainable code and achieved your Sigrid objective of 3.8 stars Show detailsSigrid compared your code against the baseline of 2024-12-09. 👍 What went well?
👎 What could be better?
📚 Remaining technical debt
View this system in Sigrid** to explore your technical debt ⭐️ Sigrid ratings
Did you find this feedback helpful?We would like to know your thoughts to make Sigrid better. |
internal/controller/controller.go
Outdated
err := mainController.setupDatabase() | ||
err = mainController.setupDatabase() | ||
if err != nil { | ||
log.Error(err) | ||
log.Error("Failed to setup database:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change?
internal/controller/controller.go
Outdated
authEnabledStr := utils.GetEnv("AUTH_ENABLED", "false") | ||
authEnabled, err := strconv.ParseBool(authEnabledStr) | ||
if err != nil { | ||
log.Error(err) | ||
return err | ||
} | ||
|
||
var auth *gauth.Authenticator | ||
if authEnabled { | ||
auth, err = gauth.New(gauth.DefaultConfig()) | ||
if err != nil { | ||
log.Error("Failed to initialize authenticator:", err) | ||
return err | ||
} | ||
routes.Middlewares(app, auth.LoadAuthContext(), auth.Middleware([]string{"admin", "soarca"})) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This must be in it's own function
113b84d
to
cdfbb25
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also fix the Sigrid error
.env.example
Outdated
|
||
AUTH_ENABLED: false #OPTIONAL for OIDC Based auth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is irrelevant
internal/controller/controller.go
Outdated
|
||
authEnabledStr := utils.GetEnv("AUTH_ENABLED", "false") | ||
authEnabled, err := strconv.ParseBool(authEnabledStr) | ||
if err != nil { | ||
log.Error(err) | ||
return err | ||
} | ||
routes.Cors(app, origins) | ||
|
||
err := mainController.setupDatabase() | ||
var auth *gauth.Authenticator | ||
if authEnabled { | ||
auth, err = gauth.New(gauth.DefaultConfig()) | ||
if err != nil { | ||
log.Error("Failed to initialize authenticator:", err) | ||
return err | ||
} | ||
app.Use(auth.LoadAuthContext()) | ||
app.Use(auth.Middleware([]string{"admin"})) | ||
} | ||
|
||
err = mainController.setupDatabase() | ||
if err != nil { | ||
log.Error(err) | ||
log.Error("Failed to setup database:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not core initialisation it can be moved into a different function
This reverts commit 4f0da89.
b0143cb
to
1eb56a4
Compare
Closes #107