mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-18 04:51:06 +01:00
added key auth support for rw operations (upload, non-expiring download)
This commit is contained in:
@@ -23,7 +23,6 @@ import (
|
||||
|
||||
const Version string = "v0.0.1"
|
||||
|
||||
var ApiVersion string = "/v1"
|
||||
var VERSION string // maintained by -x
|
||||
|
||||
type Config struct {
|
||||
@@ -31,6 +30,7 @@ type Config struct {
|
||||
Debug bool
|
||||
Retries int
|
||||
Expire string
|
||||
Apikey string
|
||||
}
|
||||
|
||||
func Getversion() string {
|
||||
|
||||
@@ -83,7 +83,8 @@ func Execute() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.Debug, "debug", "d", false, "Enable debugging")
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "custom config file")
|
||||
rootCmd.PersistentFlags().IntVarP(&conf.Retries, "retries", "r", 3, "How often shall we retry to access our endpoint")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Endpoint, "endpoint", "p", "http://localhost:8080/api", "upload api endpoint url")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Endpoint, "endpoint", "p", "http://localhost:8080/api/v1", "upload api endpoint url")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Apikey, "apikey", "a", "", "Api key to use")
|
||||
|
||||
rootCmd.AddCommand(UploadCommand(&conf))
|
||||
|
||||
|
||||
@@ -64,7 +64,11 @@ func Setup(c *cfg.Config, path string) *Request {
|
||||
})
|
||||
}
|
||||
|
||||
return &Request{Url: c.Endpoint + cfg.ApiVersion + "/file/", R: R}
|
||||
if len(c.Apikey) > 0 {
|
||||
client.SetCommonBearerAuthToken(c.Apikey)
|
||||
}
|
||||
|
||||
return &Request{Url: c.Endpoint + "/file/", R: R}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
endpoint = "http://localhost:8080/api"
|
||||
endpoint = "http://localhost:8080/api/v1"
|
||||
apikey = "970b391f22f515d96b3e9b86a2c62c627968828e47b356994d2e583188b4190a"
|
||||
|
||||
Reference in New Issue
Block a user