/
userTemplateImporterIdentityProviderMapper.go
346 lines (295 loc) · 18.1 KB
/
userTemplateImporterIdentityProviderMapper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package keycloak
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Allows for creating and managing an username template importer identity provider mapper within Keycloak.
//
// The username template importer mapper can be used to map externally defined OIDC claims or SAML attributes with a template to the username of the imported Keycloak user:
//
// - Substitutions are enclosed in \${}. For example: '\${ALIAS}.\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
//
// > If you are using Keycloak 10 or higher, you will need to specify the `extraConfig` argument in order to define a `syncMode` for the mapper.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "fmt"
//
// "github.com/pulumi/pulumi-keycloak/sdk/v4/go/keycloak"
// "github.com/pulumi/pulumi-keycloak/sdk/v4/go/keycloak/oidc"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// realm, err := keycloak.NewRealm(ctx, "realm", &keycloak.RealmArgs{
// Realm: pulumi.String("my-realm"),
// Enabled: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// oidc, err := oidc.NewIdentityProvider(ctx, "oidc", &oidc.IdentityProviderArgs{
// Realm: realm.ID(),
// Alias: pulumi.String("oidc"),
// AuthorizationUrl: pulumi.String("https://example.com/auth"),
// TokenUrl: pulumi.String("https://example.com/token"),
// ClientId: pulumi.String("example_id"),
// ClientSecret: pulumi.String("example_token"),
// DefaultScopes: pulumi.String("openid random profile"),
// })
// if err != nil {
// return err
// }
// _, err = keycloak.NewUserTemplateImporterIdentityProviderMapper(ctx, "usernameImporter", &keycloak.UserTemplateImporterIdentityProviderMapperArgs{
// Realm: realm.ID(),
// IdentityProviderAlias: oidc.Alias,
// Template: pulumi.String(fmt.Sprintf("%v.%v", ALIAS, CLAIM.Email)),
// ExtraConfig: pulumi.AnyMap{
// "syncMode": pulumi.Any("INHERIT"),
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// Identity provider mappers can be imported using the format `{{realm_id}}/{{idp_alias}}/{{idp_mapper_id}}`, where `idp_alias` is the identity provider alias, and `idp_mapper_id` is the unique ID that Keycloak assigns to the mapper upon creation. This value can be found in the URI when editing this mapper in the GUI, and is typically a GUID. Examplebash
//
// ```sh
// $ pulumi import keycloak:index/userTemplateImporterIdentityProviderMapper:UserTemplateImporterIdentityProviderMapper username_importer my-realm/my-mapper/f446db98-7133-4e30-b18a-3d28fde7ca1b
// ```
type UserTemplateImporterIdentityProviderMapper struct {
pulumi.CustomResourceState
// Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
ExtraConfig pulumi.MapOutput `pulumi:"extraConfig"`
// The alias of the associated identity provider.
IdentityProviderAlias pulumi.StringOutput `pulumi:"identityProviderAlias"`
// The name of the mapper.
Name pulumi.StringOutput `pulumi:"name"`
// The name of the realm.
Realm pulumi.StringOutput `pulumi:"realm"`
// Template to use to format the username to import. Substitutions are enclosed in \${}. For example: '\$\${ALIAS}.\$\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
Template pulumi.StringPtrOutput `pulumi:"template"`
}
// NewUserTemplateImporterIdentityProviderMapper registers a new resource with the given unique name, arguments, and options.
func NewUserTemplateImporterIdentityProviderMapper(ctx *pulumi.Context,
name string, args *UserTemplateImporterIdentityProviderMapperArgs, opts ...pulumi.ResourceOption) (*UserTemplateImporterIdentityProviderMapper, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.IdentityProviderAlias == nil {
return nil, errors.New("invalid value for required argument 'IdentityProviderAlias'")
}
if args.Realm == nil {
return nil, errors.New("invalid value for required argument 'Realm'")
}
var resource UserTemplateImporterIdentityProviderMapper
err := ctx.RegisterResource("keycloak:index/userTemplateImporterIdentityProviderMapper:UserTemplateImporterIdentityProviderMapper", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetUserTemplateImporterIdentityProviderMapper gets an existing UserTemplateImporterIdentityProviderMapper resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetUserTemplateImporterIdentityProviderMapper(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *UserTemplateImporterIdentityProviderMapperState, opts ...pulumi.ResourceOption) (*UserTemplateImporterIdentityProviderMapper, error) {
var resource UserTemplateImporterIdentityProviderMapper
err := ctx.ReadResource("keycloak:index/userTemplateImporterIdentityProviderMapper:UserTemplateImporterIdentityProviderMapper", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering UserTemplateImporterIdentityProviderMapper resources.
type userTemplateImporterIdentityProviderMapperState struct {
// Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
ExtraConfig map[string]interface{} `pulumi:"extraConfig"`
// The alias of the associated identity provider.
IdentityProviderAlias *string `pulumi:"identityProviderAlias"`
// The name of the mapper.
Name *string `pulumi:"name"`
// The name of the realm.
Realm *string `pulumi:"realm"`
// Template to use to format the username to import. Substitutions are enclosed in \${}. For example: '\$\${ALIAS}.\$\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
Template *string `pulumi:"template"`
}
type UserTemplateImporterIdentityProviderMapperState struct {
// Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
ExtraConfig pulumi.MapInput
// The alias of the associated identity provider.
IdentityProviderAlias pulumi.StringPtrInput
// The name of the mapper.
Name pulumi.StringPtrInput
// The name of the realm.
Realm pulumi.StringPtrInput
// Template to use to format the username to import. Substitutions are enclosed in \${}. For example: '\$\${ALIAS}.\$\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
Template pulumi.StringPtrInput
}
func (UserTemplateImporterIdentityProviderMapperState) ElementType() reflect.Type {
return reflect.TypeOf((*userTemplateImporterIdentityProviderMapperState)(nil)).Elem()
}
type userTemplateImporterIdentityProviderMapperArgs struct {
// Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
ExtraConfig map[string]interface{} `pulumi:"extraConfig"`
// The alias of the associated identity provider.
IdentityProviderAlias string `pulumi:"identityProviderAlias"`
// The name of the mapper.
Name *string `pulumi:"name"`
// The name of the realm.
Realm string `pulumi:"realm"`
// Template to use to format the username to import. Substitutions are enclosed in \${}. For example: '\$\${ALIAS}.\$\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
Template *string `pulumi:"template"`
}
// The set of arguments for constructing a UserTemplateImporterIdentityProviderMapper resource.
type UserTemplateImporterIdentityProviderMapperArgs struct {
// Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
ExtraConfig pulumi.MapInput
// The alias of the associated identity provider.
IdentityProviderAlias pulumi.StringInput
// The name of the mapper.
Name pulumi.StringPtrInput
// The name of the realm.
Realm pulumi.StringInput
// Template to use to format the username to import. Substitutions are enclosed in \${}. For example: '\$\${ALIAS}.\$\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
Template pulumi.StringPtrInput
}
func (UserTemplateImporterIdentityProviderMapperArgs) ElementType() reflect.Type {
return reflect.TypeOf((*userTemplateImporterIdentityProviderMapperArgs)(nil)).Elem()
}
type UserTemplateImporterIdentityProviderMapperInput interface {
pulumi.Input
ToUserTemplateImporterIdentityProviderMapperOutput() UserTemplateImporterIdentityProviderMapperOutput
ToUserTemplateImporterIdentityProviderMapperOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperOutput
}
func (*UserTemplateImporterIdentityProviderMapper) ElementType() reflect.Type {
return reflect.TypeOf((**UserTemplateImporterIdentityProviderMapper)(nil)).Elem()
}
func (i *UserTemplateImporterIdentityProviderMapper) ToUserTemplateImporterIdentityProviderMapperOutput() UserTemplateImporterIdentityProviderMapperOutput {
return i.ToUserTemplateImporterIdentityProviderMapperOutputWithContext(context.Background())
}
func (i *UserTemplateImporterIdentityProviderMapper) ToUserTemplateImporterIdentityProviderMapperOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserTemplateImporterIdentityProviderMapperOutput)
}
// UserTemplateImporterIdentityProviderMapperArrayInput is an input type that accepts UserTemplateImporterIdentityProviderMapperArray and UserTemplateImporterIdentityProviderMapperArrayOutput values.
// You can construct a concrete instance of `UserTemplateImporterIdentityProviderMapperArrayInput` via:
//
// UserTemplateImporterIdentityProviderMapperArray{ UserTemplateImporterIdentityProviderMapperArgs{...} }
type UserTemplateImporterIdentityProviderMapperArrayInput interface {
pulumi.Input
ToUserTemplateImporterIdentityProviderMapperArrayOutput() UserTemplateImporterIdentityProviderMapperArrayOutput
ToUserTemplateImporterIdentityProviderMapperArrayOutputWithContext(context.Context) UserTemplateImporterIdentityProviderMapperArrayOutput
}
type UserTemplateImporterIdentityProviderMapperArray []UserTemplateImporterIdentityProviderMapperInput
func (UserTemplateImporterIdentityProviderMapperArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*UserTemplateImporterIdentityProviderMapper)(nil)).Elem()
}
func (i UserTemplateImporterIdentityProviderMapperArray) ToUserTemplateImporterIdentityProviderMapperArrayOutput() UserTemplateImporterIdentityProviderMapperArrayOutput {
return i.ToUserTemplateImporterIdentityProviderMapperArrayOutputWithContext(context.Background())
}
func (i UserTemplateImporterIdentityProviderMapperArray) ToUserTemplateImporterIdentityProviderMapperArrayOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserTemplateImporterIdentityProviderMapperArrayOutput)
}
// UserTemplateImporterIdentityProviderMapperMapInput is an input type that accepts UserTemplateImporterIdentityProviderMapperMap and UserTemplateImporterIdentityProviderMapperMapOutput values.
// You can construct a concrete instance of `UserTemplateImporterIdentityProviderMapperMapInput` via:
//
// UserTemplateImporterIdentityProviderMapperMap{ "key": UserTemplateImporterIdentityProviderMapperArgs{...} }
type UserTemplateImporterIdentityProviderMapperMapInput interface {
pulumi.Input
ToUserTemplateImporterIdentityProviderMapperMapOutput() UserTemplateImporterIdentityProviderMapperMapOutput
ToUserTemplateImporterIdentityProviderMapperMapOutputWithContext(context.Context) UserTemplateImporterIdentityProviderMapperMapOutput
}
type UserTemplateImporterIdentityProviderMapperMap map[string]UserTemplateImporterIdentityProviderMapperInput
func (UserTemplateImporterIdentityProviderMapperMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*UserTemplateImporterIdentityProviderMapper)(nil)).Elem()
}
func (i UserTemplateImporterIdentityProviderMapperMap) ToUserTemplateImporterIdentityProviderMapperMapOutput() UserTemplateImporterIdentityProviderMapperMapOutput {
return i.ToUserTemplateImporterIdentityProviderMapperMapOutputWithContext(context.Background())
}
func (i UserTemplateImporterIdentityProviderMapperMap) ToUserTemplateImporterIdentityProviderMapperMapOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(UserTemplateImporterIdentityProviderMapperMapOutput)
}
type UserTemplateImporterIdentityProviderMapperOutput struct{ *pulumi.OutputState }
func (UserTemplateImporterIdentityProviderMapperOutput) ElementType() reflect.Type {
return reflect.TypeOf((**UserTemplateImporterIdentityProviderMapper)(nil)).Elem()
}
func (o UserTemplateImporterIdentityProviderMapperOutput) ToUserTemplateImporterIdentityProviderMapperOutput() UserTemplateImporterIdentityProviderMapperOutput {
return o
}
func (o UserTemplateImporterIdentityProviderMapperOutput) ToUserTemplateImporterIdentityProviderMapperOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperOutput {
return o
}
// Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.
func (o UserTemplateImporterIdentityProviderMapperOutput) ExtraConfig() pulumi.MapOutput {
return o.ApplyT(func(v *UserTemplateImporterIdentityProviderMapper) pulumi.MapOutput { return v.ExtraConfig }).(pulumi.MapOutput)
}
// The alias of the associated identity provider.
func (o UserTemplateImporterIdentityProviderMapperOutput) IdentityProviderAlias() pulumi.StringOutput {
return o.ApplyT(func(v *UserTemplateImporterIdentityProviderMapper) pulumi.StringOutput {
return v.IdentityProviderAlias
}).(pulumi.StringOutput)
}
// The name of the mapper.
func (o UserTemplateImporterIdentityProviderMapperOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *UserTemplateImporterIdentityProviderMapper) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The name of the realm.
func (o UserTemplateImporterIdentityProviderMapperOutput) Realm() pulumi.StringOutput {
return o.ApplyT(func(v *UserTemplateImporterIdentityProviderMapper) pulumi.StringOutput { return v.Realm }).(pulumi.StringOutput)
}
// Template to use to format the username to import. Substitutions are enclosed in \${}. For example: '\$\${ALIAS}.\$\${CLAIM.sub}'. ALIAS is the provider alias. CLAIM.\<NAME\> references an ID or Access token claim.
func (o UserTemplateImporterIdentityProviderMapperOutput) Template() pulumi.StringPtrOutput {
return o.ApplyT(func(v *UserTemplateImporterIdentityProviderMapper) pulumi.StringPtrOutput { return v.Template }).(pulumi.StringPtrOutput)
}
type UserTemplateImporterIdentityProviderMapperArrayOutput struct{ *pulumi.OutputState }
func (UserTemplateImporterIdentityProviderMapperArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*UserTemplateImporterIdentityProviderMapper)(nil)).Elem()
}
func (o UserTemplateImporterIdentityProviderMapperArrayOutput) ToUserTemplateImporterIdentityProviderMapperArrayOutput() UserTemplateImporterIdentityProviderMapperArrayOutput {
return o
}
func (o UserTemplateImporterIdentityProviderMapperArrayOutput) ToUserTemplateImporterIdentityProviderMapperArrayOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperArrayOutput {
return o
}
func (o UserTemplateImporterIdentityProviderMapperArrayOutput) Index(i pulumi.IntInput) UserTemplateImporterIdentityProviderMapperOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *UserTemplateImporterIdentityProviderMapper {
return vs[0].([]*UserTemplateImporterIdentityProviderMapper)[vs[1].(int)]
}).(UserTemplateImporterIdentityProviderMapperOutput)
}
type UserTemplateImporterIdentityProviderMapperMapOutput struct{ *pulumi.OutputState }
func (UserTemplateImporterIdentityProviderMapperMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*UserTemplateImporterIdentityProviderMapper)(nil)).Elem()
}
func (o UserTemplateImporterIdentityProviderMapperMapOutput) ToUserTemplateImporterIdentityProviderMapperMapOutput() UserTemplateImporterIdentityProviderMapperMapOutput {
return o
}
func (o UserTemplateImporterIdentityProviderMapperMapOutput) ToUserTemplateImporterIdentityProviderMapperMapOutputWithContext(ctx context.Context) UserTemplateImporterIdentityProviderMapperMapOutput {
return o
}
func (o UserTemplateImporterIdentityProviderMapperMapOutput) MapIndex(k pulumi.StringInput) UserTemplateImporterIdentityProviderMapperOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *UserTemplateImporterIdentityProviderMapper {
return vs[0].(map[string]*UserTemplateImporterIdentityProviderMapper)[vs[1].(string)]
}).(UserTemplateImporterIdentityProviderMapperOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*UserTemplateImporterIdentityProviderMapperInput)(nil)).Elem(), &UserTemplateImporterIdentityProviderMapper{})
pulumi.RegisterInputType(reflect.TypeOf((*UserTemplateImporterIdentityProviderMapperArrayInput)(nil)).Elem(), UserTemplateImporterIdentityProviderMapperArray{})
pulumi.RegisterInputType(reflect.TypeOf((*UserTemplateImporterIdentityProviderMapperMapInput)(nil)).Elem(), UserTemplateImporterIdentityProviderMapperMap{})
pulumi.RegisterOutputType(UserTemplateImporterIdentityProviderMapperOutput{})
pulumi.RegisterOutputType(UserTemplateImporterIdentityProviderMapperArrayOutput{})
pulumi.RegisterOutputType(UserTemplateImporterIdentityProviderMapperMapOutput{})
}