mirror of
https://github.com/drone-plugins/drone-webhook.git
synced 2026-06-04 18:24:05 +08:00
Merge pull request #58 from doubles-ss/master
Add support for Authorization type Bearer Token
This commit is contained in:
@@ -34,6 +34,17 @@ func main() {
|
|||||||
Usage: "password for basic auth",
|
Usage: "password for basic auth",
|
||||||
EnvVar: "PLUGIN_PASSWORD,WEBHOOK_PASSWORD",
|
EnvVar: "PLUGIN_PASSWORD,WEBHOOK_PASSWORD",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "token-value",
|
||||||
|
Usage: "token value",
|
||||||
|
EnvVar: "PLUGIN_TOKEN_VALUE,WEBHOOK_TOKEN_VALUE",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "token-type",
|
||||||
|
Usage: "type of token",
|
||||||
|
EnvVar: "PLUGIN_TOKEN_TYPE,WEBHOOK_TOKEN_TYPE",
|
||||||
|
Value: "Bearer",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "content-type",
|
Name: "content-type",
|
||||||
Usage: "content type",
|
Usage: "content type",
|
||||||
@@ -200,6 +211,8 @@ func run(c *cli.Context) error {
|
|||||||
Method: c.String("method"),
|
Method: c.String("method"),
|
||||||
Username: c.String("username"),
|
Username: c.String("username"),
|
||||||
Password: c.String("password"),
|
Password: c.String("password"),
|
||||||
|
TokenValue: c.String("token-value"),
|
||||||
|
TokenType: c.String("token-type"),
|
||||||
ContentType: c.String("content-type"),
|
ContentType: c.String("content-type"),
|
||||||
Template: c.String("template"),
|
Template: c.String("template"),
|
||||||
Headers: c.StringSlice("headers"),
|
Headers: c.StringSlice("headers"),
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ type (
|
|||||||
Method string
|
Method string
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
|
TokenValue string
|
||||||
|
TokenType string
|
||||||
ContentType string
|
ContentType string
|
||||||
Template string
|
Template string
|
||||||
Headers []string
|
Headers []string
|
||||||
@@ -141,6 +143,10 @@ func (p Plugin) Exec() error {
|
|||||||
req.SetBasicAuth(p.Config.Username, p.Config.Password)
|
req.SetBasicAuth(p.Config.Username, p.Config.Password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Config.TokenValue != "" {
|
||||||
|
req.Header.Set("Authorization", fmt.Sprintf("%s %s", p.Config.TokenType, p.Config.TokenValue))
|
||||||
|
}
|
||||||
|
|
||||||
client := http.DefaultClient
|
client := http.DefaultClient
|
||||||
|
|
||||||
if p.Config.SkipVerify {
|
if p.Config.SkipVerify {
|
||||||
|
|||||||
Reference in New Issue
Block a user