Only allow authentication with explicit access token
Aiven supports creating never expiring, named access tokens. That is the
mechanism intended for implementation automation like Terraform. Drop
support for using explicit user credentials as those shouldn't be used.
package main
import (
- "errors"
"net/url"
"strings"
@@ -13,33 +12,11 @@ import (
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
- "email": {
- Type: schema.TypeString,
- Optional: true,
- Sensitive: true,
- Description: "Aiven email address",
- Default: "",
- },
- "otp": {
- Type: schema.TypeString,
- Optional: true,
- Sensitive: true,
- Description: "Aiven One-Time password",
- Default: "",
- },
- "password": {
- Type: schema.TypeString,
- Optional: true,
- Sensitive: true,
- Description: "Aiven password",
- Default: "",
- },
"api_token": {
Type: schema.TypeString,
- Optional: true,
+ Required: true,
Sensitive: true,
Description: "Aiven Authentication Token",
- Default: "",
},
},
@@ -57,19 +34,7 @@ func Provider() *schema.Provider {
},
ConfigureFunc: func(d *schema.ResourceData) (interface{}, error) {
- if d.Get("api_token") == "" && (d.Get("email") == "" || d.Get("password") == "") {
- return nil, errors.New("Must provide an API Token or email and password")
- }
- if d.Get("api_token") != "" {
- return aiven.NewTokenClient(
- d.Get("api_token").(string),
- )
- }
- return aiven.NewMFAUserClient(
- d.Get("email").(string),
- d.Get("otp").(string),
- d.Get("password").(string),
- )
+ return aiven.NewTokenClient(d.Get("api_token").(string))
},
}
}
