M$ AspNet.WebApi 2.2
Testé avec mono current sous Debian Sid: l'import AspNet.WebApi 2.2
This commit is contained in:
parent
d40679cdf4
commit
1f64b48966
97 changed files with 7890 additions and 9323 deletions
45
web/App_Start/IdentityConfig.cs
Normal file
45
web/App_Start/IdentityConfig.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Microsoft.AspNet.Identity.Owin;
|
||||
using Microsoft.Owin;
|
||||
using Yavsc.Models.Identity;
|
||||
|
||||
namespace Yavsc.App_Start
|
||||
{
|
||||
// Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application.
|
||||
|
||||
public class ApplicationUserManager : UserManager<ApplicationUser>
|
||||
{
|
||||
public ApplicationUserManager(IUserStore<ApplicationUser> store)
|
||||
: base(store)
|
||||
{
|
||||
}
|
||||
|
||||
public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
|
||||
{
|
||||
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
|
||||
// Configure validation logic for usernames
|
||||
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
|
||||
{
|
||||
AllowOnlyAlphanumericUserNames = false,
|
||||
RequireUniqueEmail = true
|
||||
};
|
||||
// Configure validation logic for passwords
|
||||
manager.PasswordValidator = new PasswordValidator
|
||||
{
|
||||
RequiredLength = 6,
|
||||
RequireNonLetterOrDigit = true,
|
||||
RequireDigit = true,
|
||||
RequireLowercase = true,
|
||||
RequireUppercase = true,
|
||||
};
|
||||
var dataProtectionProvider = options.DataProtectionProvider;
|
||||
if (dataProtectionProvider != null)
|
||||
{
|
||||
manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity"));
|
||||
}
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
}
|
||||
68
web/App_Start/Startup.Auth.cs
Normal file
68
web/App_Start/Startup.Auth.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Microsoft.AspNet.Identity.EntityFramework;
|
||||
using Microsoft.Owin;
|
||||
using Microsoft.Owin.Security.Cookies;
|
||||
using Microsoft.Owin.Security.Google;
|
||||
using Microsoft.Owin.Security.OAuth;
|
||||
using Owin;
|
||||
using Yavsc.Models.Identity;
|
||||
using Yavsc.Providers;
|
||||
|
||||
namespace Yavsc.App_Start
|
||||
{
|
||||
public partial class Startup
|
||||
{
|
||||
public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }
|
||||
|
||||
public static string PublicClientId { get; private set; }
|
||||
|
||||
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
|
||||
public void ConfigureAuth(IAppBuilder app)
|
||||
{
|
||||
// Configure the db context and user manager to use a single instance per request
|
||||
app.CreatePerOwinContext(ApplicationDbContext.Create);
|
||||
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
|
||||
|
||||
// Enable the application to use a cookie to store information for the signed in user
|
||||
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
|
||||
app.UseCookieAuthentication(new CookieAuthenticationOptions());
|
||||
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
|
||||
|
||||
// Configure the application for OAuth based flow
|
||||
PublicClientId = "self";
|
||||
OAuthOptions = new OAuthAuthorizationServerOptions
|
||||
{
|
||||
TokenEndpointPath = new PathString("/Token"),
|
||||
Provider = new ApplicationOAuthProvider(PublicClientId),
|
||||
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
|
||||
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
|
||||
AllowInsecureHttp = true
|
||||
};
|
||||
|
||||
// Enable the application to use bearer tokens to authenticate users
|
||||
app.UseOAuthBearerTokens(OAuthOptions);
|
||||
|
||||
// Uncomment the following lines to enable logging in with third party login providers
|
||||
//app.UseMicrosoftAccountAuthentication(
|
||||
// clientId: "",
|
||||
// clientSecret: "");
|
||||
|
||||
//app.UseTwitterAuthentication(
|
||||
// consumerKey: "",
|
||||
// consumerSecret: "");
|
||||
|
||||
//app.UseFacebookAuthentication(
|
||||
// appId: "",
|
||||
// appSecret: "");
|
||||
|
||||
//app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions()
|
||||
//{
|
||||
// ClientId = "",
|
||||
// ClientSecret = ""
|
||||
//});
|
||||
}
|
||||
}
|
||||
}
|
||||
38
web/App_Start/Startup.cs
Normal file
38
web/App_Start/Startup.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// Startup.cs
|
||||
//
|
||||
// Author:
|
||||
// Paul Schneider <paul@pschneider.fr>
|
||||
//
|
||||
// Copyright (c) 2015 GNU GPL
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System;
|
||||
using Microsoft.Owin;
|
||||
using Owin;
|
||||
|
||||
|
||||
[assembly: OwinStartup(typeof(Yavsc.App_Start.Startup))]
|
||||
namespace Yavsc.App_Start
|
||||
{
|
||||
public partial class Startup
|
||||
{
|
||||
public void Configuration(IAppBuilder app)
|
||||
{
|
||||
ConfigureAuth (app);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue