Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • Experimental/newSaml2
  • Fix/xxxx-migrateLogin
  • Hotfix/1234-handlingMergeToken
  • Hotfix/1354-workingFHLogin
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/1545-emptyUserGraphs
  • Hotfix/2087-efNet6
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameDev
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameUiv2
  • Hotfix/2169-ignoreAuthContext
  • Hotfix/2576-certificatePatch
  • Hotfix/2592-sameProvider
  • Hotfix/2775-dfnCertRollover
  • Hotfix/64-releaseUDE
  • Issue/1833-newLogin
  • Issue/1910-MigrationtoNET6.0
  • Issue/1964-tokenExpiryUIv2
  • Issue/1974-shibbolethLogout
  • Issue/2078-renamingEntitlementAcceptStaff
  • Issue/2078-renamingEntitlementAcceptStaffUiv2
  • Issue/2115-extendParsingPairwiseId
  • Issue/2147-exchangingCoscineCertificate
  • Issue/2147-exchangingCoscineCertificate-step2
  • Issue/2147-exchangingCoscineCertificate-step3
  • Issue/2309-docs
  • Issue/2325-fixApiTokenMerging
  • Issue/3003-stsInstitute
  • Issue/40-rdsQuotaForUKA
  • Product/1149-dfnaai
  • Product/1287-dotnet5Sharepoint
  • Product/1290-dfnaai
  • Product/1414-fhPrivileges
  • Product/1629-onboardingOtherUniversities
  • Product/797-overhaul
  • Product/917-maintenanceFunctionality
  • Sprint/2020-20
  • Sprint/2020-21
  • Sprint/2020-22
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-06
  • Sprint/2021-08
  • Sprint/2021-10
  • Sprint/2021-11
  • Sprint/2021-19
  • Sprint/2021-20
  • Sprint/2021-23
  • Sprint/2022-01
  • Topic/1224-overhaul
  • Topic/1276-DFN-AAIFrontend
  • Topic/1278-dfnAAI
  • Topic/1297-maintenanceBanner
  • Topic/1335-dotnet5Apis
  • Topic/1425-fhPrivileges
  • Topic/1711-extendResourceTypeConfiguration
  • dev
  • gitkeep
  • master
  • top
  • uiv2
  • v1.0.0
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.11.1
  • v1.11.2
  • v1.11.3
  • v1.12.0
  • v1.13.0
  • v1.14.0
  • v1.14.1
  • v1.15.0
  • v1.16.0
  • v1.16.1
  • v1.16.2
  • v1.17.0
  • v1.18.0
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.8.0
  • v1.8.1
  • v1.9.0
  • v1.9.1
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.2.3
  • v2.2.4
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.3.3
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v3.0.0
  • v3.1.0
  • v3.1.1
  • v3.1.2
  • v3.1.3
  • v3.1.4
  • v4.0.0
  • v4.0.1
  • v4.0.2
  • v4.0.3
  • v4.0.4
  • v4.0.5
  • v4.0.6
  • v4.0.7
  • v4.0.8
  • v4.0.9
  • v4.1.0
  • v4.1.1
129 results

Target

Select target project
  • coscine/backend/apis/sts
