Skip to content

Commit

Permalink
Contributing testing cert creation docs update
Browse files Browse the repository at this point in the history
Fixed bug in sample settings file.
  • Loading branch information
juliemturner committed Feb 22, 2022
1 parent dd68288 commit d8d5dc4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
14 changes: 12 additions & 2 deletions docs/contributing/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ MSAL configuration has two parts, these are the initialization which is passed d

> If you are calling Microsoft Graph sovereign or gov clouds the scope may need to be updated.
You will need to create testing certs for the sample settings file below. Using the following code you end up with three files, "cert.pem", "key.pem", and "keytmp.pem". The "cert.pem" file is uploaded to your AAD application registration. The "key.pem" is read as the private key for the configuration. Copy the contents of the "key.pem" file and paste it in the `privateKey` variable below. The `gitignore` file in this repository will ignore the settings.js file.

>Replace `HereIsMySuperPass` with your own password
```cmd
mkdir \temp
cd \temp
openssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365 -passout pass:HereIsMySuperPass -subj '/C=US/ST=Washington/L=Seattle'
openssl rsa -in keytmp.pem -out key.pem -passin pass:HereIsMySuperPass
```

```JavaScript
const privateKey = `-----BEGIN RSA PRIVATE KEY-----
your private key, read from a file or included here
Expand All @@ -29,7 +40,7 @@ var msalInit = {
}
}

var settings = {
export const settings = {
testing: {
enableWebTests: true,
testUser: "i:0#.f|membership|[email protected]",
Expand All @@ -50,7 +61,6 @@ var settings = {
},
}

module.exports = settings;
```

The settings object has a single sub-object `testing` which contains the configuration used for debugging and testing PnPjs. The parts of this object are described in detail below.
Expand Down
37 changes: 23 additions & 14 deletions settings.example.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
export const settings = {
const privateKey = `-----BEGIN RSA PRIVATE KEY-----
{contents of key.pem file}
-----END RSA PRIVATE KEY-----
`;

// any of the settings available for msal-node client, passed to the constructor
// https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-node

// PnP example: https://pnp.github.io/pnpjs/authentication/server-nodejs/#call-sharepoint
var msalInit = {
auth: {
authority: "https://login.microsoftonline.com/{tenant Id}/",
clientCertificate: {
thumbprint: "{Thumbprint from your cert.pem file -- shown in AAD App Registration}",
privateKey: privateKey,
},
clientId: "{AAD Application Id/Client Id}",
}
}

export const settings = {
testing: {
enableWebTests: true,
// AAD login for test user
Expand All @@ -15,12 +34,7 @@ export const settings = {
notificationUrl: "{ notification url }",
// for new deployments we recommend the msal settings that can then be applied to both graph and SharePoint
msal: {
init: {
// any of the settings available for msal-node client, passed to the constructor
// https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-node

// PnP example: https://pnp.github.io/pnpjs/authentication/server-nodejs/#call-sharepoint
},
init: msalInit,
// set your scopes as needed here
scopes: ["https://{tenant}.sharepoint.com/.default"]
},
Expand All @@ -33,15 +47,10 @@ export const settings = {
secret: "{your secret}",
// for new deployments we recommend the msal settings that can then be applied to both graph and SharePoint
msal: {
init: {
// any of the settings available for msal-node client, passed to the constructor
// https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/lib/msal-node

// PnP example: https://pnp.github.io/pnpjs/authentication/server-nodejs/#call-sharepoint
},
init: msalInit,
// set your scopes as needed here
scopes: ["https://graph.microsoft.com/.default"]
},
},
}
}
}

0 comments on commit d8d5dc4

Please sign in to comment.