vapor / fluent

Vapor ORM (queries, models, and relations) for NoSQL and SQL databases
https://docs.vapor.codes/4.0/fluent/overview/
MIT License
1.32k stars 172 forks source link

ModelAuthenticatable Authentication issues #688

Closed anthonycastelli closed 4 years ago

anthonycastelli commented 4 years ago

When trying to use the

public func authenticator(
        database: DatabaseID? = nil
    ) -> Authenticator {
        ModelAuthenticator<Self>(database: database)
    }

method, the ModelAuthenticator is not returned correctly making the ability to authenticate a user not possible. The method in ModelAuthenticator

func authenticate(
        basic: BasicAuthorization,
        for request: Request
    )

is not found.

0xTim commented 4 years ago

I think this is because it's inside the private ModelAuthenticator<User> type - I don't know if this is a deliberate decision or not

anthonycastelli commented 4 years ago

Yeah, that's what I assume as well, but figured I would create a ticket and have @tanner0101 have a look at it in case there is something I am missing.

tanner0101 commented 4 years ago

You can cast it as a BasicAuthenticator to get access to those methods. But it's meant to be used as a middleware:

public protocol Authenticator: Middleware { }

This guide has more info: https://docs.vapor.codes/4.0/authentication/#fluent