forked from auth0-samples/aspnet-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
452 additions
and
323 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...00-Starter-Seed/auth0-aspnet-mvc4-sample/aspnet4-sample1/Controllers/AccountController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Auth0.AuthenticationApi; | ||
using Auth0.AuthenticationApi.Models; | ||
using System; | ||
using System.Configuration; | ||
using System.Globalization; | ||
using System.IdentityModel.Services; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
|
||
namespace aspnet4_sample1.Controllers | ||
{ | ||
public class AccountController : Controller | ||
{ | ||
public ActionResult Login(string returnUrl) | ||
{ | ||
var client = new AuthenticationApiClient( | ||
new Uri(string.Format("https://{0}", ConfigurationManager.AppSettings["auth0:Domain"]))); | ||
|
||
|
||
var request = this.Request; | ||
var redirectUri = new UriBuilder(request.Url.Scheme, request.Url.Host, this.Request.Url.IsDefaultPort ? -1 : request.Url.Port, "LoginCallback.ashx"); | ||
|
||
var authorizeUrlBuilder = client.BuildAuthorizationUrl() | ||
.WithClient(ConfigurationManager.AppSettings["auth0:ClientId"]) | ||
.WithRedirectUrl(redirectUri.ToString()) | ||
.WithResponseType(AuthorizationResponseType.Code) | ||
.WithScope("openid profile") | ||
// adding this audience will cause Auth0 to use the OIDC-Conformant pipeline | ||
// you don't need it if your client is flagged as OIDC-Conformant (Advance Settings | OAuth) | ||
.WithAudience("https://" + @ConfigurationManager.AppSettings["auth0:Domain"] + "/userinfo"); | ||
|
||
if (!string.IsNullOrEmpty(returnUrl)) | ||
{ | ||
var state = "ru=" + HttpUtility.UrlEncode(returnUrl); | ||
authorizeUrlBuilder.WithState(state); | ||
} | ||
|
||
return new RedirectResult(authorizeUrlBuilder.Build().ToString()); | ||
} | ||
|
||
public ActionResult Logout() | ||
{ | ||
FederatedAuthentication.SessionAuthenticationModule.SignOut(); | ||
|
||
// Redirect to Auth0's logout endpoint. | ||
// After terminating the user's session, Auth0 will redirect to the | ||
// returnTo URL, which you will have to add to the list of allowed logout URLs for the client. | ||
var returnTo = Url.Action("Index", "Home", null, protocol: Request.Url.Scheme); | ||
return Redirect( | ||
string.Format(CultureInfo.InvariantCulture, | ||
"https://{0}/v2/logout?returnTo={1}&client_id={2}", | ||
ConfigurationManager.AppSettings["auth0:Domain"], | ||
Server.UrlEncode(returnTo), | ||
ConfigurationManager.AppSettings["auth0:ClientId"])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Quickstart/00-Starter-Seed/auth0-aspnet-mvc4-sample/aspnet4-sample1/Scripts/_references.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
...tart/00-Starter-Seed/auth0-aspnet-mvc4-sample/aspnet4-sample1/Scripts/jquery-3.1.1.min.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...art/00-Starter-Seed/auth0-aspnet-mvc4-sample/aspnet4-sample1/Scripts/jquery-3.1.1.min.map
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...00-Starter-Seed/auth0-aspnet-mvc4-sample/aspnet4-sample1/Scripts/jquery-3.1.1.slim.min.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...0-Starter-Seed/auth0-aspnet-mvc4-sample/aspnet4-sample1/Scripts/jquery-3.1.1.slim.min.map
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.