Created
May 13, 2020 17:53
-
-
Save xsolon/89bf6d8e3eb7c6fadb45bdc49f0c92f6 to your computer and use it in GitHub Desktop.
SharePoint On Premise App trust setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configure Trust ---------------------------------------------------------------- | |
$certPath = "C:\cert.cer" | |
$certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath) | |
$appName = 'appName' | |
New-SPTrustedRootAuthority -Name $appName -Certificate $certificate | |
$realm = Get-SPAuthenticationRealm | |
$specificIssuerId = "11115920-1111-1111-1111-111111111111" # use lower case for GUID | |
$fullIssuerIdentifier = $specificIssuerId + '@' + $realm | |
$issuer = New-SPTrustedSecurityTokenIssuer -Name $appName -Certificate $certificate -RegisteredIssuerName $fullIssuerIdentifier -IsTrustBroker | |
iisreset | |
# dev only http | |
$serviceConfig = Get-SPSecurityTokenServiceConfig | |
$serviceConfig.AllowOAuthOverHttp = $true | |
$serviceConfig.Update() | |
# App Permissions ---------------------------------------------------------------- | |
$spurl ="https://site" | |
$spsite = Get-SPSite $spurl | |
$specificIssuerId = "11115920-1111-1111-1111-111111111111" # use lower case for GUID | |
$realm = Get-SPAuthenticationRealm -ServiceContext $spsite | |
$fullAppIdentifier = $specificIssuerId + '@' + $realm | |
$appPrincipal = Register-SPAppPrincipal -NameIdentifier $fullAppIdentifier -Site $spsite.OpenWeb() -DisplayName $appName | |
Set-SPAppPrincipalPermission -AppPrincipal $appPrincipal -Site $spsite.Rootweb -Scope SiteCollection -Right FullControl -EnableAppOnlyPolicy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment