Skip to content

Commit 0d89ddc

Browse files
Ticket #13 : Externalize the Authentication and the Authorization from all the libraries
1 parent 9455753 commit 0d89ddc

File tree

43 files changed

+296
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+296
-219
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.0.3</VersionPrefix>
3+
<VersionPrefix>1.0.4</VersionPrefix>
44
<Authors>SimpleIdServer</Authors>
55
<Owners>SimpleIdServer</Owners>
66
</PropertyGroup>

SimpleIdServer.OAuth.Host.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.645
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29503.13
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "02. Startup Layer", "02. Startup Layer", "{68306EFF-55D9-497B-9482-FEB81C485914}"
77
EndProject

SimpleIdServer.OpenId.Host.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.645
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29503.13
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "04. Startup Layer", "04. Startup Layer", "{68306EFF-55D9-497B-9482-FEB81C485914}"
77
EndProject

SimpleIdServer.Scim.Host.sln

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28307.645
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29503.13
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "01. Core Layer", "01. Core Layer", "{E47E7F9F-C5CA-4459-AF46-F320F155B69E}"
77
EndProject
@@ -62,7 +62,6 @@ Global
6262
HideSolutionNode = FALSE
6363
EndGlobalSection
6464
GlobalSection(NestedProjects) = preSolution
65-
{E47E7F9F-C5CA-4459-AF46-F320F155B69E} = {011E8E6E-5B36-4E0C-A4AE-FF7B11579380}
6665
{4B26792A-6960-4270-92C1-65C4C1FD59F3} = {E47E7F9F-C5CA-4459-AF46-F320F155B69E}
6766
{A1C64BA0-42BE-4BF2-B06E-663D7122AD48} = {011E8E6E-5B36-4E0C-A4AE-FF7B11579380}
6867
{C3E22928-FC40-47EF-A886-B37B7B96D9B4} = {E5F2ACD7-7D4E-449B-94D3-62F8185E7AAE}

docs/intro/getting-started-with-oauth.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ An OAUTH2.0 server can be hosted in ASP.NET CORE project by following the follow
77

88
2) Install the Nuget package **SimpleIdServer.OAuth**.
99

10-
3) In the Startup.cs file, insert the following line at the end on the **ConfigureServices** method : **services.AddSIDOAuth()**.
10+
3) In the Startup.cs file, insert the following line at the end of the **ConfigureServices** method : **services.AddSIDOAuth()**.
1111

12-
4) In the Startup.cs file, insert the following line at the end of the **Configure** method : **app.UseSID()**.
12+
4) In the Startup.cs file, use the function **AddAuthentication** to add authentication services for example : *services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();*
13+
14+
5) In the Startup.cs file, use the function **AddAuthorization** to add authorization rules for example : *services.AddAuthorization(opts => opts.AddDefaultOAUTHAuthorizationPolicy());*.
15+
16+
6) In the Startup.cs file, update the **Configure** method to configure the routing engine.
1317

1418
5) Run the application and verify JSON is returned when you browse the following url : https://localhost:<sslPort>/.well-known/oauth-authorization-server. The application URL and SSL port are defined in the launchSettings.json file located in your application Properties folder.
1519

docs/intro/getting-started-with-openid.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ For example, login password authentication with Bootstrap4 theme can be installe
1919

2020
3) In the **Startup.cs** file, insert the following line at the end of **ConfigureServices** method : **services.AddSIDOpenID().AddLoginPasswordAuthentication()**.
2121

22-
4) Run the application and browse the URL https://localhost:<sslPort>/authorization?client_id=f3d35cce-de69-45bf-958c-4a8796f8ed37&redirect_uri=http://localhost:8080&response_type=code&scope=openid profile&state=state.
22+
4) Run the application and browse the URL https://localhost:<sslPort>/authorization?client_id=umaClient&redirect_uri=https://localhost:60001/signin-oidc&response_type=code&scope=openid profile&state=state.
2323

24-
6) Authenticate with the credentials : Login : administrator, Password : password
24+
6) Authenticate with the credentials : Login : umaUser, Password : password
2525

2626
7) Confirm the consent.
2727

28-
8) User agent will be redirected to the callback url http://localhost:8080, the authorization code is passed in the query.
28+
8) User agent will be redirected to the callback url https://localhost:60001, the authorization code is passed in the query.
2929

3030
OPENID server is similar to OAUTH2.0 server, in fact by default clients, scopes, users and JSON Web Keys are stored in memory.
3131
OPENID introduces the concept of **Authentication Context Class Reference** (ACR), default values can be overridden like this::