1 result
Select Git revision
  • Experimental/newSaml2
  • Fix/xxxx-migrateLogin
  • Hotfix/1234-handlingMergeToken
  • Hotfix/1354-workingFHLogin
  • Hotfix/1357-ymlFile
  • Hotfix/1370-swaggerDescription
  • Hotfix/1545-emptyUserGraphs
  • Hotfix/2087-efNet6
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameDev
  • Hotfix/2103-RepositoryurlstoConsulUpdateMappingGivennameUiv2
  • Hotfix/2169-ignoreAuthContext
  • Hotfix/2576-certificatePatch
  • Hotfix/2592-sameProvider
  • Hotfix/2775-dfnCertRollover
  • Hotfix/64-releaseUDE
  • Issue/1833-newLogin
  • Issue/1910-MigrationtoNET6.0
  • Issue/1964-tokenExpiryUIv2
  • Issue/1974-shibbolethLogout
  • Issue/2078-renamingEntitlementAcceptStaff
  • Issue/2078-renamingEntitlementAcceptStaffUiv2
  • Issue/2115-extendParsingPairwiseId
  • Issue/2147-exchangingCoscineCertificate
  • Issue/2147-exchangingCoscineCertificate-step2
  • Issue/2147-exchangingCoscineCertificate-step3
  • Issue/2309-docs
  • Issue/2325-fixApiTokenMerging
  • Issue/3003-stsInstitute
  • Issue/40-rdsQuotaForUKA
  • Product/1149-dfnaai
  • Product/1287-dotnet5Sharepoint
  • Product/1290-dfnaai
  • Product/1414-fhPrivileges
  • Product/1629-onboardingOtherUniversities
  • Product/797-overhaul
  • Product/917-maintenanceFunctionality
  • Sprint/2020-20
  • Sprint/2020-21
  • Sprint/2020-22
  • Sprint/2021-01
  • Sprint/2021-03
  • Sprint/2021-05
  • Sprint/2021-06
  • Sprint/2021-08
  • Sprint/2021-10
  • Sprint/2021-11
  • Sprint/2021-19
  • Sprint/2021-20
  • Sprint/2021-23
  • Sprint/2022-01
  • Topic/1224-overhaul
  • Topic/1276-DFN-AAIFrontend
  • Topic/1278-dfnAAI
  • Topic/1297-maintenanceBanner
  • Topic/1335-dotnet5Apis
  • Topic/1425-fhPrivileges
  • Topic/1711-extendResourceTypeConfiguration
  • dev
  • gitkeep
  • master
  • top
  • uiv2
  • v1.0.0
  • v1.1.0
  • v1.10.0
  • v1.10.1
  • v1.10.2
  • v1.11.0
  • v1.11.1
  • v1.11.2
  • v1.11.3
  • v1.12.0
  • v1.13.0
  • v1.14.0
  • v1.14.1
  • v1.15.0
  • v1.16.0
  • v1.16.1
  • v1.16.2
  • v1.17.0
  • v1.18.0
  • v1.2.0
  • v1.2.1
  • v1.3.0
  • v1.4.0
  • v1.5.0
  • v1.6.0
  • v1.7.0
  • v1.8.0
  • v1.8.1
  • v1.9.0
  • v1.9.1
  • v2.0.0
  • v2.0.1
  • v2.0.2
  • v2.0.3
  • v2.1.0
  • v2.2.0
  • v2.2.1
  • v2.2.2
  • v2.2.3
  • v2.2.4
  • v2.3.0
  • v2.3.1
  • v2.3.2
  • v2.3.3
  • v2.4.0
  • v2.4.1
  • v2.4.2
  • v2.4.3
  • v2.4.4
  • v3.0.0
  • v3.1.0
  • v3.1.1
  • v3.1.2
  • v3.1.3
  • v3.1.4
  • v4.0.0
  • v4.0.1
  • v4.0.2
  • v4.0.3
  • v4.0.4
  • v4.0.5
  • v4.0.6
  • v4.0.7
  • v4.0.8
  • v4.0.9
  • v4.1.0
  • v4.1.1
