AutoQuery Authentication

Maybe missing something really obvious, but I’m not seeing it. Is there a way to require authentication using the registered auth provider on AutoQuery services without having specific service implementation that uses the IAutoQueryDb interface?

Hi @yage0832,

If you are using AutoQuery with just the DTOs declared, you can apply the request filter attributes to request and response DTOs.

You can use the [ValidateIsAuthenticated] Type Validators attribute as they’re decoupled from any implementation and suited for use in your ServiceModel project.

Alternatively you can also add Attributes at runtime in your AppHost during startup configuration. Eg,

    .AddAttributes(new AuthenticateAttribute());

Where QueryAlbums is an AutoQuery request DTO.

[Route("/albums", "GET")]
[Route("/albums/{AlbumId}", "GET")]
public class QueryAlbums
    : QueryDb<Albums>, IReturn<QueryResponse<Albums>>, IGet
    public long? AlbumId { get; set; }

Hope that helps!

The type validators will work perfectly. Thanks!