Skip to content

Commit ec65a6c

Browse files
Update get token response to include auth info (#5378) (#5397)
* Update get token response to include auth info * Update token response * Update response Co-authored-by: Steve Gordon <[email protected]>
1 parent 6a31505 commit ec65a6c

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/Nest/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenResponse.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using System.Collections.Generic;
56
using System.Runtime.Serialization;
7+
using Elasticsearch.Net;
68

79
namespace Nest
810
{
@@ -19,5 +21,46 @@ public class GetUserAccessTokenResponse : ResponseBase
1921

2022
[DataMember(Name ="type")]
2123
public string Type { get; set; }
24+
25+
[DataMember(Name = "authentication")]
26+
public Authentication Authentication { get; set; }
27+
}
28+
29+
public class Authentication
30+
{
31+
[DataMember(Name = "email")]
32+
public string Email { get; internal set; }
33+
34+
[DataMember(Name = "full_name")]
35+
public string FullName { get; internal set; }
36+
37+
[DataMember(Name = "metadata")]
38+
public IReadOnlyDictionary<string, object> Metadata { get; internal set; }
39+
= EmptyReadOnly<string, object>.Dictionary;
40+
41+
[DataMember(Name = "roles")]
42+
public IReadOnlyCollection<string> Roles { get; internal set; }
43+
= EmptyReadOnly<string>.Collection;
44+
45+
[DataMember(Name = "username")]
46+
public string Username { get; internal set; }
47+
48+
[DataMember(Name = "authentication_realm")]
49+
public AuthenticationRealmInfo AuthenticationRealm { get; internal set; }
50+
51+
[DataMember(Name = "lookup_realm")]
52+
public AuthenticationRealmInfo LookupRealm { get; internal set; }
53+
54+
[DataMember(Name = "authentication_type")]
55+
public string AuthenticationType { get; internal set; }
56+
}
57+
58+
public class AuthenticationRealmInfo
59+
{
60+
[DataMember(Name = "name")]
61+
public string Name { get; internal set; }
62+
63+
[DataMember(Name = "type")]
64+
public string Type { get; internal set; }
2265
}
2366
}

tests/Tests/XPack/Security/User/GetUserAccessToken/GetUserAccessTokenApiTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using Elasticsearch.Net;
88
using FluentAssertions;
99
using Nest;
10+
using Tests.Configuration;
11+
using Tests.Core.Extensions;
1012
using Tests.Framework.EndpointTests;
1113
using Tests.Framework.EndpointTests.TestState;
1214
using static Elastic.Elasticsearch.Ephemeral.ClusterAuthentication;
@@ -63,6 +65,13 @@ protected override void ExpectResponse(GetUserAccessTokenResponse response)
6365
response.Type.Should().NotBeNullOrEmpty().And.Be("Bearer");
6466
response.ExpiresIn.Should().BeGreaterThan(0);
6567
response.Scope.Should().Be("full");
68+
69+
if (TestConfiguration.Instance.InRange(">=7.11.0"))
70+
{
71+
response.Authentication.Should().NotBeNull();
72+
response.Authentication.Username.Should().NotBeNullOrEmpty();
73+
response.Authentication.Roles.Count.Should().BeGreaterThan(0);
74+
}
6675
}
6776
}
6877

0 commit comments

Comments
 (0)