public static IServiceCollection AddImplicitFlowAuthentication(this IServiceCollection services, Action <OpenIdConnectOptions> options) { var optionsObject = new OpenIdConnectOptions(); options(optionsObject); services.AddAuthentication(x => { x.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; x.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; }) .AddCookie() .AddOpenIdConnect(x => { x.Authority = optionsObject.Authority; x.ClientId = optionsObject.ClientId; x.SignedOutRedirectUri = optionsObject.SignedOutRedirectUri; x.RequireHttpsMetadata = optionsObject.RequireHttpsMetadata; x.SaveTokens = true; }); return(services); }
public static IServiceCollection AddResourceOwnerPasswordCredentialsFlow(this IServiceCollection services, Action <OpenIdConnectOptions> options) { var optionsObject = new OpenIdConnectOptions(); options(optionsObject); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }).AddJwtBearer(x => { x.Authority = optionsObject.Authority; x.Audience = optionsObject.Audience; x.RequireHttpsMetadata = optionsObject.RequireHttpsMetadata; x.TokenValidationParameters = new TokenValidationParameters { ValidateAudience = false, ValidateIssuer = false }; }); return(services); }