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

feat: add basic auth to stakerd routes #155

Merged
merged 14 commits into from
Mar 12, 2025
Merged

Conversation

RafilxTenfen
Copy link
Contributor

@RafilxTenfen RafilxTenfen commented Mar 11, 2025

  • Add basic auth to staker daemon routes
  • Add .env.example and tip on readme to add AUTH envs
  • Copy a few things from cometbft to add middleware in RPC routes

Closes: #153

@RafilxTenfen RafilxTenfen self-assigned this Mar 11, 2025
@RafilxTenfen RafilxTenfen marked this pull request as ready for review March 12, 2025 01:26
func BasicAuthMiddleware(expUsername, expPwd string) func(http.HandlerFunc) http.HandlerFunc {
return func(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
user, pass, ok := r.BasicAuth()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we can take some insipiration in how auth is done from btcd - https://github.com/btcsuite/btcd/blob/cba88226f49d5162c83c3edb562cc926edb4a87f/rpcserver.go#L4150 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems more complex, but I can those maps to the staker service and have the BasicAuthMiddleware as a method to check basic auth

	authsha                [sha256.Size]byte
	limitauthsha           [sha256.Size]byte

@RafilxTenfen RafilxTenfen merged commit cbe13c2 into main Mar 12, 2025
15 checks passed
RafilxTenfen added a commit that referenced this pull request Mar 13, 2025
* feat: add basic auth to stakerd routes

* chore: add #155 to cl

* chore: warn user about env

* chore: RPC from cometbft to add basic auth middleware

* fix: lint

* chore: add auth to stakercli requests

* chore: removed print for load .env

* chore: removed opaque set

* chore: add auth middleware to / as well

* chore: add comment for auth Rpc client

* chore: add auth env to manager

* chore: use vars

* fix: add client auth to e2e test
RafilxTenfen added a commit that referenced this pull request Mar 13, 2025
* feat: add basic auth to stakerd routes (#155)

* feat: add basic auth to stakerd routes

* chore: add #155 to cl

* chore: warn user about env

* chore: RPC from cometbft to add basic auth middleware

* fix: lint

* chore: add auth to stakercli requests

* chore: removed print for load .env

* chore: removed opaque set

* chore: add auth middleware to / as well

* chore: add comment for auth Rpc client

* chore: add auth env to manager

* chore: use vars

* fix: add client auth to e2e test

* chore: add env auth vars to StartManagerStakerApp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add password auth to authenticate between stakercli and stakerd
2 participants