feature: Basic auth for web console#313
Open
zekiahmetbayar wants to merge 1 commit intohibiken:masterfrom
Open
feature: Basic auth for web console#313zekiahmetbayar wants to merge 1 commit intohibiken:masterfrom
zekiahmetbayar wants to merge 1 commit intohibiken:masterfrom
Conversation
Author
|
any update??? |
|
I've found another solution, without modifying the base code. Given the example with gorilla mux. First - create asynqmon handler var h = asynqmon.New(asynqmon.Options{
RootPath: "/monitoring",
RedisConnOpt: asynq.RedisClientOpt{
Addr: "localhost:6379",
DB: 0,
Password: "",
})Second - create gorilla mux sub-router with your middleware and attach handler for that route. monitoring := r.PathPrefix(h.RootPath()).Subrouter()
monitoring.Use(isAuthenticated, isAuthorised, exampleMiddleware)
monitoring.NewRoute().Handler(h)Important It is important to use NewRoute(), in order to be able to attach he handler. Bellow is the exampleMiddleware where you can add your logic. var exampleMiddleware = func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
allowed := true
if !allowed {
w.WriteHeader(http.StatusForbidden)
return
}
next.ServeHTTP(w, r.WithContext(ctx))
})
} |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I did not want everyone to read the data I wrote to the tasks, and encrypting and decrypting this data slowed down my application. For this reason, I researched whether there was a basic auth option and came across this. #78
When I saw that it was not yet available, I wanted to make an improvement for this application and I added basic auth.
Features: