vapor / auth

👤 Authentication and Authorization framework for Fluent.
53 stars 34 forks source link

Should AuthenticationCache be public? #46

Closed vicsonic closed 6 years ago

vicsonic commented 6 years ago

Hi!

I'm trying to use TokenAuthenticatable for a user model, however, when running the app I'm getting this log:

[ ERROR ] ServiceError.make: No services are available for 'AuthenticationCache'. (Container.swift:112)
[ DEBUG ] Suggested fixes for ServiceError.make: Register a service for 'AuthenticationCache'. `services.register(AuthenticationCache.self) { ... }`. (Logger+LogError.swift:20)

After trying to register the AuthenticationCache service in my configuration I'm getting a Use of unresolver identifier error, because AuthenticationCache is not public:

/// Stores authenticated objects. This should be created
/// using the request container as a singleton. Authenticated
/// objects can then be stored here by middleware and fetched
/// later in route closures.
final class AuthenticationCache: Service { ... }

Should this class be public? or maybe I'm doing this wrong, I'm pretty new with vapor and I can't find many guides or references about this.

Thank you.

0xTim commented 6 years ago

@vicsonic you need to register the authentication provider like so https://github.com/raywenderlich/vapor-til/blob/master/Sources/App/configure.swift#L45

vicsonic commented 6 years ago

@0xTim Sweet! That totally works! Thank you! 🙌