Skip to content

Commit

Permalink
Merge pull request #1276 from OfficeDev/dev
Browse files Browse the repository at this point in the history
build: preview release 20240517
  • Loading branch information
MSFT-yiz committed May 17, 2024
2 parents abc25fa + 93bec57 commit b83537c
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 162 deletions.
37 changes: 19 additions & 18 deletions bot-sso-docker/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<div id="divError"></div>
<script type="text/javascript">
microsoftTeams.initialize();
let hashParams = getHashParameters();
microsoftTeams.app.initialize().then(() => {
let hashParams = getHashParameters();

if (hashParams["error"]) {
// Authentication failed
handleAuthError(hashParams["error"], hashParams);
} else if (hashParams["code"]) {
// Get the stored state parameter and compare with incoming state
let expectedState = localStorage.getItem("state");
if (expectedState !== hashParams["state"]) {
// State does not match, report error
handleAuthError("StateDoesNotMatch", hashParams);
if (hashParams["error"]) {
// Authentication failed
handleAuthError(hashParams["error"], hashParams);
} else if (hashParams["code"]) {
// Get the stored state parameter and compare with incoming state
let expectedState = localStorage.getItem("state");
if (expectedState !== hashParams["state"]) {
// State does not match, report error
handleAuthError("StateDoesNotMatch", hashParams);
} else {
microsoftTeams.authentication.notifySuccess();
}
} else {
microsoftTeams.authentication.notifySuccess();
// Unexpected condition: hash does not contain error or access_token parameter
handleAuthError("UnexpectedFailure", hashParams);
}
} else {
// Unexpected condition: hash does not contain error or access_token parameter
handleAuthError("UnexpectedFailure", hashParams);
}
});

// Parse hash parameters into key-value pairs
function getHashParameters() {
Expand Down
37 changes: 19 additions & 18 deletions bot-sso/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,32 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<div id="divError"></div>
<script type="text/javascript">
microsoftTeams.initialize();
let hashParams = getHashParameters();
microsoftTeams.app.initialize().then(() => {
let hashParams = getHashParameters();

if (hashParams["error"]) {
// Authentication failed
handleAuthError(hashParams["error"], hashParams);
} else if (hashParams["code"]) {
// Get the stored state parameter and compare with incoming state
let expectedState = localStorage.getItem("state");
if (expectedState !== hashParams["state"]) {
// State does not match, report error
handleAuthError("StateDoesNotMatch", hashParams);
if (hashParams["error"]) {
// Authentication failed
handleAuthError(hashParams["error"], hashParams);
} else if (hashParams["code"]) {
// Get the stored state parameter and compare with incoming state
let expectedState = localStorage.getItem("state");
if (expectedState !== hashParams["state"]) {
// State does not match, report error
handleAuthError("StateDoesNotMatch", hashParams);
} else {
microsoftTeams.authentication.notifySuccess();
}
} else {
microsoftTeams.authentication.notifySuccess();
// Unexpected condition: hash does not contain error or access_token parameter
handleAuthError("UnexpectedFailure", hashParams);
}
} else {
// Unexpected condition: hash does not contain error or access_token parameter
handleAuthError("UnexpectedFailure", hashParams);
}
});

// Parse hash parameters into key-value pairs
function getHashParameters() {
Expand Down
37 changes: 19 additions & 18 deletions command-bot-with-sso/src/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,32 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<div id="divError"></div>
<script type="text/javascript">
microsoftTeams.initialize();
let hashParams = getHashParameters();
microsoftTeams.app.initialize().then(() => {
let hashParams = getHashParameters();

if (hashParams.get("error")) {
// Authentication failed
handleAuthError(hashParams.get("error"), hashParams);
} else if (hashParams.get("code")) {
// Get the stored state parameter and compare with incoming state
let expectedState = localStorage.getItem("state");
if (expectedState !== hashParams.get("state")) {
// State does not match, report error
handleAuthError("StateDoesNotMatch", hashParams);
if (hashParams.get("error")) {
// Authentication failed
handleAuthError(hashParams.get("error"), hashParams);
} else if (hashParams.get("code")) {
// Get the stored state parameter and compare with incoming state
let expectedState = localStorage.getItem("state");
if (expectedState !== hashParams.get("state")) {
// State does not match, report error
handleAuthError("StateDoesNotMatch", hashParams);
} else {
microsoftTeams.authentication.notifySuccess();
}
} else {
microsoftTeams.authentication.notifySuccess();
// Unexpected condition: hash does not contain error or access_token parameter
handleAuthError("UnexpectedFailure", hashParams);
}
} else {
// Unexpected condition: hash does not contain error or access_token parameter
handleAuthError("UnexpectedFailure", hashParams);
}
});

// Parse hash parameters into key-value pairs
function getHashParameters() {
Expand Down
2 changes: 1 addition & 1 deletion developer-assist-dashboard/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@azure/functions": "^4.2.0",
"@microsoft/teamsfx": "^2.0.0",
"@microsoft/teams-js": "^2.7.1",
"@microsoft/teams-js": "^2.22.0",
"@octokit/core": "^5",
"isomorphic-fetch": "^3.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion developer-assist-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@fluentui/react-components": "^9.18.0",
"@fluentui/react-icons": "^2.0.186",
"@microsoft/microsoft-graph-client": "^3.0.5",
"@microsoft/teams-js": "^2.7.1",
"@microsoft/teams-js": "^2.22.0",
"@microsoft/teamsfx": "2.3.0",
"@microsoft/teamsfx-react": "3.1.0",
"axios": "^1.3.6",
Expand Down
4 changes: 2 additions & 2 deletions developer-assist-dashboard/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://res.cdn.office.net/teams-js/2.0.0/js/MicrosoftTeams.min.js"
integrity="sha384-QtTBFeFlfRDZBfwHJHYQp7MdLJ2C3sfAEB1Qpy+YblvjavBye+q87TELpTnvlXw4"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand Down
4 changes: 2 additions & 2 deletions developer-assist-dashboard/public/auth-start.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://res.cdn.office.net/teams-js/2.0.0/js/MicrosoftTeams.min.js"
integrity="sha384-QtTBFeFlfRDZBfwHJHYQp7MdLJ2C3sfAEB1Qpy+YblvjavBye+q87TELpTnvlXw4"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand Down
2 changes: 1 addition & 1 deletion hello-world-bot-with-tab/tab/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@fluentui/react-components": "^9.18.0",
"@microsoft/teams-js": "^2.7.1",
"@microsoft/teams-js": "^2.22.0",
"@microsoft/teamsfx": "^2.2.0",
"@microsoft/teamsfx-react": "^3.0.0",
"axios": "^1.6.7",
Expand Down
2 changes: 1 addition & 1 deletion hello-world-tab-docker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@fluentui/react-components": "^9.18.0",
"@microsoft/teams-js": "^2.7.1",
"@microsoft/teams-js": "^2.22.0",
"@microsoft/teamsfx": "^2.2.0",
"@microsoft/teamsfx-react": "^3.0.0",
"axios": "^0.21.1",
Expand Down
4 changes: 2 additions & 2 deletions hello-world-tab-docker/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://res.cdn.office.net/teams-js/2.0.0/js/MicrosoftTeams.min.js"
integrity="sha384-QtTBFeFlfRDZBfwHJHYQp7MdLJ2C3sfAEB1Qpy+YblvjavBye+q87TELpTnvlXw4"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand Down
4 changes: 2 additions & 2 deletions hello-world-tab-docker/public/auth-start.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://res.cdn.office.net/teams-js/2.0.0/js/MicrosoftTeams.min.js"
integrity="sha384-QtTBFeFlfRDZBfwHJHYQp7MdLJ2C3sfAEB1Qpy+YblvjavBye+q87TELpTnvlXw4"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand Down
2 changes: 1 addition & 1 deletion intelligent-data-chart-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@fluentui/react": "^8.114.2",
"@fluentui/react-components": "^9.44.2",
"@fluentui/react-icons": "^2.0.224",
"@microsoft/teams-js": "^2.18.0",
"@microsoft/teams-js": "^2.22.0",
"@microsoft/teamsfx": "^2.3.0",
"@microsoft/teamsfx-react": "^3.1.0",
"axios": "^1.6.5",
Expand Down
59 changes: 30 additions & 29 deletions intelligent-data-chart-generator/public/auth-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand All @@ -22,34 +22,35 @@
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");

microsoftTeams.initialize();
microsoftTeams.getContext(async function (context) {
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}
microsoftTeams.app.initialize().then(() => {
microsoftTeams.getContext(async function (context) {
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalInstance = new window.msal.PublicClientApplication(msalConfig);
msalInstance.handleRedirectPromise()
.then((tokenResponse) => {
if (tokenResponse !== null) {
microsoftTeams.authentication.notifySuccess(JSON.stringify({
sessionStorage: sessionStorage
}));
} else {
microsoftTeams.authentication.notifyFailure("Get empty response.");
}
})
.catch((error) => {
microsoftTeams.authentication.notifyFailure(JSON.stringify(error));
});
})
const msalInstance = new window.msal.PublicClientApplication(msalConfig);
msalInstance.handleRedirectPromise()
.then((tokenResponse) => {
if (tokenResponse !== null) {
microsoftTeams.authentication.notifySuccess(JSON.stringify({
sessionStorage: sessionStorage
}));
} else {
microsoftTeams.authentication.notifyFailure("Get empty response.");
}
})
.catch((error) => {
microsoftTeams.authentication.notifyFailure(JSON.stringify(error));
});
})
});
</script>
</body>
</html>
60 changes: 30 additions & 30 deletions intelligent-data-chart-generator/public/auth-start.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<body>
<script
src="https://statics.teams.cdn.office.net/sdk/v1.6.0/js/MicrosoftTeams.min.js"
integrity="sha384-mhp2E+BLMiZLe7rDIzj19WjgXJeI32NkPvrvvZBrMi5IvWup/1NUfS5xuYN5S3VT"
src="https://res.cdn.office.net/teams-js/2.22.0/js/MicrosoftTeams.min.js"
integrity="sha384-WSG/sWulIv7rel5TnFlH8JTpxl2OxzZh9Lux2mIzBFiTRLFvMBeFv9VURu/3vQdx"
crossorigin="anonymous"
></script>
<script
Expand All @@ -19,36 +19,36 @@
crossorigin="anonymous">
</script>
<script type="text/javascript">
microsoftTeams.initialize();
microsoftTeams.app.initialize().then(() => {
// Get the tab context, and use the information to navigate to Azure AD login page
microsoftTeams.getContext(async function (context) {
// Generate random state string and store it, so we can verify it in the callback
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");
var scope = currentURL.searchParams.get("scope");
var loginHint = currentURL.searchParams.get("loginHint");

// Get the tab context, and use the information to navigate to Azure AD login page
microsoftTeams.getContext(async function (context) {
// Generate random state string and store it, so we can verify it in the callback
var currentURL = new URL(window.location);
var clientId = currentURL.searchParams.get("clientId");
var scope = currentURL.searchParams.get("scope");
var loginHint = currentURL.searchParams.get("loginHint");
const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalConfig = {
auth: {
clientId: clientId,
authority: `https://login.microsoftonline.com/${context.tid}`,
navigateToLoginRequestUrl: false
},
cache: {
cacheLocation: "sessionStorage",
},
}

const msalInstance = new msal.PublicClientApplication(msalConfig);
const scopesArray = scope.split(" ");
const scopesRequest = {
scopes: scopesArray,
redirectUri: window.location.origin + `/auth-end.html?clientId=${clientId}`,
loginHint: loginHint,
prompt : "consent"
};
await msalInstance.loginRedirect(scopesRequest);
const msalInstance = new msal.PublicClientApplication(msalConfig);
const scopesArray = scope.split(" ");
const scopesRequest = {
scopes: scopesArray,
redirectUri: window.location.origin + `/auth-end.html?clientId=${clientId}`,
loginHint: loginHint,
prompt : "consent"
};
await msalInstance.loginRedirect(scopesRequest);
});
});
</script>
</body>
Expand Down

0 comments on commit b83537c

Please sign in to comment.