| 1 |
Sharepoint |
| 2 |
========== |
| 3 |
|
| 4 |
|logo| |
| 5 |
|
| 6 |
Presentation |
| 7 |
------------ |
| 8 |
|
| 9 |
Sharepoint is a content Management system which provide a lot of features for |
| 10 |
designing websites such as intranets, professional websites, blogs, home pages. |
| 11 |
|
| 12 |
It can be configured to authenticate users with :doc:`OpenID Connect <../idpopenidconnect>`. |
| 13 |
|
| 14 |
.. versionadded:: 2.0.16 |
| 15 |
|
| 16 |
Because Sharepoint requires support for the *OAuth 2.0 Form Post Response Mode* |
| 17 |
feature, it only works starting with LemonLDAP::NG 2.0.16 and above |
| 18 |
|
| 19 |
|
| 20 |
.. warning:: |
| 21 |
Configuring Sharepoint for OpenID Connect is a complex operation which |
| 22 |
requires some familiarity with Microsoft products, and a good knowledge of |
| 23 |
OpenID Connect. This documentation is only meant to help you configure |
| 24 |
LemonLDAP::NG to work with Sharepoint, but is not a complete, up-to-date |
| 25 |
walkthrough. |
| 26 |
|
| 27 |
Configuration |
| 28 |
------------- |
| 29 |
|
| 30 |
LemonLDAP::NG |
| 31 |
~~~~~~~~~~~~~ |
| 32 |
|
| 33 |
|
| 34 |
Make sure you have already |
| 35 |
:doc:`enabled OpenID Connect<../idpopenidconnect>` on your LemonLDAP::NG |
| 36 |
server. |
| 37 |
|
| 38 |
Make sure you have generated a set of signing keys in |
| 39 |
``OpenID Connect Service`` > ``Security`` > ``Keys`` |
| 40 |
|
| 41 |
The signing public key must be in `BEGIN CERTIFICATE` format, check :ref:`the |
| 42 |
OIDC certificate conversion instructions <x5c>` for details if you are |
| 43 |
currently using a public key in `BEGIN PUBLIC KEY` format. |
| 44 |
|
| 45 |
Add a Relying Party with the following configuration: |
| 46 |
|
| 47 |
- Options > Basic > Client ID : choose a client ID, such as ``my_client_id`` |
| 48 |
- Options > Basic > Public client : set to ``Enabled`` |
| 49 |
- Options > Basic > Client Secret : leave empty |
| 50 |
- Options > Basic > Allowed redirection address : ``https://spsites.contoso.local/`` (adjust to your own URL) |
| 51 |
- Options > Advanced > Force claims to be returned in ID Token : ``On`` |
| 52 |
- Options > Security > ID Token Signature Algorithm : ``RS256`` |
| 53 |
|
| 54 |
Define *Scope values content*: |
| 55 |
|
| 56 |
- ``email`` => ``http://schemas.xmlsoap.org/claims/CommonName http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress`` |
| 57 |
|
| 58 |
Define exported attributes: |
| 59 |
|
| 60 |
- ``http://schemas.xmlsoap.org/claims/CommonName`` => ``cn`` (or LemonLDAP variable containing the common name) |
| 61 |
- ``http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname`` => ``givenName`` (or LemonLDAP variable containing the given name) |
| 62 |
- ``http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname`` => ``sn`` (or LemonLDAP variable containing the surname) |
| 63 |
- ``http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress`` => ``mail`` (or LemonLDAP variable containing the email) |
| 64 |
|
| 65 |
|
| 66 |
SharePoint |
| 67 |
~~~~~~~~~~ |
| 68 |
|
| 69 |
Refer to the `Microsoft Sharepoint OpenID Connect documentation |
| 70 |
<https://learn.microsoft.com/en-us/sharepoint/security-for-sharepoint-server/oidc-1-0-authentication>`__ |
| 71 |
for instructions. |
| 72 |
|
| 73 |
|
| 74 |
You do not need an Azure AD or Azure ADFS, so you can skip the steps regarding |
| 75 |
Azure AD/ADFS. You should not need to configure the identity provider manually. |
| 76 |
If you use LemonLDAP 2.0.16 and above, with a certificate as your OIDC signing |
| 77 |
key, the OpenID Connect JWKS document should contain the `x5c` field expected |
| 78 |
by sharepoint. |
| 79 |
|
| 80 |
First you need to create a Web application through the Sharepoint Manager A web |
| 81 |
application could contain several site ( called "collection") |
| 82 |
|
| 83 |
The authentication method is applied to a web application and collection |
| 84 |
behind |
| 85 |
|
| 86 |
All URL of each site must be declared as an allowed redirection address in LemonLDAP::NG |
| 87 |
|
| 88 |
You need to execute a powershell script which : |
| 89 |
|
| 90 |
- defines claims |
| 91 |
- defines metadata url |
| 92 |
- defines ClientID |
| 93 |
- defines Service account of website |
| 94 |
- generates a certificates for cookie |
| 95 |
- generates an Token Issuer objects |
| 96 |
- generates an Authentication Provider from Token Issuer |
| 97 |
|
| 98 |
Here is a sample script, make sure to adapt it to your needs, and always refer |
| 99 |
to official Microsoft documentation if you have any doubts |
| 100 |
|
| 101 |
.. code-block:: bash |
| 102 |
|
| 103 |
# set the owner of Web application Pool see : you could get it through the |
| 104 |
# IIS interface > Application Pool |
| 105 |
# You could pick the owner of the corresponding Web Application |
| 106 |
$webApplicationPoolUser="DOMAIN\user" |
| 107 |
|
| 108 |
# Set the AAD metadata endpoint URL. Please replace <TenantID> with the |
| 109 |
value saved in step #3 in AAD setup section |
| 110 |
$metadataendpointurl = "https://auth.lemonportal.org/.well-known/openid-configuration" |
| 111 |
|
| 112 |
# Please replace <Application (Client) ID> with the value saved in step #3 |
| 113 |
# in AAD setup section |
| 114 |
$clientIdentifier = "APP-ID" |
| 115 |
|
| 116 |
# list of Claim types |
| 117 |
|
| 118 |
$email = New-SPClaimTypeMapping "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" -IncomingClaimTypeDisplayName "EmailAddress" -SameAsIncoming |
| 119 |
$cn = New-SPClaimTypeMapping "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/CommonName"-IncomingClaimTypeDisplayName "CommonName" -SameAsIncoming |
| 120 |
$sn = New-SPClaimTypeMapping "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname" -IncomingClaimTypeDisplayName "surname" -SameAsIncoming |
| 121 |
$givenName = New-SPClaimTypeMapping "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"-IncomingClaimTypeDisplayName "givenName" -SameAsIncoming |
| 122 |
|
| 123 |
|
| 124 |
# |
| 125 |
# CERTIFICATs FOR Secure COOKIE |
| 126 |
# certificats and key muste be exported and spread on each sharepoint server in farm |
| 127 |
# |
| 128 |
# |
| 129 |
|
| 130 |
# Setup farm properties to work with OIDC |
| 131 |
$cert = New-SelfSignedCertificate -CertStoreLocation Cert:\LocalMachine\My -Provider 'Microsoft Enhanced RSA and AES Cryptographic Provider' -Subject "CN=SharePoint Cookie Cert for LLNG Demo" |
| 132 |
$rsaCert = [System.Security.Cryptography.X509Certificates.RSACertificateExtensions]::GetRSAPrivateKey($cert) |
| 133 |
$fileName = $rsaCert.key.UniqueName |
| 134 |
|
| 135 |
# if you have multiple SharePoint servers in the farm, you need to export |
| 136 |
# certificate by Export-PfxCertificate and import certificate to all other |
| 137 |
# SharePoint servers in the farm by Import-PfxCertificate. |
| 138 |
|
| 139 |
# After certificate is successfully imported to SharePoint Server, we will |
| 140 |
# need to grant access permission to certificate private key. |
| 141 |
|
| 142 |
$path = "$env:ALLUSERSPROFILE\Microsoft\Crypto\RSA\MachineKeys\$fileName" |
| 143 |
$permissions = Get-Acl -Path $path |
| 144 |
|
| 145 |
#Please replace the <web application pool account> with real application |
| 146 |
# pool account of your web application |
| 147 |
$access_rule = New-Object System.Security.AccessControl.FileSystemAccessRule($webApplicationPoolUser, 'Read', 'None', 'None', 'Allow') |
| 148 |
$permissions.AddAccessRule($access_rule) |
| 149 |
Set-Acl -Path $path -AclObject $permissions |
| 150 |
|
| 151 |
#Then we update farm properties |
| 152 |
$f = Get-SPFarm |
| 153 |
$f.Farm.Properties['SP-NonceCookieCertificateThumbprint']=$cert.Thumbprint |
| 154 |
$f.Farm.Properties['SP-NonceCookieHMACSecretKey']='seed' |
| 155 |
$f.Farm.Update() |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
# Create a new SPTrustedIdentityTokenIssuer in SharePoint |
| 161 |
$spTrust = New-SPTrustedIdentityTokenIssuer -Name "LemonLDAP_DEMO" -Description "lemonldap Demo" -ClaimsMappings $email,$cn,$sn,$givenName -IdentifierClaim $eppn.InputClaimType -DefaultClientIdentifier $clientIdentifier -MetadataEndPoint $metadataendpointurl -Scope "openid email" |
| 162 |
|
| 163 |
# Declare a SPAuthenticationProvider from SPTrustedIdentityTokenIssuer |
| 164 |
$trustedAp = New-SPAuthenticationProvider -TrustedIdentityTokenIssuer $spTrust |
| 165 |
|
| 166 |
|
| 167 |
After that you need to assign the new SPAuthenticationProvider to the Web application |
| 168 |
|
| 169 |
|image2| |
| 170 |
|
| 171 |
|
| 172 |
At this time you should restart IIS and the website |
| 173 |
|
| 174 |
|
| 175 |
By the way, despite you are authenticated, you could note access to Web site , |
| 176 |
you need to be authorized, It's a website's administrator job. Pay attention ! |
| 177 |
If you need to add a user, you must set the identifier of the user inside the |
| 178 |
searchbox and clique "OK" |
| 179 |
|
| 180 |
|
| 181 |
Troubleshooting |
| 182 |
~~~~~~~~~~~~~~~ |
| 183 |
|
| 184 |
If you got an error and the web page is displaying nothing relevant, see the URL |
| 185 |
Example in case of lack of sub :: |
| 186 |
|
| 187 |
<url>/_layouts/15/_login/default.aspx?errorCode=TrustedMissingIdentityClaimSource=<link source> |
| 188 |
|
| 189 |
.. |logo| image:: /applications/sharepoint.png |
| 190 |
|
| 191 |
.. |image2| image:: /applications/SharePoint-assign-AuthProvider.png |
| 192 |
:class: align-center |