Skip to content

Commit 99ab687

Browse files
authored
User Profile - Remove profile.user.active field (#85856)
The profile document has two boolean fields, profile.enabled and profile.user.active. The intention was that profile.enabled=false means the profile is not searchable (somewhat equivalent to being deleted) and profile.user.active=false means the profile is searchable but may not be assignable (in Kibana). However we don't currently have a concrete requirement for the later. Also we don't provide an API so far to set profile.user.active to false. Hence we agree to leave this field out till we have a better requirement for it.
1 parent 1269378 commit 99ab687

File tree

10 files changed

+19
-53
lines changed

10 files changed

+19
-53
lines changed

x-pack/docs/en/rest-api/security/activate-user-profile.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ The API returns the following response:
113113
],
114114
"realm_name": "native",
115115
"full_name": "Jack Nicholson",
116-
"email": "[email protected]",
117-
"active": true
116+
"email": "[email protected]"
118117
},
119118
"labels": {},
120119
"data": {},

x-pack/docs/en/rest-api/security/get-user-profile.asciidoc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ The API returns the following response for a `uid` matching `u_kd2JMqwUQwSCCOxMv
7676
],
7777
"realm_name": "native1",
7878
"full_name": "Jack Nicholson",
79-
"email": "[email protected]",
80-
"active": true
79+
"email": "[email protected]"
8180
},
8281
"labels": {},
8382
"data": {}, <1>
@@ -117,8 +116,7 @@ GET /_security/profile/u_kd2JMqwUQwSCCOxMv7M1vw?data=app1.key1
117116
],
118117
"realm_name": "native1",
119118
"full_name": "Jack Nicholson",
120-
"email": "[email protected]",
121-
"active": true
119+
"email": "[email protected]"
122120
},
123121
"labels": {},
124122
"data": {

x-pack/docs/en/rest-api/security/suggest-user-profile.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ The API returns:
9090
"full_name": "Jack Nicholson",
9191
"email": "[email protected]",
9292
"roles": [ "admin", "other_role1" ],
93-
"realm_name": "native1",
94-
"active": true
93+
"realm_name": "native1"
9594
}
9695
}
9796
]

x-pack/docs/en/rest-api/security/update-user-profile-data.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ If you run the request again, the consolidated profile data is returned:
147147
],
148148
"realm_name": "native1",
149149
"full_name": "Jack Nicholson",
150-
"email": "[email protected]",
151-
"active": true
150+
"email": "[email protected]"
152151
},
153152
"labels": {
154153
"app1": {

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/profile/Profile.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ public record ProfileUser(
3737
String realmName,
3838
@Nullable String domainName,
3939
String email,
40-
String fullName,
41-
boolean active
40+
String fullName
4241
) implements Writeable, ToXContent {
4342

4443
public ProfileUser(StreamInput in) throws IOException {
@@ -48,8 +47,7 @@ public ProfileUser(StreamInput in) throws IOException {
4847
in.readString(),
4948
in.readOptionalString(),
5049
in.readOptionalString(),
51-
in.readOptionalString(),
52-
in.readBoolean()
50+
in.readOptionalString()
5351
);
5452
}
5553

@@ -72,7 +70,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
7270
if (fullName != null) {
7371
builder.field("full_name", fullName);
7472
}
75-
builder.field("active", active);
7673
builder.endObject();
7774
return builder;
7875
}
@@ -85,7 +82,6 @@ public void writeTo(StreamOutput out) throws IOException {
8582
out.writeOptionalString(domainName);
8683
out.writeOptionalString(email);
8784
out.writeOptionalString(fullName);
88-
out.writeBoolean(active);
8985
}
9086
}
9187

x-pack/plugin/security/qa/profile/src/javaRestTest/java/org/elasticsearch/xpack/security/profile/ProfileIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public class ProfileIT extends ESRestTestCase {
5656
"node_name": "node1"
5757
},
5858
"email": "[email protected]",
59-
"full_name": "User Foo",
60-
"active": true
59+
"full_name": "User Foo"
6160
},
6261
"last_synchronized": %s,
6362
"labels": {

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileDocument.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ public record ProfileDocument(
4444
BytesReference applicationData
4545
) implements ToXContentObject {
4646

47-
public record ProfileDocumentUser(
48-
String username,
49-
List<String> roles,
50-
Authentication.RealmRef realm,
51-
String email,
52-
String fullName,
53-
boolean active
54-
) implements ToXContent {
47+
public record ProfileDocumentUser(String username, List<String> roles, Authentication.RealmRef realm, String email, String fullName)
48+
implements
49+
ToXContent {
5550

5651
@Override
5752
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
@@ -61,14 +56,13 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
6156
builder.field("realm", realm);
6257
builder.field("email", email);
6358
builder.field("full_name", fullName);
64-
builder.field("active", active);
6559
builder.endObject();
6660
return builder;
6761
}
6862

6963
public Profile.ProfileUser toProfileUser() {
7064
final String domainName = realm.getDomain() != null ? realm.getDomain().name() : null;
71-
return new Profile.ProfileUser(username, roles, realm.getName(), domainName, email, fullName, active);
65+
return new Profile.ProfileUser(username, roles, realm.getName(), domainName, email, fullName);
7266
}
7367
}
7468

@@ -96,7 +90,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
9690

9791
public Subject subject() {
9892
return new Subject(
99-
new User(user.username, user.roles.toArray(String[]::new), user.fullName, user.email, Map.of(), user.active),
93+
new User(user.username, user.roles.toArray(String[]::new), user.fullName, user.email, Map.of(), true),
10094
user.realm
10195
);
10296
}
@@ -118,8 +112,7 @@ static ProfileDocument fromSubjectWithUid(Subject subject, String uid) {
118112
Arrays.asList(subjectUser.roles()),
119113
subject.getRealm(),
120114
subjectUser.email(),
121-
subjectUser.fullName(),
122-
subjectUser.enabled()
115+
subjectUser.fullName()
123116
),
124117
Map.of(),
125118
null
@@ -162,8 +155,7 @@ public static ProfileDocument fromXContent(XContentParser parser) {
162155
(List<String>) args[1],
163156
(Authentication.RealmRef) args[2],
164157
(String) args[3],
165-
(String) args[4],
166-
(Boolean) args[5]
158+
(String) args[4]
167159
)
168160
);
169161

@@ -193,7 +185,6 @@ public static ProfileDocument fromXContent(XContentParser parser) {
193185
PROFILE_DOC_USER_PARSER.declareObject(constructorArg(), (p, c) -> REALM_REF_PARSER.parse(p, c), new ParseField("realm"));
194186
PROFILE_DOC_USER_PARSER.declareStringOrNull(optionalConstructorArg(), new ParseField("email"));
195187
PROFILE_DOC_USER_PARSER.declareStringOrNull(optionalConstructorArg(), new ParseField("full_name"));
196-
PROFILE_DOC_USER_PARSER.declareBoolean(constructorArg(), new ParseField("active"));
197188

198189
PROFILE_DOC_PARSER.declareString(constructorArg(), new ParseField("uid"));
199190
PROFILE_DOC_PARSER.declareBoolean(constructorArg(), new ParseField("enabled"));

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/profile/ProfileService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,7 @@ private static ProfileDocument updateWithSubject(ProfileDocument doc, Subject su
617617
subject.getRealm(),
618618
// Replace with incoming information even when they are null
619619
subjectUser.email(),
620-
subjectUser.fullName(),
621-
subjectUser.enabled()
620+
subjectUser.fullName()
622621
),
623622
doc.labels(),
624623
doc.applicationData()

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecuritySystemIndices.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,6 @@ private XContentBuilder getProfileIndexMappings() {
833833
builder.startObject("full_name");
834834
builder.field("type", "search_as_you_type");
835835
builder.endObject();
836-
837-
builder.startObject("active");
838-
builder.field("type", "boolean");
839-
builder.endObject();
840836
}
841837
builder.endObject();
842838
}

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/profile/ProfileServiceTests.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ public class ProfileServiceTests extends ESTestCase {
8080
"node_name": "node1"
8181
},
8282
"email": "[email protected]",
83-
"full_name": "User Foo",
84-
"active": true
83+
"full_name": "User Foo"
8584
},
8685
"last_synchronized": %s,
8786
"labels": {
@@ -161,15 +160,7 @@ public void testGetProfileByUid() {
161160
uid,
162161
true,
163162
lastSynchronized,
164-
new Profile.ProfileUser(
165-
"Foo",
166-
List.of("role1", "role2"),
167-
"realm_name_1",
168-
"domainA",
169-
170-
"User Foo",
171-
true
172-
),
163+
new Profile.ProfileUser("Foo", List.of("role1", "role2"), "realm_name_1", "domainA", "[email protected]", "User Foo"),
173164
Map.of(),
174165
applicationData,
175166
new Profile.VersionControl(1, 0)
@@ -253,8 +244,7 @@ private ProfileDocument randomProfileDocument(String uid) {
253244
List.of(),
254245
AuthenticationTests.randomRealmRef(randomBoolean()),
255246
256-
null,
257-
true
247+
null
258248
),
259249
Map.of(),
260250
null

0 commit comments

Comments
 (0)