Skip to content

Commit

Permalink
Additions to Invalidate Token API (#3937)
Browse files Browse the repository at this point in the history
* Implement additional fields on invalidate user token requests
* Add error details to response
* Update src/Nest/XPack/Security/User/InvalidateUserAccessToken/InvalidateUserAccessTokenRequest.cs
* Fix inherit doc references

Co-Authored-By: Russ Cam <russ.cam@elastic.co>
  • Loading branch information
codebrain and russcam committed Jul 18, 2019
1 parent 957caf0 commit b8e8a11
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,83 @@

namespace Nest
{
/// <summary>
/// Invalidates one or more access tokens or refresh tokens.
/// </summary>
[MapsApi("security.invalidate_token.json")]
public partial interface IInvalidateUserAccessTokenRequest
{
/// <summary>
/// An access token.
/// This parameter cannot be used if any of <see cref="RefreshToken"/>, <see cref="RealmName"/> or <see cref="Username"/> are used.
/// </summary>
[DataMember(Name ="token")]
string Token { get; set; }

/// <summary>
/// A refresh token.
/// This parameter cannot be used any of <see cref="RefreshToken"/>, <see cref="RealmName"/> or <see cref="Username"/> are used.
/// </summary>
[DataMember(Name = "refresh_token")]
string RefreshToken { get; set; }

/// <summary>
/// The name of an authentication realm.
/// This parameter cannot be used with either <see cref="RefreshToken"/> or <see cref="Token"/>.
/// </summary>
[DataMember(Name = "realm_name")]
string RealmName { get; set; }

/// <summary>
/// The username of a user.
/// This parameter cannot be used with either <see cref="RefreshToken"/> or <see cref="Token"/>.
/// </summary>
[DataMember(Name = "username")]
string Username { get; set; }
}


public partial class InvalidateUserAccessTokenRequest
{
public InvalidateUserAccessTokenRequest(string token) => ((IInvalidateUserAccessTokenRequest)this).Token = token;

[DataMember(Name ="token")]
/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.Token"/>
string IInvalidateUserAccessTokenRequest.Token { get; set; }

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.RefreshToken"/>
string IInvalidateUserAccessTokenRequest.RefreshToken { get; set; }

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.RealmName"/>
string IInvalidateUserAccessTokenRequest.RealmName { get; set; }

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.Username"/>
string IInvalidateUserAccessTokenRequest.Username { get; set; }
}

public partial class InvalidateUserAccessTokenDescriptor
{
/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.Token" />
public InvalidateUserAccessTokenDescriptor(string token) => ((IInvalidateUserAccessTokenRequest)this).Token = token;

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.RefreshToken" />
public InvalidateUserAccessTokenDescriptor RefreshToken(string refreshToken) => Assign(refreshToken, (a, v) => a.RefreshToken = v);

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.RealmName" />
public InvalidateUserAccessTokenDescriptor RealmName(string realmName) => Assign(realmName, (a, v) => a.RealmName = v);

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.Username" />
public InvalidateUserAccessTokenDescriptor Username(string username) => Assign(username, (a, v) => a.Username = v);

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.Token" />
string IInvalidateUserAccessTokenRequest.Token { get; set; }

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.RefreshToken" />
string IInvalidateUserAccessTokenRequest.RefreshToken { get; set; }

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.RealmName" />
string IInvalidateUserAccessTokenRequest.RealmName { get; set; }

/// <inheritdoc cref="IInvalidateUserAccessTokenRequest.Username" />
string IInvalidateUserAccessTokenRequest.Username { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Elasticsearch.Net;

namespace Nest
{
public class InvalidateUserAccessTokenResponse : ResponseBase
{
/// <summary>
/// The number of the tokens that were invalidated as part of this request.
/// </summary>
[DataMember(Name = "invalidated_tokens")]
public long InvalidatedTokens { get; internal set; }

/// <summary>
/// The number of tokens that were already invalidated.
/// </summary>
[DataMember(Name = "previously_invalidated_tokens")]
public long PreviouslyInvalidatedTokens { get; internal set; }

/// <summary>
/// The number of errors that were encountered when invalidating the tokens.
/// </summary>
[DataMember(Name = "error_count")]
public long ErrorCount { get; internal set; }

/// <summary>
/// Details about these errors. This field is not present in the response when there are no errors.
/// </summary>
[DataMember(Name = "error_details")]
public IReadOnlyCollection<ErrorCause> ErrorDetails { get; internal set; } = EmptyReadOnly<ErrorCause>.Collection;
}
}

0 comments on commit b8e8a11

Please sign in to comment.