aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/ApiKeyController.cs
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2023-01-31 12:18:10 +0100
committerShadowghost <Ghost_of_Stone@web.de>2023-02-02 18:50:33 +0100
commitf5f890e68562e55d4bed16c454c4b4305152b296 (patch)
treeb52e3b45ceb2faa446153866600b4456fed44c8b /Jellyfin.Api/Controllers/ApiKeyController.cs
parent58b3945805db4f88bc069ee84013bdf85d7429b1 (diff)
Migrate to file-scoped namespaces
Diffstat (limited to 'Jellyfin.Api/Controllers/ApiKeyController.cs')
-rw-r--r--Jellyfin.Api/Controllers/ApiKeyController.cs109
1 files changed, 54 insertions, 55 deletions
diff --git a/Jellyfin.Api/Controllers/ApiKeyController.cs b/Jellyfin.Api/Controllers/ApiKeyController.cs
index 024a15349..991f8cbf2 100644
--- a/Jellyfin.Api/Controllers/ApiKeyController.cs
+++ b/Jellyfin.Api/Controllers/ApiKeyController.cs
@@ -7,70 +7,69 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
-namespace Jellyfin.Api.Controllers
+namespace Jellyfin.Api.Controllers;
+
+/// <summary>
+/// Authentication controller.
+/// </summary>
+[Route("Auth")]
+public class ApiKeyController : BaseJellyfinApiController
{
+ private readonly IAuthenticationManager _authenticationManager;
+
/// <summary>
- /// Authentication controller.
+ /// Initializes a new instance of the <see cref="ApiKeyController"/> class.
/// </summary>
- [Route("Auth")]
- public class ApiKeyController : BaseJellyfinApiController
+ /// <param name="authenticationManager">Instance of <see cref="IAuthenticationManager"/> interface.</param>
+ public ApiKeyController(IAuthenticationManager authenticationManager)
{
- private readonly IAuthenticationManager _authenticationManager;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="ApiKeyController"/> class.
- /// </summary>
- /// <param name="authenticationManager">Instance of <see cref="IAuthenticationManager"/> interface.</param>
- public ApiKeyController(IAuthenticationManager authenticationManager)
- {
- _authenticationManager = authenticationManager;
- }
+ _authenticationManager = authenticationManager;
+ }
- /// <summary>
- /// Get all keys.
- /// </summary>
- /// <response code="200">Api keys retrieved.</response>
- /// <returns>A <see cref="QueryResult{AuthenticationInfo}"/> with all keys.</returns>
- [HttpGet("Keys")]
- [Authorize(Policy = Policies.RequiresElevation)]
- [ProducesResponseType(StatusCodes.Status200OK)]
- public async Task<ActionResult<QueryResult<AuthenticationInfo>>> GetKeys()
- {
- var keys = await _authenticationManager.GetApiKeys().ConfigureAwait(false);
+ /// <summary>
+ /// Get all keys.
+ /// </summary>
+ /// <response code="200">Api keys retrieved.</response>
+ /// <returns>A <see cref="QueryResult{AuthenticationInfo}"/> with all keys.</returns>
+ [HttpGet("Keys")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ public async Task<ActionResult<QueryResult<AuthenticationInfo>>> GetKeys()
+ {
+ var keys = await _authenticationManager.GetApiKeys().ConfigureAwait(false);
- return new QueryResult<AuthenticationInfo>(keys);
- }
+ return new QueryResult<AuthenticationInfo>(keys);
+ }
- /// <summary>
- /// Create a new api key.
- /// </summary>
- /// <param name="app">Name of the app using the authentication key.</param>
- /// <response code="204">Api key created.</response>
- /// <returns>A <see cref="NoContentResult"/>.</returns>
- [HttpPost("Keys")]
- [Authorize(Policy = Policies.RequiresElevation)]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- public async Task<ActionResult> CreateKey([FromQuery, Required] string app)
- {
- await _authenticationManager.CreateApiKey(app).ConfigureAwait(false);
+ /// <summary>
+ /// Create a new api key.
+ /// </summary>
+ /// <param name="app">Name of the app using the authentication key.</param>
+ /// <response code="204">Api key created.</response>
+ /// <returns>A <see cref="NoContentResult"/>.</returns>
+ [HttpPost("Keys")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public async Task<ActionResult> CreateKey([FromQuery, Required] string app)
+ {
+ await _authenticationManager.CreateApiKey(app).ConfigureAwait(false);
- return NoContent();
- }
+ return NoContent();
+ }
- /// <summary>
- /// Remove an api key.
- /// </summary>
- /// <param name="key">The access token to delete.</param>
- /// <response code="204">Api key deleted.</response>
- /// <returns>A <see cref="NoContentResult"/>.</returns>
- [HttpDelete("Keys/{key}")]
- [Authorize(Policy = Policies.RequiresElevation)]
- [ProducesResponseType(StatusCodes.Status204NoContent)]
- public async Task<ActionResult> RevokeKey([FromRoute, Required] string key)
- {
- await _authenticationManager.DeleteApiKey(key).ConfigureAwait(false);
+ /// <summary>
+ /// Remove an api key.
+ /// </summary>
+ /// <param name="key">The access token to delete.</param>
+ /// <response code="204">Api key deleted.</response>
+ /// <returns>A <see cref="NoContentResult"/>.</returns>
+ [HttpDelete("Keys/{key}")]
+ [Authorize(Policy = Policies.RequiresElevation)]
+ [ProducesResponseType(StatusCodes.Status204NoContent)]
+ public async Task<ActionResult> RevokeKey([FromRoute, Required] string key)
+ {
+ await _authenticationManager.DeleteApiKey(key).ConfigureAwait(false);
- return NoContent();
- }
+ return NoContent();
}
}