129 results
Show changes
Commits on Source (3)
......@@ -14,6 +14,10 @@ Instructions for making it run:
* Visit your SharePoint and put in your User Guid
* You find one from your Coscine database
* You should be logged in with that User Guid
* Set the value "coscine/global/ad/url" in your Consul storage with your Active Directory url
* Set the value "coscine/global/ad/ou" in your Consul storage with your Active Directory orginizational unit
* Set the value "coscine/global/ad/username" in your Consul storage with your Active Directory username
* Set the value "coscine/global/ad/password" in your Consul storage with your Active Directory password
* Have fun!
For ORCiD:
......
......@@ -14,6 +14,10 @@ Instructions for making it run:
* Visit your SharePoint and put in your User Guid
* You find one from your Coscine database
* You should be logged in with that User Guid
* Set the value "coscine/global/ad/url" in your Consul storage with your Active Directory url
* Set the value "coscine/global/ad/ou" in your Consul storage with your Active Directory orginizational unit
* Set the value "coscine/global/ad/username" in your Consul storage with your Active Directory username
* Set the value "coscine/global/ad/password" in your Consul storage with your Active Directory password
* Have fun!
### Links
......
......@@ -15,6 +15,8 @@ using System.Net;
using Microsoft.IdentityModel.Logging;
using Coscine.ApiCommons.Models;
using System.Linq;
using System.DirectoryServices;
using System.DirectoryServices.AccountManagement;
namespace Coscine.STS.Controllers
{
......@@ -67,7 +69,7 @@ namespace Coscine.STS.Controllers
UserPlainModel userPlainModel = new UserPlainModel(Program.Configuration);
var user = new User
{
DisplayName = givenname + " " + surname,
DisplayName = (givenname + " " + surname).Trim(),
EmailAddress = ORCiD + "@orcid.org",
Surname = surname,
Givenname = givenname
......
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("STS is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("STS")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: AssemblyInformationalVersion("1.5.0.0")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyFileVersion("1.6.0.0")]
[assembly: AssemblyInformationalVersion("1.6.0.0")]
[assembly: AssemblyCopyright("2019 IT Center, RWTH Aachen University")]
......@@ -9,8 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Coscine.ApiCommons" Version="1.2.1" />
<PackageReference Include="Coscine.Database" Version="1.5.1" />
<PackageReference Include="Coscine.ApiCommons" Version="1.2.2" />
<PackageReference Include="Coscine.Database" Version="1.10.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
......@@ -21,6 +21,9 @@
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.IdentityModel" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.2.0" />
<PackageReference Include="System.DirectoryServices" Version="4.6.0" />
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="4.6.0" />
<PackageReference Include="System.DirectoryServices.Protocols" Version="4.6.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
</ItemGroup>
......
using Coscine.ApiCommons.Models;
using System;
using System.Configuration;
using System.DirectoryServices;
using System.IdentityModel;
using System.IdentityModel.Configuration;
using System.IdentityModel.Protocols.WSTrust;
......@@ -77,6 +78,8 @@ namespace Coscine.STS.Security
UserPlainModel userPlainModel = new UserPlainModel(Program.Configuration);
var user = userPlainModel.GetById(Guid.Parse(principal.Identity.Name));
AddToAD(user);
var claims = new[]
{
new Claim(System.IdentityModel.Claims.ClaimTypes.Name, user.DisplayName),
......@@ -91,6 +94,49 @@ namespace Coscine.STS.Security
return identity;
}
private static void AddToAD(Database.Model.User user)
{
// If keys exist
if (Program.Configuration.KeysAndWait("coscine/global/ad") != null)
{
var adUsername = Program.Configuration.GetStringAndWait("coscine/global/ad/username");
var adPassword = Program.Configuration.GetStringAndWait("coscine/global/ad/password");
using (DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://" + Program.Configuration.GetStringAndWait("coscine/global/ad/url"), adUsername, adPassword))
{
using (var coscineEntry = directoryEntry.Children.Find("OU=" + Program.Configuration.GetStringAndWait("coscine/global/ad/ou")))
{
try
{
// Check if user already exists in AD
coscineEntry.Children.Find("CN=" + user.Id);
}
catch (DirectoryServicesCOMException)
{
using (var newUser = coscineEntry.Children.Add("CN=" + user.Id, "User"))
{
newUser.Properties["sAMAccountName"].Value = user.Id.ToString().Substring(0, 20);
if (!string.IsNullOrWhiteSpace(user.Givenname))
{
newUser.Properties["givenName"].Value = user.Givenname;
}
if (!string.IsNullOrWhiteSpace(user.Surname))
{
newUser.Properties["sn"].Value = user.Surname;
}
newUser.Properties["displayName"].Value = user.DisplayName;
newUser.Properties["mail"].Value = user.EmailAddress;
newUser.Properties["uid"].Value = user.Id.ToString();
newUser.Properties["userPrincipalName"].Value = user.Id.ToString() + "@" + Program.Configuration.GetStringAndWait("coscine/global/ad/url");
newUser.CommitChanges();
}
}
}
}
}
}
public static X509Certificate2 GetCertificate()
{
var pfx = Program.Configuration.GetAndWait("coscine/global/sts/pfx");
......