fix: check for obviously invalid instance URLs, use correct JSON key for mastodon scopes
This commit is contained in:
		
							parent
							
								
									9160281ea2
								
							
						
					
					
						commit
						d0bf638a21
					
				
					 2 changed files with 18 additions and 10 deletions
				
			
		|  | @ -6,7 +6,6 @@ using Foxnouns.Backend.Utils; | |||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using NodaTime; | ||||
| using FediverseAuthService = Foxnouns.Backend.Services.Auth.FediverseAuthService; | ||||
| 
 | ||||
| namespace Foxnouns.Backend.Controllers.Authentication; | ||||
| 
 | ||||
|  | @ -25,6 +24,9 @@ public class FediverseAuthController( | |||
|     [ProducesResponseType<FediverseUrlResponse>(statusCode: StatusCodes.Status200OK)] | ||||
|     public async Task<IActionResult> GetFediverseUrlAsync([FromQuery] string instance) | ||||
|     { | ||||
|         if (instance.Any(c => c is '@' or ':' or '/') || !instance.Contains('.')) | ||||
|             throw new ApiError.BadRequest("Not a valid domain.", "instance", instance); | ||||
| 
 | ||||
|         var url = await fediverseAuthService.GenerateAuthUrlAsync(instance); | ||||
|         return Ok(new FediverseUrlResponse(url)); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue