Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
More fixes for URL rewriting handling.
Browse files Browse the repository at this point in the history
See Google Code Issue 86.
  • Loading branch information
AArnott committed Jun 11, 2008
1 parent 428ca6c commit f048fb1
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/DotNetOpenId/Provider/IdentityEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override void Render(HtmlTextWriter writer) {
writer.WriteBeginTag("link");
writer.WriteAttribute("rel", Protocol.HtmlDiscoveryProviderKey);
writer.WriteAttribute("href",
new Uri(Page.Request.Url, Page.ResolveUrl(ProviderEndpointUrl)).AbsoluteUri);
new Uri(Util.GetRequestUrlFromContext(), Page.ResolveUrl(ProviderEndpointUrl)).AbsoluteUri);
writer.Write(">");
writer.WriteEndTag("link");
writer.WriteLine();
Expand All @@ -86,7 +86,7 @@ protected override void Render(HtmlTextWriter writer) {
writer.WriteBeginTag("link");
writer.WriteAttribute("rel", Protocol.HtmlDiscoveryLocalIdKey);
writer.WriteAttribute("href",
new Uri(Page.Request.Url, Page.ResolveUrl(ProviderLocalIdentifier)).AbsoluteUri);
new Uri(Util.GetRequestUrlFromContext(), Page.ResolveUrl(ProviderLocalIdentifier)).AbsoluteUri);
writer.Write(">");
writer.WriteEndTag("link");
writer.WriteLine();
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetOpenId/Provider/OpenIdProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static Uri getProviderEndpointFromContext() {
HttpContext context = HttpContext.Current;
if (context == null)
throw new InvalidOperationException(Strings.HttpContextRequiredForThisOverload);
UriBuilder builder = new UriBuilder(HttpContext.Current.Request.Url);
UriBuilder builder = new UriBuilder(Util.GetRequestUrlFromContext());
builder.Query = null;
builder.Fragment = null;
return builder.Uri;
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetOpenId/RelyingParty/OpenIdMobileTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void addProfileArgs(IAuthenticationRequest request)
Language = RequestLanguage,
TimeZone = RequestTimeZone,
PolicyUrl = string.IsNullOrEmpty(PolicyUrl) ?
null : new Uri(Page.Request.Url, Page.ResolveUrl(PolicyUrl)),
null : new Uri(Util.GetRequestUrlFromContext(), Page.ResolveUrl(PolicyUrl)),
});
}

Expand Down
6 changes: 2 additions & 4 deletions src/DotNetOpenId/RelyingParty/OpenIdRelyingParty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier, R
if (HttpContext.Current == null) throw new InvalidOperationException(Strings.CurrentHttpContextRequired);

// Build the return_to URL
UriBuilder returnTo = new UriBuilder(HttpContext.Current.Request.Url);
// Support cookieless sessions by adding the special path if appropriate.
returnTo.Path = HttpContext.Current.Response.ApplyAppPathModifier(returnTo.Path);
UriBuilder returnTo = new UriBuilder(Util.GetRequestUrlFromContext());
// Trim off any parameters with an "openid." prefix, and a few known others
// to avoid carrying state from a prior login attempt.
returnTo.Query = string.Empty;
Expand Down Expand Up @@ -119,7 +117,7 @@ public IAuthenticationRequest CreateRequest(Identifier userSuppliedIdentifier) {
if (HttpContext.Current == null) throw new InvalidOperationException(Strings.CurrentHttpContextRequired);

// Build the realm URL
UriBuilder realmUrl = new UriBuilder(HttpContext.Current.Request.Url);
UriBuilder realmUrl = new UriBuilder(Util.GetRequestUrlFromContext());
realmUrl.Path = HttpContext.Current.Request.ApplicationPath;
realmUrl.Query = null;
realmUrl.Fragment = null;
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetOpenId/RelyingParty/OpenIdTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ void addProfileArgs(IAuthenticationRequest request)
Language = RequestLanguage,
TimeZone = RequestTimeZone,
PolicyUrl = string.IsNullOrEmpty(PolicyUrl) ?
null : new Uri(Page.Request.Url, Page.ResolveUrl(PolicyUrl)),
null : new Uri(Util.GetRequestUrlFromContext(), Page.ResolveUrl(PolicyUrl)),
});
}

Expand All @@ -675,7 +675,7 @@ UriBuilder getResolvedRealm(string realm)
});

UriBuilder fullyQualifiedRealm = new UriBuilder(
new Uri(Page.Request.Url, Page.ResolveUrl(realmNoWildcard)));
new Uri(Util.GetRequestUrlFromContext(), Page.ResolveUrl(realmNoWildcard)));

if (foundWildcard)
{
Expand Down
4 changes: 4 additions & 0 deletions src/DotNetOpenId/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public static IDictionary<string, string> GetQueryFromContext() {
HttpContext.Current.Request.QueryString : HttpContext.Current.Request.Form;
return NameValueCollectionToDictionary(query);
}
/// <summary>
/// Gets the original request URL, as seen from the browser before any URL rewrites on the server if any.
/// Cookieless session directory (if applicable) is also included.
/// </summary>
internal static Uri GetRequestUrlFromContext() {
HttpContext context = HttpContext.Current;
if (context == null) throw new InvalidOperationException(Strings.CurrentHttpContextRequired);
Expand Down
4 changes: 2 additions & 2 deletions src/DotNetOpenId/XrdsPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ protected override void Render(HtmlTextWriter writer) {
if (Enabled && Visible && !string.IsNullOrEmpty(XrdsUrl)) {
if ((XrdsAdvertisement & XrdsUrlLocations.HttpHeader) != 0) {
Page.Response.AddHeader(Yadis.Yadis.HeaderName,
new Uri(Page.Request.Url, Page.Response.ApplyAppPathModifier(XrdsUrl)).AbsoluteUri);
new Uri(Util.GetRequestUrlFromContext(), Page.Response.ApplyAppPathModifier(XrdsUrl)).AbsoluteUri);
}
if ((XrdsAdvertisement & XrdsUrlLocations.HtmlMeta) != 0) {
writer.WriteBeginTag("meta");
writer.WriteAttribute("http-equiv", Yadis.Yadis.HeaderName);
writer.WriteAttribute("content",
new Uri(Page.Request.Url, Page.Response.ApplyAppPathModifier(XrdsUrl)).AbsoluteUri);
new Uri(Util.GetRequestUrlFromContext(), Page.Response.ApplyAppPathModifier(XrdsUrl)).AbsoluteUri);
writer.Write("/>");
writer.WriteLine();
}
Expand Down

0 comments on commit f048fb1

Please sign in to comment.