Permalink
Browse files

If using the default oauth token, we will use the request's host & po…

…rt, rather than rely on the user to specify them for us.
  • Loading branch information...
1 parent eddc268 commit addaa36d8f81ee098b5b2dec8efc3e91e531d60a @ayende ayende committed Mar 22, 2013
@@ -254,6 +254,11 @@ private void SetVirtualDirectory()
}
+ public bool UseDefaultOAuthTokenServer
+ {
+ get { return Settings["Raven/OAuthTokenServer"] == null; }
+ }
+
private void SetupOAuth()
{
OAuthTokenServer = Settings["Raven/OAuthTokenServer"] ??
@@ -109,7 +109,19 @@ void WriteAuthorizationChallenge(IHttpContext ctx, int statusCode, string error,
{
if (string.IsNullOrEmpty(Settings.OAuthTokenServer) == false)
{
- ctx.Response.AddHeader("OAuth-Source", Settings.OAuthTokenServer);
+ if (Settings.UseDefaultOAuthTokenServer == false)
+ {
+ ctx.Response.AddHeader("OAuth-Source", Settings.OAuthTokenServer);
+ }
+ else
+ {
+ ctx.Response.AddHeader("OAuth-Source", new UriBuilder(Settings.OAuthTokenServer)
+ {
+ Host = ctx.Request.Url.Host,
+ Port = ctx.Request.Url.Port
+ }.Uri.ToString());
+
+ }
}
ctx.Response.StatusCode = statusCode;
ctx.Response.AddHeader("WWW-Authenticate", string.Format("Bearer realm=\"Raven\", error=\"{0}\",error_description=\"{1}\"", error, errorDescription));
View
@@ -15,6 +15,8 @@ class Program
{
static void Main(string[] args)
{
+ var uri = new Uri("ftp://localhost/");
+ Console.WriteLine(uri.Port);
}
}
}

0 comments on commit addaa36

Please sign in to comment.