From cd6874b3dd54c6b3e501439d308d591e4b2aada5 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 5 Oct 2022 18:30:31 -0500 Subject: add auth policies --- .../API/Controllers/ConversationsController.cs | 12 ++++++------ .../API/Controllers/PublicChatController.cs | 4 ++-- .../Messaging/API/Controllers/RoomsController.cs | 20 ++++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src/slskd/Messaging/API') diff --git a/src/slskd/Messaging/API/Controllers/ConversationsController.cs b/src/slskd/Messaging/API/Controllers/ConversationsController.cs index 492340f0..17c55a10 100644 --- a/src/slskd/Messaging/API/Controllers/ConversationsController.cs +++ b/src/slskd/Messaging/API/Controllers/ConversationsController.cs @@ -66,7 +66,7 @@ namespace slskd.Messaging.API /// A conversation with the specified username, or a message matching the specified id could not be found. /// [HttpPut("{username}/{id}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(200)] [ProducesResponseType(404)] public async Task Acknowledge([FromRoute]string username, [FromRoute]int id) @@ -90,7 +90,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// A conversation with the specified username could not be found. [HttpPut("{username}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(200)] [ProducesResponseType(404)] public async Task AcknowledgeAll([FromRoute]string username) @@ -124,7 +124,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// A conversation with the specified username could not be found. [HttpDelete("{username}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(404)] [ProducesResponseType(204)] public IActionResult Delete([FromRoute]string username) @@ -145,7 +145,7 @@ namespace slskd.Messaging.API /// /// The request completed successfully. [HttpGet("")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Dictionary>), 200)] public IActionResult GetAll() { @@ -166,7 +166,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// A matching search was not found. [HttpGet("{username}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(List), 200)] [ProducesResponseType(404)] public IActionResult GetByUsername([FromRoute]string username) @@ -192,7 +192,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified message is null or empty. [HttpPost("{username}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(201)] [ProducesResponseType(400)] public async Task Send([FromRoute]string username, [FromBody]string message) diff --git a/src/slskd/Messaging/API/Controllers/PublicChatController.cs b/src/slskd/Messaging/API/Controllers/PublicChatController.cs index c30e08a8..83f7ede7 100644 --- a/src/slskd/Messaging/API/Controllers/PublicChatController.cs +++ b/src/slskd/Messaging/API/Controllers/PublicChatController.cs @@ -45,7 +45,7 @@ namespace slskd.Messaging.API /// /// [HttpPost] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] public async Task Start() { await Client.StartPublicChatAsync(); @@ -57,7 +57,7 @@ namespace slskd.Messaging.API /// /// [HttpDelete] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] public async Task Stop() { await Client.StopPublicChatAsync(); diff --git a/src/slskd/Messaging/API/Controllers/RoomsController.cs b/src/slskd/Messaging/API/Controllers/RoomsController.cs index 8a3e5f3f..66993630 100644 --- a/src/slskd/Messaging/API/Controllers/RoomsController.cs +++ b/src/slskd/Messaging/API/Controllers/RoomsController.cs @@ -59,7 +59,7 @@ namespace slskd.Messaging.API /// /// The request completed successfully. [HttpGet("joined")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Dictionary>), 200)] public IActionResult GetAll() { @@ -74,7 +74,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpGet("joined/{roomName}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Room), 200)] [ProducesResponseType(404)] public IActionResult GetByRoomName([FromRoute]string roomName) @@ -96,7 +96,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpPost("joined/{roomName}/messages")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(201)] [ProducesResponseType(404)] public async Task SendMessage([FromRoute]string roomName, [FromBody]string message) @@ -119,7 +119,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpPost("joined/{roomName}/ticker")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(201)] [ProducesResponseType(404)] public async Task SetTicker([FromRoute] string roomName, [FromBody] string message) @@ -142,7 +142,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpPost("joined/{roomName}/members")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(201)] [ProducesResponseType(404)] public async Task AddRoomMember([FromRoute]string roomName, [FromBody]string username) @@ -164,7 +164,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpGet("joined/{roomName}/users")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(IList), 200)] [ProducesResponseType(404)] public IActionResult GetUsersByRoomName([FromRoute]string roomName) @@ -188,7 +188,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The specified roomName could not be found. [HttpGet("joined/{roomName}/messages")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(IList), 200)] [ProducesResponseType(404)] public IActionResult GetMessagesByRoomName([FromRoute]string roomName) @@ -209,7 +209,7 @@ namespace slskd.Messaging.API /// /// [HttpGet("available")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(List), 200)] public async Task GetRooms() { @@ -237,7 +237,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The room has already been joined. [HttpPost("joined")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(typeof(Room), 201)] [ProducesResponseType(304)] public async Task JoinRoom([FromBody]string roomName) @@ -273,7 +273,7 @@ namespace slskd.Messaging.API /// The request completed successfully. /// The room has not been joined. [HttpDelete("joined/{roomName}")] - [Authorize] + [Authorize(Policy = AuthPolicy.Any)] [ProducesResponseType(204)] [ProducesResponseType(404)] public async Task LeaveRoom([FromRoute]string roomName) -- cgit v1.2.3