docs/intro/getting-started-with-scim.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ A system for Cross-domain Identity Management (SCIM2.0) can be hosted in ASP.NET
77

88
2) Install the Nuget package **SimpleIdServer.Scim**.
99

10-
3) In the Startup.cs file, insert the following line at the end on the **ConfigureServices** method : **services.AddSIDScim()**.
10+
3) In the Startup.cs file, insert the following line at the end of the **ConfigureServices** method : **services.AddSIDScim()**.
1111

12-
4) In the Startup.cs file, use the function **AddAuthentication** returned by **AddSIDScim()** to add authentication services and use the authentication scheme **SCIMConstants.AuthenticationScheme** for example : *services.AddSIDScim().AddAuthentication(s => s.AddCookie(SCIMConstants.AuthenticationScheme));*
12+
4) In the Startup.cs file, use the function **AddAuthentication** to add authentication services and use the authentication scheme **SCIMConstants.AuthenticationScheme** for example : *services.AddAuthentication(SCIMConstants.AuthenticationScheme).AddCookie(SCIMConstants.AuthenticationScheme);*
1313

14-
5) In the Startup.cs file, insert the following line at the end of the **Configure** method : **app.UseSID()**.
14+
5) In the Startup.cs file, use the function **AddAuthorization** to add authorization rules for example : *services.AddAuthorization(opts => opts.AddDefaultSCIMAuthorizationPolicy());*.
1515

16-
6) Run the application and verify JSON is returned when you browse the following url : https://localhost:<sslPort>/Schemas.
16+
6) In the Startup.cs file, update the **Configure** method to configure the routing engine.
17+
18+
7) Run the application and verify JSON is returned when you browse the following url : https://localhost:<sslPort>/Schemas.
1719

1820
By default SCIM schemas are stored in memory, default values can be overridden like this::
1921

samples/ProtectAPIFromUndesirableClients/src/ProtectAPIFromUndesirableClients.OAuth/ProtectAPIFromUndesirableClients.OAuth.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageReference Include="Microsoft.AspNetCore.App" />
8-
<PackageReference Include="SimpleIdServer.OAuth" Version="1.0.3" />
8+
<PackageReference Include="SimpleIdServer.OAuth" Version="1.0.4" />
99
</ItemGroup>
1010
<ItemGroup>
1111
<None Update="oauth_key.txt">

samples/ProtectAPIFromUndesirableClients/src/ProtectAPIFromUndesirableClients.OAuth/Startup.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) SimpleIdServer. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
using Microsoft.AspNetCore.Authentication.Cookies;
34
using Microsoft.AspNetCore.Builder;
45
using Microsoft.AspNetCore.Hosting;
56
using Microsoft.Extensions.DependencyInjection;
@@ -37,6 +38,9 @@ public void ConfigureServices(IServiceCollection services)
3738
}).SetAlg(rsa, "RS256").Build();
3839
}
3940

41+
services.AddMvc();
42+
services.AddAuthorization(opts => opts.AddDefaultOAUTHAuthorizationPolicy());
43+
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
4044
services.AddSIDOAuth()
4145
.AddScopes(DefaultConfiguration.Scopes)
4246
.AddClients(DefaultConfiguration.Clients)
@@ -45,7 +49,8 @@ public void ConfigureServices(IServiceCollection services)
4549

4650
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
4751
{
48-
app.UseSID();
52+
app.UseAuthentication();
53+
app.UseMvc();
4954
}
5055
}
5156
}

samples/ProtectAPIFromUndesirableUsers/src/ProtectAPIFromUndesirableUsers.OpenId/ProtectAPIFromUndesirableUsers.OpenId.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageReference Include="Microsoft.AspNetCore.App" />
8-
<PackageReference Include="SimpleIdServer.OpenID.Bootstrap4" Version="1.0.3" />
9-
<PackageReference Include="SimpleIdServer.UI.Authenticate.LoginPassword.Bootstrap4" Version="1.0.3" />
8+
<PackageReference Include="SimpleIdServer.OpenID.Bootstrap4" Version="1.0.4" />
9+
<PackageReference Include="SimpleIdServer.UI.Authenticate.LoginPassword.Bootstrap4" Version="1.0.4" />
1010
</ItemGroup>
1111
<ItemGroup>
1212
<Compile Update="Resources\Global.Designer.cs">

0 commit comments

Comments
 (0)