Skip to content
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

feature: Basic auth for web console #313

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zekiahmetbayar
Copy link

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:

  • Basic auth

@zekiahmetbayar
Copy link
Author

zekiahmetbayar commented Nov 11, 2023

Hey @hibiken, are you interested in this pr?

I think there are a lot of people who need it :) #78

@sh0umik
Copy link

sh0umik commented Nov 29, 2023

Hey @hibiken, are you interested in this pr?

I think there are a lot of people who need it :) #78

thx for the PR. I think this should be merged but its the author's wish, however, I will be using this in my code. thx a lot

@thanhfphan
Copy link

any update???

@emilhakobian
Copy link

emilhakobian commented Jul 18, 2024

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))

	})
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants