Skip to content

Commit 80bd856

Browse files
Fix UseSimpleTokenAuthentication for beta8
1 parent fd00e8c commit 80bd856

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

src/MakingSense.AspNet.Authentication.SimpleToken/SimpleTokenAppBuilderExtensions.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,22 @@ public static class SimpleTokenAppBuilderExtensions
1111
{
1212
public static IApplicationBuilder UseSimpleTokenAuthentication([NotNull] this IApplicationBuilder app, Action<SimpleTokenAuthenticationOptions> configureOptions = null, string optionsName = "")
1313
{
14-
return app.UseMiddleware<SimpleTokenAuthenticationMiddleware>(
15-
new ConfigureOptions<SimpleTokenAuthenticationOptions>(o =>
16-
{
17-
if (configureOptions != null)
18-
{
19-
configureOptions(o);
20-
}
21-
if (o.SecurityTokenValidatorsFactory == null)
22-
{
23-
o.SecurityTokenValidatorsFactory = () => app.ApplicationServices.GetServices<ISecurityTokenValidator>();
24-
}
25-
})
26-
{
27-
Name = optionsName
28-
});
14+
var options = new SimpleTokenAuthenticationOptions()
15+
{
16+
AuthenticationScheme = optionsName
17+
};
18+
19+
if (configureOptions != null)
20+
{
21+
configureOptions(options);
22+
}
23+
24+
if (options.SecurityTokenValidatorsFactory == null)
25+
{
26+
options.SecurityTokenValidatorsFactory = () => app.ApplicationServices.GetServices<ISecurityTokenValidator>();
27+
}
28+
29+
return app.UseMiddleware<SimpleTokenAuthenticationMiddleware>(options);
2930
}
3031
}
3132
}

0 commit comments

Comments
 (0)