Skip to content

Commit 38bdddf

Browse files
zmotsoSergK
authored andcommitted
feat: Add the ability to manage Realm Attributes (#85)
1 parent 97746ea commit 38bdddf

File tree

55 files changed

+3457
-988
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3457
-988
lines changed

.golangci.yaml

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,9 @@ run:
44
issues-exit-code: 1
55
build-tags:
66
- mytag
7-
skip-dirs:
8-
- "mocks"
9-
skip-dirs-use-default: true
10-
skip-files:
11-
- "mock_.*\\.go"
127

138
modules-download-mode: mod
14-
allow-parallel-runners: false
15-
16-
output:
17-
format: colored-line-number
18-
print-issued-lines: true
19-
20-
# print linter name in the end of issue text, default is true
21-
print-linter-name: true
22-
23-
# make issues output unique by line, default is true
24-
uniq-by-line: true
25-
26-
# add a prefix to the output file references; default is no prefix
27-
path-prefix: ""
28-
29-
# sorts results by: filepath, line and column
30-
sort-results: false
9+
allow-parallel-runners: true
3110

3211

3312
# all available settings of specific linters
@@ -66,11 +45,6 @@ linters-settings:
6645
# default is false: such cases aren't reported by default.
6746
check-blank: false
6847

69-
# [deprecated] comma-separated list of pairs of the form pkg:regex
70-
# the regex is used to ignore names within pkg. (default "fmt:.*").
71-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
72-
ignore: fmt:.*,io/ioutil:^Read.*
73-
7448
# # [deprecated] use exclude-functions instead.
7549
# # path to a file containing a list of functions to exclude from checking
7650
# # see https://github.com/kisielk/errcheck#excluding-functions for details
@@ -193,9 +167,9 @@ linters-settings:
193167
# By default list of stable checks is used.
194168
enabled-checks:
195169
- nestingReduce
196-
- unnamedresult
197170
- ruleguard
198171
- truncateCmp
172+
- unnamedResult
199173

200174
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
201175
disabled-checks:
@@ -302,9 +276,6 @@ linters-settings:
302276
simplify: true
303277

304278
gofumpt:
305-
# Select the Go version to target. The default is `1.15`.
306-
lang-version: "1.15"
307-
308279
# Choose whether or not to use the extra rules that are disabled
309280
# by default
310281
extra-rules: false
@@ -420,9 +391,6 @@ linters-settings:
420391
checks: [ "all" ]
421392

422393
govet:
423-
# report about shadowed variables
424-
check-shadowing: true
425-
426394
# settings per analyzer
427395
settings:
428396
printf: # analyzer name, run `go tool vet help` to see all analyzers
@@ -458,6 +426,7 @@ linters-settings:
458426
- nilness
459427
- printf
460428
- reflectvaluecompare
429+
- shadow
461430
- shift
462431
- sigchanyzer
463432
- sortslice
@@ -771,9 +740,8 @@ linters:
771740
- errchkjson
772741
- errname
773742
- errorlint
774-
- execinquery
775743
- exhaustive
776-
- exportloopref
744+
- copyloopvar
777745
- forbidigo
778746
- gci
779747
- goconst
@@ -785,19 +753,13 @@ linters:
785753
- ineffassign
786754
- typecheck
787755
- revive
788-
- megacheck
789756
- decorder
790757
- forcetypeassert
791758
- funlen
792759
- gochecknoinits
793760
- wrapcheck
794761
- wsl
795762
- unused
796-
797-
disabled:
798-
- exhaustruct
799-
- contextcheck #Disabled due to issue https://github.com/golangci/golangci-lint/issues/2649.
800-
- bodyclose #Disabled due to issue https://github.com/timakin/bodyclose/issues/30
801763
fast: false
802764

803765
issues:
@@ -836,6 +798,10 @@ issues:
836798
- cyclop
837799
- funlen
838800
text: 'Reconcile'
801+
exclude-files:
802+
- "mock_.*\\.go"
803+
exclude-dirs:
804+
- "mocks"
839805

840806
# Independently of option `exclude` we use default exclude patterns,
841807
# it can be disabled by this option. To list all

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ helm-docs: helmdocs ## generate helm docs
139139
GOLANGCILINT = ${CURRENT_DIR}/bin/golangci-lint
140140
.PHONY: golangci-lint
141141
golangci-lint: ## Download golangci-lint locally if necessary.
142-
$(call go-get-tool,$(GOLANGCILINT),github.com/golangci/golangci-lint/cmd/golangci-lint,v1.55.2)
142+
$(call go-get-tool,$(GOLANGCILINT),github.com/golangci/golangci-lint/cmd/golangci-lint,v1.62.0)
143143

144144
.PHONY: install
145145
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
@@ -218,4 +218,4 @@ mocks: mockery
218218
MOCKERY = $(LOCALBIN)/mockery
219219
.PHONY: mockery
220220
mockery: ## Download mockery locally if necessary.
221-
$(call go-get-tool,$(MOCKERY),github.com/vektra/mockery/v2,v2.43.0)
221+
$(call go-get-tool,$(MOCKERY),github.com/vektra/mockery/v2,v2.46.3)

api/common/realm.go

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// +kubebuilder:object:generate=true
12
package common
23

34
// TokenSettings is the configuration for tokens in the realm.
@@ -53,3 +54,108 @@ type TokenSettings struct {
5354
// +kubebuilder:default=43200
5455
ActionTokenGeneratedByAdminLifespan int `json:"actionTokenGeneratedByAdminLifespan,omitempty"`
5556
}
57+
58+
// UserProfileConfig defines the configuration for user profile in the realm.
59+
type UserProfileConfig struct {
60+
// UnmanagedAttributePolicy are user attributes not explicitly defined in the user profile configuration.
61+
// Empty value means that unmanaged attributes are disabled.
62+
// Possible values:
63+
// ENABLED - unmanaged attributes are allowed.
64+
// ADMIN_VIEW - unmanaged attributes are read-only and only available through the administration console and API.
65+
// ADMIN_EDIT - unmanaged attributes can be managed only through the administration console and API.
66+
// +optional
67+
UnmanagedAttributePolicy string `json:"unmanagedAttributePolicy,omitempty"`
68+
69+
// Attributes specifies the list of user profile attributes.
70+
Attributes []UserProfileAttribute `json:"attributes,omitempty"`
71+
72+
// Groups specifies the list of user profile groups.
73+
Groups []UserProfileGroup `json:"groups,omitempty"`
74+
}
75+
76+
type UserProfileAttribute struct {
77+
// Name of the user attribute, used to uniquely identify an attribute.
78+
// +required
79+
Name string `json:"name"`
80+
81+
// Display name for the attribute.
82+
DisplayName string `json:"displayName,omitempty"`
83+
84+
// Group to which the attribute belongs.
85+
Group string `json:"group,omitempty"`
86+
87+
// Multivalued specifies if this attribute supports multiple values.
88+
// This setting is an indicator and does not enable any validation
89+
Multivalued bool `json:"multivalued,omitempty"`
90+
91+
// Permissions specifies the permissions for the attribute.
92+
Permissions *UserProfileAttributePermissions `json:"permissions,omitempty"`
93+
94+
// Required indicates that the attribute must be set by users and administrators.
95+
Required *UserProfileAttributeRequired `json:"required,omitempty"`
96+
97+
// Selector specifies the scopes for which the attribute is available.
98+
Selector *UserProfileAttributeSelector `json:"selector,omitempty"`
99+
100+
// Annotations specifies the annotations for the attribute.
101+
Annotations map[string]string `json:"annotations,omitempty"`
102+
103+
// Validations specifies the validations for the attribute.
104+
Validations map[string]map[string]UserProfileAttributeValidation `json:"validations,omitempty"`
105+
}
106+
107+
type UserProfileAttributeValidation struct {
108+
// +optional
109+
StringVal string `json:"stringVal,omitempty"`
110+
111+
// +optional
112+
// +nullable
113+
MapVal map[string]string `json:"mapVal,omitempty"`
114+
115+
// +optional
116+
IntVal int `json:"intVal,omitempty"`
117+
118+
// +optional
119+
// +nullable
120+
SliceVal []string `json:"sliceVal,omitempty"`
121+
}
122+
123+
type UserProfileAttributePermissions struct {
124+
// Edit specifies who can edit the attribute.
125+
Edit []string `json:"edit,omitempty"`
126+
127+
// View specifies who can view the attribute.
128+
View []string `json:"view,omitempty"`
129+
}
130+
131+
// UserProfileAttributeRequired defines model for UserProfileAttributeRequired.
132+
type UserProfileAttributeRequired struct {
133+
// Roles specifies the roles for whom the attribute is required.
134+
Roles []string `json:"roles,omitempty"`
135+
136+
// Scopes specifies the scopes when the attribute is required.
137+
Scopes []string `json:"scopes,omitempty"`
138+
}
139+
140+
// UserProfileAttributeSelector defines model for UserProfileAttributeSelector.
141+
type UserProfileAttributeSelector struct {
142+
// Scopes specifies the scopes for which the attribute is available.
143+
Scopes []string `json:"scopes,omitempty"`
144+
}
145+
146+
type UserProfileGroup struct {
147+
// Name is unique name of the group.
148+
// +required
149+
Name string `json:"name"`
150+
151+
// Annotations specifies the annotations for the group.
152+
// +optional
153+
// nullable
154+
Annotations map[string]string `json:"annotations,omitempty"`
155+
156+
// DisplayDescription specifies a user-friendly name for the group that should be used when rendering a group of attributes in user-facing forms.
157+
DisplayDescription string `json:"displayDescription,omitempty"`
158+
159+
// DisplayHeader specifies a text that should be used as a header when rendering user-facing forms.
160+
DisplayHeader string `json:"displayHeader,omitempty"`
161+
}

api/common/ref.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ type RealmRef struct {
1818
Name string `json:"name,omitempty"`
1919
}
2020

21+
// +kubebuilder:object:generate=false
2122
type HasRealmRef interface {
2223
GetRealmRef() RealmRef
2324
}
2425

26+
// +kubebuilder:object:generate=false
2527
type HasKeycloakRef interface {
2628
GetKeycloakRef() KeycloakRef
2729
}

0 commit comments

Comments
 (0)