t2v / play2-auth

Play2.x Authentication and Authorization module
Apache License 2.0
608 stars 142 forks source link

Removed the use of play.api.Application and play.api.Cache singletons #178

Closed tototoshi closed 7 years ago

tototoshi commented 8 years ago

Since Play 2.4, the use of play.api.Application and play.api.Cache is deprecated and not recommended. play.api.Cache singleton should be replaced with CacheApi and play.api.Application with Configuration/Environment.

To minimize the change, I think It's reasonable to add fields of CacheApi/Environment to AuthConfig trait. But it is not always the case for CacheApi. CacheApi is used only when CacheIdContainer is used as IdContainer. It is already discussed in https://github.com/t2v/play2-auth/issues/155. So I added idContainer field instead.

As for play.api.Environment which is the substitute of play.api.Application, I can say the same thing as CacheApi. It is used for only when CookieTokenAccessor. However, should I added a tokenAccessor field to AuthConfig instead of Environment? It's a little difficult but I don't think it's necessary because Environment is also in AsyncAuth and much more commonly used than CacheApi in Play app.

mikesname commented 8 years ago

This was very handy. I used it to get some Play 2.6 working with some extra changes: https://github.com/mikesname/play2-auth/tree/feature/play2.6

gakuzzzz commented 7 years ago

Sorry too late response and thanks for this PR!