Skip to content

Instantly share code, notes, and snippets.

Andrew Connell andrewconnell

Block or report user

Report or block andrewconnell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andrewconnell
andrewconnell / teams-manifest.json
Created Apr 24, 2019
Microsoft Teams Manifest file
View teams-manifest.json
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.2/MicrosoftTeams.schema.json",
"manifestVersion": "1.2",
"packageName": "{{SPFX_COMPONENT_ALIAS}}",
"id": "aa3fecf0-1fd0-4751-aba1-12314dc3a22f",
"version": "0.1",
"developer": {
"name": "Parker Porcupine",
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
@andrewconnell
andrewconnell / jest.config.json
Created Apr 15, 2019
Jest v24.* configuration with code coverage for SPFx projects
View jest.config.json
{
"collectCoverage": true,
"collectCoverageFrom": [
"<rootDir>/**/*.{ts,tsx}",
"!<rootDir>/**/*.scss.*",
"!<rootDir>/loc/**/*.*"
],
"coverageDirectory": "<rootDir>/../temp/test",
"coverageReporters": [
"json",
View spfx-1.8.0-typescript-3.3.sh
npm install @microsoft/rush-stack-compiler-3.3@0.1.6 typescript@3.3 --save-dev --exact
View post-spfx1.8.0-webpart.ts
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import {
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-property-pane';
View pre-spfx1.8.0-webpart.ts
import {
BaseClientSideWebPart,
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-webpart-base';
@andrewconnell
andrewconnell / decode-jwt-token.ts
Created Feb 18, 2019
Decode JTW token with TypeScript
View decode-jwt-token.ts
import jwt = require('jsonwebtoken');
const decodedValidToken = (accessToken: string) => {
const key: string = '-----BEGIN CERTIFICATE-----\nMIIDBTCCAe...\n-----END CERTIFICATE-----';
// decode & verify token
return jwt.verify(accessToken, key);
}
const authorizationHeader: string = req.headers.authorization;
@andrewconnell
andrewconnell / secure-rest-api.ts
Created Feb 18, 2019
Secure REST API (in Azure Function App) Using Permissions
View secure-rest-api.ts
if (isValidRequest) {
switch (req.method) {
case 'GET':
if (hasMissionReadScope) {
response = missionId ? getOne(missionId) : getMany();
} else {
response = {
status: HttpStatusCode.Unauthorized,
body: {
message: 'Insufficient permissions to retrieve missions. Missing scope Mission.Read.'
@andrewconnell
andrewconnell / secure-rest-api.ts
Last active Feb 18, 2019
Secure REST API - Detect permissions & user making the call
View secure-rest-api.ts
import jwt = require('jsonwebtoken');
const aadKey: string = // aad public key used to sign oauth access token
try {
const authorizationHeader: string = req.headers.authorization;
// decode the token using the AzureAD public signing key
const decodedToken = (jwt.verify(authorizationHeader.replace('Bearer ','')) as any), aadKey);
View grant-permission.sh
# start the Office 365 CLI
office365
# >>> make sure you are logged in
# just enough to connect to the endpoint, but not do anything
spo serviceprincipal grant add --resource "voitanos-secure" --scope "user_impersonation"
# get one or many Apollo Missions (HTTP GET)
spo serviceprincipal grant add --resource "voitanos-secure" --scope "Mission.Read"
You can’t perform that action at this time.