@@ -32,6 +32,7 @@ type PomeriumProvider struct {
32
32
type PomeriumProviderModel struct {
33
33
APIURL types.String `tfsdk:"api_url"`
34
34
ServiceAccountToken types.String `tfsdk:"service_account_token"`
35
+ SharedSecretB64 types.String `tfsdk:"shared_secret_b64"`
35
36
TLSInsecureSkipVerify types.Bool `tfsdk:"tls_insecure_skip_verify"`
36
37
}
37
38
@@ -49,7 +50,12 @@ func (p *PomeriumProvider) Schema(_ context.Context, _ provider.SchemaRequest, r
49
50
},
50
51
"service_account_token" : schema.StringAttribute {
51
52
MarkdownDescription : "Pomerium Enterprise Service Account Token" ,
52
- Required : true ,
53
+ Optional : true ,
54
+ Sensitive : true ,
55
+ },
56
+ "shared_secret_b64" : schema.StringAttribute {
57
+ MarkdownDescription : "Pomerium Shared Secret (base64 encoded)" ,
58
+ Optional : true ,
53
59
Sensitive : true ,
54
60
},
55
61
"tls_insecure_skip_verify" : schema.BoolAttribute {
@@ -88,13 +94,21 @@ func (p *PomeriumProvider) Configure(ctx context.Context, req provider.Configure
88
94
port = "443"
89
95
}
90
96
91
- if data .ServiceAccountToken .IsNull () {
92
- resp .Diagnostics .AddError ("service_account_token is required" , "service_account_token is required" )
97
+ tlsConfig := & tls.Config {InsecureSkipVerify : data .TLSInsecureSkipVerify .ValueBool ()}
98
+ var token string
99
+ if ! data .ServiceAccountToken .IsNull () {
100
+ token = data .ServiceAccountToken .ValueString ()
101
+ } else if ! data .SharedSecretB64 .IsNull () {
102
+ token , err = generateBootstrapServiceAccountToken (data .SharedSecretB64 .ValueString ())
103
+ if err != nil {
104
+ resp .Diagnostics .AddError ("failed to decode shared_secret_b64" , err .Error ())
105
+ return
106
+ }
107
+ } else {
108
+ resp .Diagnostics .AddError ("service_account_token or shared_secret_b64 is required" , "service_account_token or shared_secret_b64 is required" )
93
109
return
94
110
}
95
-
96
- tlsConfig := & tls.Config {InsecureSkipVerify : data .TLSInsecureSkipVerify .ValueBool ()}
97
- c , err := client .NewClient (ctx , net .JoinHostPort (host , port ), data .ServiceAccountToken .ValueString (), client .WithTlsConfig (tlsConfig ))
111
+ c , err := client .NewClient (ctx , net .JoinHostPort (host , port ), token , client .WithTlsConfig (tlsConfig ))
98
112
if err != nil {
99
113
resp .Diagnostics .AddError ("failed to create Pomerium Enterprise API client" , err .Error ())
100
114
return
0 commit comments