You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by "ninuxer (via GitHub)" <gi...@apache.org> on 2024/08/23 05:50:08 UTC

[PR] add api basic auth support [kvrocks-controller]

ninuxer opened a new pull request, #201:
URL: https://github.com/apache/kvrocks-controller/pull/201

   Implement basic auth for api interface base on gin middleware.
   
   Although gin has its own gin.BasicAuth() middleware, but I still implemented it by myself for future expansion.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "torwig (via GitHub)" <gi...@apache.org>.
torwig commented on code in PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#discussion_r1728403320


##########
config/config.go:
##########
@@ -55,6 +60,7 @@ type Config struct {
 	Zookeeper   *zookeeper.Config `yaml:"zookeeper"`
 	Admin       AdminConfig       `yaml:"admin"`
 	Controller  *ControllerConfig `yaml:"controller"`
+	ApiAuth     *ApiAuthConfig    `yaml:"apiAuth"`

Review Comment:
   I see that we we snake_case for yaml-tags in this file. Could you please adhere this convention?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "torwig (via GitHub)" <gi...@apache.org>.
torwig commented on code in PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#discussion_r1728403573


##########
config/config.go:
##########
@@ -37,6 +37,11 @@ type AdminConfig struct {
 	Addr string `yaml:"addr"`
 }
 
+type ApiAuthConfig struct {
+	ApiUser     string `yaml:"apiUser"`
+	ApiPassword string `yaml:"apiPassword"`

Review Comment:
   The same: yaml-tags.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "ninuxer (via GitHub)" <gi...@apache.org>.
ninuxer commented on PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#issuecomment-2306404135

   I will fix it, thanks
   
   > How to prove that the implementation is correct without tests?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "ninuxer (via GitHub)" <gi...@apache.org>.
ninuxer commented on PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#issuecomment-2306498524

   already fix and commit,my test case see
   ![image](https://github.com/user-attachments/assets/15667d84-6d7c-439a-83f3-052f2d3b45ad)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "torwig (via GitHub)" <gi...@apache.org>.
torwig commented on PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#issuecomment-2306350652

   How to prove that the implementation is correct without tests?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "ninuxer (via GitHub)" <gi...@apache.org>.
ninuxer closed pull request #201: add api basic auth support
URL: https://github.com/apache/kvrocks-controller/pull/201


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#issuecomment-2306535901

   ## [Codecov](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `0%` with `81 lines` in your changes missing coverage. Please review.
   > Project coverage is 42.27%. Comparing base [(`6c56470`)](https://app.codecov.io/gh/apache/kvrocks-controller/commit/6c564700d621ef30a182bad1bfeff0aa13db6ea7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`6f89f6d`)](https://app.codecov.io/gh/apache/kvrocks-controller/commit/6f89f6d729708e947c8cea08505f48ed77016c35?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 2 commits behind head on unstable.
   
   | [Files](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [server/middleware/middleware.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=server%2Fmiddleware%2Fmiddleware.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL21pZGRsZXdhcmUvbWlkZGxld2FyZS5nbw==) | 0.00% | [39 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/command/client.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fcommand%2Fclient.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9jb21tYW5kL2NsaWVudC5nbw==) | 0.00% | [7 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config/config.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=config%2Fconfig.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y29uZmlnL2NvbmZpZy5nbw==) | 0.00% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [server/route.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=server%2Froute.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c2VydmVyL3JvdXRlLmdv) | 0.00% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/main.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fmain.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9tYWluLmdv) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/command/create.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fcommand%2Fcreate.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9jb21tYW5kL2NyZWF0ZS5nbw==) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/command/delete.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fcommand%2Fdelete.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9jb21tYW5kL2RlbGV0ZS5nbw==) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/command/failover.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fcommand%2Ffailover.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9jb21tYW5kL2ZhaWxvdmVyLmdv) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/command/get.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fcommand%2Fget.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9jb21tYW5kL2dldC5nbw==) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [cmd/client/command/import.go](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&filepath=cmd%2Fclient%2Fcommand%2Fimport.go&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-Y21kL2NsaWVudC9jb21tYW5kL2ltcG9ydC5nbw==) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | ... and [2 more](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@             Coverage Diff              @@
   ##           unstable     #201      +/-   ##
   ============================================
   - Coverage     43.38%   42.27%   -1.11%     
   ============================================
     Files            37       37              
     Lines          2971     3049      +78     
   ============================================
     Hits           1289     1289              
   - Misses         1544     1622      +78     
     Partials        138      138              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [unittests](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `42.27% <0.00%> (-1.11%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/kvrocks-controller/pull/201?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "torwig (via GitHub)" <gi...@apache.org>.
torwig commented on code in PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#discussion_r1728407238


##########
server/route.go:
##########
@@ -36,6 +36,14 @@ func (srv *Server) initHandlers() {
 		c.Set(consts.ContextKeyStore, srv.store)
 		c.Next()
 	}, middleware.RedirectIfNotLeader)
+
+	if srv.config.ApiAuth.ApiUser != "" && srv.config.ApiAuth.ApiPassword != "" {

Review Comment:
   This condition can be extracted in a single method of config like config.AuthConfigured().



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add api basic auth support [kvrocks-controller]

Posted by "ninuxer (via GitHub)" <gi...@apache.org>.
ninuxer commented on PR #201:
URL: https://github.com/apache/kvrocks-controller/pull/201#issuecomment-2325686964

   Close the pr as it did not take into account the authentication of the web UI.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org