/
hardcodedAttributeMapper.go
363 lines (312 loc) · 14.7 KB
/
hardcodedAttributeMapper.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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
// 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 ldap
import (
"context"
"reflect"
"errors"
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Allows for creating and managing hardcoded attribute mappers for Keycloak users federated via LDAP.
//
// The LDAP hardcoded attribute mapper will set the specified value to the LDAP attribute.
//
// **NOTE**: This mapper only works when the `syncRegistrations` attribute on the `ldap.UserFederation` resource is set to `true`.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
// "github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/ldap"
// "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
// }
// ldapUserFederation, err := ldap.NewUserFederation(ctx, "ldapUserFederation", &ldap.UserFederationArgs{
// RealmId: realm.ID(),
// UsernameLdapAttribute: pulumi.String("cn"),
// RdnLdapAttribute: pulumi.String("cn"),
// UuidLdapAttribute: pulumi.String("entryDN"),
// UserObjectClasses: pulumi.StringArray{
// pulumi.String("simpleSecurityObject"),
// pulumi.String("organizationalRole"),
// },
// ConnectionUrl: pulumi.String("ldap://openldap"),
// UsersDn: pulumi.String("dc=example,dc=org"),
// BindDn: pulumi.String("cn=admin,dc=example,dc=org"),
// BindCredential: pulumi.String("admin"),
// SyncRegistrations: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// _, err = ldap.NewHardcodedAttributeMapper(ctx, "assignBarToFoo", &ldap.HardcodedAttributeMapperArgs{
// RealmId: realm.ID(),
// LdapUserFederationId: ldapUserFederation.ID(),
// AttributeName: pulumi.String("foo"),
// AttributeValue: pulumi.String("bar"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// LDAP mappers can be imported using the format `{{realm_id}}/{{ldap_user_federation_id}}/{{ldap_mapper_id}}`.
//
// The ID of the LDAP user federation provider and the mapper can be found within the Keycloak GUI, and they are typically GUIDs.
//
// Example:
//
// bash
//
// ```sh
// $ pulumi import keycloak:ldap/hardcodedAttributeMapper:HardcodedAttributeMapper assign_bar_to_foo my-realm/af2a6ca3-e4d7-49c3-b08b-1b3c70b4b860/3d923ece-1a91-4bf7-adaf-3b82f2a12b67
// ```
type HardcodedAttributeMapper struct {
pulumi.CustomResourceState
// The name of the LDAP attribute to set.
AttributeName pulumi.StringOutput `pulumi:"attributeName"`
// The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
AttributeValue pulumi.StringOutput `pulumi:"attributeValue"`
// The ID of the LDAP user federation provider to attach this mapper to.
LdapUserFederationId pulumi.StringOutput `pulumi:"ldapUserFederationId"`
// Display name of this mapper when displayed in the console.
Name pulumi.StringOutput `pulumi:"name"`
// The realm that this LDAP mapper will exist in.
RealmId pulumi.StringOutput `pulumi:"realmId"`
}
// NewHardcodedAttributeMapper registers a new resource with the given unique name, arguments, and options.
func NewHardcodedAttributeMapper(ctx *pulumi.Context,
name string, args *HardcodedAttributeMapperArgs, opts ...pulumi.ResourceOption) (*HardcodedAttributeMapper, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.AttributeName == nil {
return nil, errors.New("invalid value for required argument 'AttributeName'")
}
if args.AttributeValue == nil {
return nil, errors.New("invalid value for required argument 'AttributeValue'")
}
if args.LdapUserFederationId == nil {
return nil, errors.New("invalid value for required argument 'LdapUserFederationId'")
}
if args.RealmId == nil {
return nil, errors.New("invalid value for required argument 'RealmId'")
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource HardcodedAttributeMapper
err := ctx.RegisterResource("keycloak:ldap/hardcodedAttributeMapper:HardcodedAttributeMapper", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetHardcodedAttributeMapper gets an existing HardcodedAttributeMapper 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 GetHardcodedAttributeMapper(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *HardcodedAttributeMapperState, opts ...pulumi.ResourceOption) (*HardcodedAttributeMapper, error) {
var resource HardcodedAttributeMapper
err := ctx.ReadResource("keycloak:ldap/hardcodedAttributeMapper:HardcodedAttributeMapper", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering HardcodedAttributeMapper resources.
type hardcodedAttributeMapperState struct {
// The name of the LDAP attribute to set.
AttributeName *string `pulumi:"attributeName"`
// The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
AttributeValue *string `pulumi:"attributeValue"`
// The ID of the LDAP user federation provider to attach this mapper to.
LdapUserFederationId *string `pulumi:"ldapUserFederationId"`
// Display name of this mapper when displayed in the console.
Name *string `pulumi:"name"`
// The realm that this LDAP mapper will exist in.
RealmId *string `pulumi:"realmId"`
}
type HardcodedAttributeMapperState struct {
// The name of the LDAP attribute to set.
AttributeName pulumi.StringPtrInput
// The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
AttributeValue pulumi.StringPtrInput
// The ID of the LDAP user federation provider to attach this mapper to.
LdapUserFederationId pulumi.StringPtrInput
// Display name of this mapper when displayed in the console.
Name pulumi.StringPtrInput
// The realm that this LDAP mapper will exist in.
RealmId pulumi.StringPtrInput
}
func (HardcodedAttributeMapperState) ElementType() reflect.Type {
return reflect.TypeOf((*hardcodedAttributeMapperState)(nil)).Elem()
}
type hardcodedAttributeMapperArgs struct {
// The name of the LDAP attribute to set.
AttributeName string `pulumi:"attributeName"`
// The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
AttributeValue string `pulumi:"attributeValue"`
// The ID of the LDAP user federation provider to attach this mapper to.
LdapUserFederationId string `pulumi:"ldapUserFederationId"`
// Display name of this mapper when displayed in the console.
Name *string `pulumi:"name"`
// The realm that this LDAP mapper will exist in.
RealmId string `pulumi:"realmId"`
}
// The set of arguments for constructing a HardcodedAttributeMapper resource.
type HardcodedAttributeMapperArgs struct {
// The name of the LDAP attribute to set.
AttributeName pulumi.StringInput
// The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
AttributeValue pulumi.StringInput
// The ID of the LDAP user federation provider to attach this mapper to.
LdapUserFederationId pulumi.StringInput
// Display name of this mapper when displayed in the console.
Name pulumi.StringPtrInput
// The realm that this LDAP mapper will exist in.
RealmId pulumi.StringInput
}
func (HardcodedAttributeMapperArgs) ElementType() reflect.Type {
return reflect.TypeOf((*hardcodedAttributeMapperArgs)(nil)).Elem()
}
type HardcodedAttributeMapperInput interface {
pulumi.Input
ToHardcodedAttributeMapperOutput() HardcodedAttributeMapperOutput
ToHardcodedAttributeMapperOutputWithContext(ctx context.Context) HardcodedAttributeMapperOutput
}
func (*HardcodedAttributeMapper) ElementType() reflect.Type {
return reflect.TypeOf((**HardcodedAttributeMapper)(nil)).Elem()
}
func (i *HardcodedAttributeMapper) ToHardcodedAttributeMapperOutput() HardcodedAttributeMapperOutput {
return i.ToHardcodedAttributeMapperOutputWithContext(context.Background())
}
func (i *HardcodedAttributeMapper) ToHardcodedAttributeMapperOutputWithContext(ctx context.Context) HardcodedAttributeMapperOutput {
return pulumi.ToOutputWithContext(ctx, i).(HardcodedAttributeMapperOutput)
}
// HardcodedAttributeMapperArrayInput is an input type that accepts HardcodedAttributeMapperArray and HardcodedAttributeMapperArrayOutput values.
// You can construct a concrete instance of `HardcodedAttributeMapperArrayInput` via:
//
// HardcodedAttributeMapperArray{ HardcodedAttributeMapperArgs{...} }
type HardcodedAttributeMapperArrayInput interface {
pulumi.Input
ToHardcodedAttributeMapperArrayOutput() HardcodedAttributeMapperArrayOutput
ToHardcodedAttributeMapperArrayOutputWithContext(context.Context) HardcodedAttributeMapperArrayOutput
}
type HardcodedAttributeMapperArray []HardcodedAttributeMapperInput
func (HardcodedAttributeMapperArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*HardcodedAttributeMapper)(nil)).Elem()
}
func (i HardcodedAttributeMapperArray) ToHardcodedAttributeMapperArrayOutput() HardcodedAttributeMapperArrayOutput {
return i.ToHardcodedAttributeMapperArrayOutputWithContext(context.Background())
}
func (i HardcodedAttributeMapperArray) ToHardcodedAttributeMapperArrayOutputWithContext(ctx context.Context) HardcodedAttributeMapperArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(HardcodedAttributeMapperArrayOutput)
}
// HardcodedAttributeMapperMapInput is an input type that accepts HardcodedAttributeMapperMap and HardcodedAttributeMapperMapOutput values.
// You can construct a concrete instance of `HardcodedAttributeMapperMapInput` via:
//
// HardcodedAttributeMapperMap{ "key": HardcodedAttributeMapperArgs{...} }
type HardcodedAttributeMapperMapInput interface {
pulumi.Input
ToHardcodedAttributeMapperMapOutput() HardcodedAttributeMapperMapOutput
ToHardcodedAttributeMapperMapOutputWithContext(context.Context) HardcodedAttributeMapperMapOutput
}
type HardcodedAttributeMapperMap map[string]HardcodedAttributeMapperInput
func (HardcodedAttributeMapperMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*HardcodedAttributeMapper)(nil)).Elem()
}
func (i HardcodedAttributeMapperMap) ToHardcodedAttributeMapperMapOutput() HardcodedAttributeMapperMapOutput {
return i.ToHardcodedAttributeMapperMapOutputWithContext(context.Background())
}
func (i HardcodedAttributeMapperMap) ToHardcodedAttributeMapperMapOutputWithContext(ctx context.Context) HardcodedAttributeMapperMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(HardcodedAttributeMapperMapOutput)
}
type HardcodedAttributeMapperOutput struct{ *pulumi.OutputState }
func (HardcodedAttributeMapperOutput) ElementType() reflect.Type {
return reflect.TypeOf((**HardcodedAttributeMapper)(nil)).Elem()
}
func (o HardcodedAttributeMapperOutput) ToHardcodedAttributeMapperOutput() HardcodedAttributeMapperOutput {
return o
}
func (o HardcodedAttributeMapperOutput) ToHardcodedAttributeMapperOutputWithContext(ctx context.Context) HardcodedAttributeMapperOutput {
return o
}
// The name of the LDAP attribute to set.
func (o HardcodedAttributeMapperOutput) AttributeName() pulumi.StringOutput {
return o.ApplyT(func(v *HardcodedAttributeMapper) pulumi.StringOutput { return v.AttributeName }).(pulumi.StringOutput)
}
// The value to set to the LDAP attribute. You can hardcode any value like 'foo'.
func (o HardcodedAttributeMapperOutput) AttributeValue() pulumi.StringOutput {
return o.ApplyT(func(v *HardcodedAttributeMapper) pulumi.StringOutput { return v.AttributeValue }).(pulumi.StringOutput)
}
// The ID of the LDAP user federation provider to attach this mapper to.
func (o HardcodedAttributeMapperOutput) LdapUserFederationId() pulumi.StringOutput {
return o.ApplyT(func(v *HardcodedAttributeMapper) pulumi.StringOutput { return v.LdapUserFederationId }).(pulumi.StringOutput)
}
// Display name of this mapper when displayed in the console.
func (o HardcodedAttributeMapperOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *HardcodedAttributeMapper) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// The realm that this LDAP mapper will exist in.
func (o HardcodedAttributeMapperOutput) RealmId() pulumi.StringOutput {
return o.ApplyT(func(v *HardcodedAttributeMapper) pulumi.StringOutput { return v.RealmId }).(pulumi.StringOutput)
}
type HardcodedAttributeMapperArrayOutput struct{ *pulumi.OutputState }
func (HardcodedAttributeMapperArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*HardcodedAttributeMapper)(nil)).Elem()
}
func (o HardcodedAttributeMapperArrayOutput) ToHardcodedAttributeMapperArrayOutput() HardcodedAttributeMapperArrayOutput {
return o
}
func (o HardcodedAttributeMapperArrayOutput) ToHardcodedAttributeMapperArrayOutputWithContext(ctx context.Context) HardcodedAttributeMapperArrayOutput {
return o
}
func (o HardcodedAttributeMapperArrayOutput) Index(i pulumi.IntInput) HardcodedAttributeMapperOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *HardcodedAttributeMapper {
return vs[0].([]*HardcodedAttributeMapper)[vs[1].(int)]
}).(HardcodedAttributeMapperOutput)
}
type HardcodedAttributeMapperMapOutput struct{ *pulumi.OutputState }
func (HardcodedAttributeMapperMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*HardcodedAttributeMapper)(nil)).Elem()
}
func (o HardcodedAttributeMapperMapOutput) ToHardcodedAttributeMapperMapOutput() HardcodedAttributeMapperMapOutput {
return o
}
func (o HardcodedAttributeMapperMapOutput) ToHardcodedAttributeMapperMapOutputWithContext(ctx context.Context) HardcodedAttributeMapperMapOutput {
return o
}
func (o HardcodedAttributeMapperMapOutput) MapIndex(k pulumi.StringInput) HardcodedAttributeMapperOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *HardcodedAttributeMapper {
return vs[0].(map[string]*HardcodedAttributeMapper)[vs[1].(string)]
}).(HardcodedAttributeMapperOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*HardcodedAttributeMapperInput)(nil)).Elem(), &HardcodedAttributeMapper{})
pulumi.RegisterInputType(reflect.TypeOf((*HardcodedAttributeMapperArrayInput)(nil)).Elem(), HardcodedAttributeMapperArray{})
pulumi.RegisterInputType(reflect.TypeOf((*HardcodedAttributeMapperMapInput)(nil)).Elem(), HardcodedAttributeMapperMap{})
pulumi.RegisterOutputType(HardcodedAttributeMapperOutput{})
pulumi.RegisterOutputType(HardcodedAttributeMapperArrayOutput{})
pulumi.RegisterOutputType(HardcodedAttributeMapperMapOutput{})
}