16
16
*/
17
17
package securesocial .core .services
18
18
19
+ import play .api .Configuration
19
20
import play .api .mvc .{ Call , RequestHeader }
20
21
import securesocial .core .IdentityProvider
21
22
@@ -99,20 +100,25 @@ object RoutesService {
99
100
* The default RoutesService implementation. It points to the routes
100
101
* defined by the built in controllers.
101
102
*/
102
- class Default extends RoutesService {
103
+ class Default ( configuration : Configuration ) extends RoutesService {
103
104
private val logger = play.api.Logger (" securesocial.core.DefaultRoutesService" )
104
- lazy val conf = play.api.Play .current.configuration
105
-
106
105
val FaviconKey = " securesocial.faviconPath"
107
106
val JQueryKey = " securesocial.jqueryPath"
108
107
val BootstrapCssKey = " securesocial.bootstrapCssPath"
109
108
val CustomCssKey = " securesocial.customCssPath"
110
109
val DefaultFaviconPath = " images/favicon.png"
111
110
val DefaultJqueryPath = " javascripts/jquery-1.7.1.min.js"
112
111
val DefaultBootstrapCssPath = " bootstrap/css/bootstrap.min.css"
112
+ val ApplicationHostKey = " securesocial.applicationHost"
113
+ val ApplicationPortKey = " securesocial.applicationPort"
114
+ private lazy val applicationHost = configuration.getString(ApplicationHostKey ).getOrElse {
115
+ throw new RuntimeException (s " Missing property: $ApplicationHostKey" )
116
+ }
117
+ private lazy val applicationPort = configuration.getInt(ApplicationPortKey ).map(port => s " : $port" ).getOrElse(" " )
118
+ private lazy val hostAndPort = s " $applicationHost$applicationPort"
113
119
114
120
protected def absoluteUrl (call : Call )(implicit req : RequestHeader ): String = {
115
- call.absoluteURL(IdentityProvider .sslEnabled)
121
+ call.absoluteURL(IdentityProvider .sslEnabled, hostAndPort )
116
122
}
117
123
118
124
override def loginPageUrl (implicit req : RequestHeader ): String = {
@@ -168,7 +174,7 @@ object RoutesService {
168
174
}
169
175
170
176
protected def valueFor (key : String , default : String ) = {
171
- val value = conf .getString(key).getOrElse(default)
177
+ val value = configuration .getString(key).getOrElse(default)
172
178
logger.debug(s " [securesocial] $key = $value" )
173
179
securesocial.controllers.routes.Assets .at(value)
174
180
}
@@ -195,7 +201,7 @@ object RoutesService {
195
201
* @return Option containing a custom css file or None
196
202
*/
197
203
override val customCssPath : Option [Call ] = {
198
- val path = conf .getString(CustomCssKey ).map(securesocial.controllers.routes.Assets .at)
204
+ val path = configuration .getString(CustomCssKey ).map(securesocial.controllers.routes.Assets .at)
199
205
logger.debug(" [securesocial] custom css path = %s" .format(path))
200
206
path
201
207
}
0 commit comments