Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
06a744b
Initial Commit
tnorling May 15, 2020
f6fefcd
Create clientInfo from idToken
tnorling May 15, 2020
69e40cb
Merge branch 'cloud-discovery' of https://github.com/AzureAD/microsof…
tnorling May 27, 2020
56fdfdd
Update default type
tnorling May 27, 2020
10335de
Update Sample Readmes
tnorling May 27, 2020
520a465
Update package name for sample
tnorling May 27, 2020
c2ccdec
Merge branch 'cloud-discovery' of https://github.com/AzureAD/microsof…
tnorling Jun 3, 2020
00873a3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jun 3, 2020
93549a4
Strip Policy from UID
tnorling Jun 4, 2020
ccb09e7
Update policy strip logic
tnorling Jun 4, 2020
d8862d5
Sample
tnorling Jun 4, 2020
35ad895
Update with lab app registration
tnorling Jun 5, 2020
167ca67
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jun 15, 2020
47d0a87
Update AuthorityType logic
tnorling Jun 15, 2020
336fc2a
Remove sample
tnorling Jun 15, 2020
c88a12e
Move isAdfs to Authority class
tnorling Jun 15, 2020
661f000
Unit tests
tnorling Jun 15, 2020
3b9c058
Add tests
tnorling Jun 16, 2020
5197bc4
Add upn as backup for username
tnorling Jun 16, 2020
76b1685
Revert "Add upn as backup for username"
tnorling Jun 16, 2020
c969187
Add upn as backup for username
tnorling Jun 16, 2020
c91e0f0
Merge branch 'dev' into b2c-multiple-policies
tnorling Jun 16, 2020
456ba37
Remove samples, will be added in different PR
tnorling Jun 16, 2020
5a5472b
Address Feedback
tnorling Jun 16, 2020
5398cca
Update to ternary
tnorling Jun 16, 2020
dfa6f5d
Update lib/msal-core/src/ClientInfo.ts
tnorling Jun 17, 2020
6114764
Merge branch 'msal-core-adfs' of https://github.com/AzureAD/microsoft…
tnorling Jun 17, 2020
a283256
Add sample + E2E
tnorling Jun 17, 2020
afd59f0
Update testRunner and LabClient
tnorling Jun 17, 2020
9b29939
Merge branch 'dev' into msal-core-adfs
tnorling Jun 17, 2020
4a6d1d3
Merge branch 'msal-core-adfs' of https://github.com/AzureAD/microsoft…
tnorling Jun 17, 2020
85a990a
Add readme to sample
tnorling Jun 22, 2020
c8c7a1e
Update server port
tnorling Jun 23, 2020
ab12b92
Update samples/VanillaJSTestApp/app/adfs/Readme.md
tnorling Jun 23, 2020
88c9132
Addressing feedback
tnorling Jun 24, 2020
6a962d5
Merge branch 'adfs-sample' of https://github.com/AzureAD/microsoft-au…
tnorling Jun 24, 2020
c1b8d1a
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Jul 7, 2020
4a664b9
Fix linting
tnorling Jul 7, 2020
176334f
Merge branch 'dev' into msal-core-adfs
tnorling Jul 25, 2020
2201bd3
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 10, 2020
f674871
Cleanup
tnorling Aug 10, 2020
b861e2d
Update FAQ
tnorling Aug 10, 2020
553a623
Merge branch 'dev' into msal-core-adfs
tnorling Aug 11, 2020
63bac81
Change files
tnorling Aug 12, 2020
c08165c
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 12, 2020
91dc3ac
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 12, 2020
b082274
Tests passing
tnorling Aug 12, 2020
d5548a1
Change files
tnorling Aug 12, 2020
c400722
Merge branch 'dev' into msal-core-adfs
tnorling Aug 17, 2020
5f10555
Merge pull request #1668 from AzureAD/msal-core-adfs
tnorling Aug 17, 2020
30f7b66
Merge branch '1.4.0-release' of https://github.com/AzureAD/microsoft-…
tnorling Aug 17, 2020
603c101
[msal-core] Fix response type configuration by basing it mainly on sc…
Aug 17, 2020
cefd4ca
Merge branch '1.4.0-release' of https://github.com/AzureAD/microsoft-…
tnorling Aug 17, 2020
3782c0b
Update test
tnorling Aug 17, 2020
364621d
Update samples/VanillaJSTestApp/app/adfs/Readme.md
tnorling Aug 17, 2020
4fcdb41
Update welcome message
tnorling Aug 17, 2020
f5378d3
Merge branch 'adfs-sample' of https://github.com/AzureAD/microsoft-au…
tnorling Aug 17, 2020
c4fc53c
Add federationProvider to LabClient
tnorling Aug 17, 2020
2e2116d
Merge pull request #1791 from AzureAD/adfs-sample
tnorling Aug 18, 2020
065b8d8
Fix heading
tnorling Aug 18, 2020
83746d1
Update lib/msal-core/docs/FAQ.md
tnorling Aug 18, 2020
2be68fb
Merge branch '1.4.0-release' of https://github.com/AzureAD/microsoft-…
tnorling Aug 18, 2020
148fa9b
Address Feedback
tnorling Aug 18, 2020
9c011d5
Tests passing
tnorling Aug 19, 2020
f10c797
Merge pull request #1757 from AzureAD/b2c-multiple-policies
tnorling Aug 19, 2020
649a731
[msal-core] Fix invalid state issue by removing second layer of URL d…
Aug 20, 2020
c45ccd5
Merge branch 'dev' of https://github.com/AzureAD/microsoft-authentica…
tnorling Aug 24, 2020
efcfbb2
Update SRI hashes
tnorling Aug 24, 2020
2985cc2
Merge branch 'dev' into 1.4.0-release
tnorling Aug 24, 2020
552edd5
Merge branch 'dev' into 1.4.0-release
tnorling Aug 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ADFS Support

MSAL.js supports connecting to Azure AD, which signs in managed-users (users managed in Azure AD) or federated users (users managed by another identity provider such as ADFS). MSAL.js does not differentiate between these two types of users. As far as it’s concerned, it talks to Azure AD. The authority that you would pass in this case is the normal Azure AD Authority: `https://login.microsoftonline.com/{Enter_the_Tenant_Info_Here}`

MSAL.js also supports directly connecting to ADFS 2019, which is OpenID Connect compliant and has support for scopes and PKCE. This support requires that a service pack [KB 4490481](https://support.microsoft.com/en-us/help/4490481/windows-10-update-kb4490481) is applied to Windows Server. When connecting directly to ADFS, the authority you'll want to use to build your application will be of form `https://mysite.contoso.com/adfs/`

Currently, there are no plans to support a direct connection to ADFS 16 or ADFS v2. ADFS 16 does not support scopes, and ADFS v2 is not OIDC compliant.
93 changes: 93 additions & 0 deletions samples/msal-core-samples/VanillaJSTestApp/app/adfs/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Browser check variables
// If you support IE, our recommendation is that you sign-in using Redirect APIs
// If you as a developer are testing using Edge InPrivate mode, please add "isEdge" to the if check
const ua = window.navigator.userAgent;
const msie = ua.indexOf("MSIE ");
const msie11 = ua.indexOf("Trident/");
const msedge = ua.indexOf("Edge/");
const isIE = msie > 0 || msie11 > 0;
const isEdge = msedge > 0;

let signInType;

// Create the main myMSALObj instance
// configuration parameters are located at authConfig.js
const myMSALObj = new Msal.UserAgentApplication(msalConfig);

// Register Callbacks for Redirect flow
myMSALObj.handleRedirectCallback(authRedirectCallBack);

function authRedirectCallBack(error, response) {
if (error) {
console.log(error);
} else {
if (response.tokenType === "id_token" && myMSALObj.getAccount() && !myMSALObj.isCallback(window.location.hash)) {
console.log('id_token acquired at: ' + new Date().toString());
showWelcomeMessage(myMSALObj.getAccount());
} else if (response.tokenType === "access_token") {
console.log('access_token acquired at: ' + new Date().toString());
updateUI(response);
accessTokenButtonPopup.style.display = 'none';
accessTokenButtonRedirect.style.display = 'none';
} else {
console.log("token type is:" + response.tokenType);
}
}
}

// Redirect: once login is successful and redirects with tokens, call Graph API
if (myMSALObj.getAccount() && !myMSALObj.isCallback(window.location.hash)) {
// avoid duplicate code execution on page load in case of iframe and Popup window.
showWelcomeMessage(myMSALObj.getAccount());
}

function signIn(method) {
signInType = isIE ? "loginRedirect" : method;
if (signInType === "loginPopup") {
myMSALObj.loginPopup(loginRequest)
.then(loginResponse => {
console.log(loginResponse);
if (myMSALObj.getAccount()) {
showWelcomeMessage(myMSALObj.getAccount());
}
}).catch(function (error) {
console.log(error);
});
} else if (signInType === "loginRedirect") {
myMSALObj.loginRedirect(loginRequest)
}
}

function signOut() {
myMSALObj.logout();
}

function getAccessTokenPopup() {
if (myMSALObj.getAccount()) {
myMSALObj.acquireTokenPopup(loginRequest).then(response => {
updateUI(response);
accessTokenButtonPopup.style.display = 'none';
accessTokenButtonRedirect.style.display = 'none';
}).catch(error => {
console.log(error);
});
}
}

function getAccessTokenRedirect() {
if (myMSALObj.getAccount()) {
myMSALObj.acquireTokenRedirect(loginRequest);
}
}

function getAccessTokenSilent() {
if (myMSALObj.getAccount()) {
myMSALObj.acquireTokenSilent(loginRequest).then(response => {
updateUI(response);
accessTokenButtonPopup.style.display = 'none';
accessTokenButtonRedirect.style.display = 'none';
}).catch(error => {
console.log(error);
})
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Config object to be passed to Msal on creation
const msalConfig = {
auth: {
clientId: "57448aa1-9515-4176-a106-5cb9be8550e1",
authority: "https://fs.msidlab8.com/adfs/",
knownAuthorities: ["fs.msidlab8.com"]
},
cache: {
cacheLocation: "localStorage", // This configures where your cache will be stored
storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
}
};

// Add here scopes for id token to be used at MS Identity Platform endpoints.
const loginRequest = {
scopes: ["openid", "profile"],
forceRefresh: false // Set this to "true" to skip a cached token and go to the server to get a new token
};
73 changes: 73 additions & 0 deletions samples/msal-core-samples/VanillaJSTestApp/app/adfs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<title>Quickstart | MSAL.JS with ADFS 2019 Vanilla JavaScript SPA</title>

<!-- IE support: add promises polyfill before msal.js -->
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/[email protected]/js/browser/bluebird.min.js"></script>
<script src="./dist/msal.js"></script>

<!-- adding Bootstrap 4 for UI components -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="/">MS Identity Platform</a>
<div class="btn-group ml-auto dropleft">
<button type="button" id="SignIn" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Sign In
</button>
<div class="dropdown-menu">
<button class="dropdown-item" id="loginPopup" onclick="signIn(this.id)">Sign in using Popup</button>
<button class="dropdown-item" id="loginRedirect" onclick="signIn(this.id)">Sign in using Redirect</button>
</div>
</div>
</nav>
<br>
<h5 class="card-header text-center">Vanilla JavaScript SPA calling MS Graph API with MSAL.JS</h5>
<br>
<div class="row" style="margin:auto" >
<div id="card-div" class="col-md-3" style="display:none">
<div class="card text-center">
<div class="card-body">
<h5 class="card-title" id="WelcomeMessage">Please sign-in to acquire an access token</h5>
<div id="profile-div"></div>
<br>
<br>
<button class="btn btn-primary" id="getAccessTokenRedirect" onclick="getAccessTokenRedirect()">Get Access Token (Redirect)</button>
<br>
<br>
<button class="btn btn-primary" id="getAccessTokenPopup" onclick="getAccessTokenPopup()">Get Access Token (Popup)</button>
<br>
<br>
<button class="btn btn-primary" id="getAccessTokenSilent" onclick="getAccessTokenSilent()">Get Access Token (Silent)</button>
</div>
</div>
</div>
<br>
<br>
<div class="col-md-4">
<div class="list-group" id="list-tab" role="tablist">
</div>
</div>
<div class="col-md-5">
<div class="tab-content" id="nav-tabContent">
</div>
</div>
</div>
<br>
<br>

<!-- importing bootstrap.js and supporting js libraries -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>

<!-- importing app scripts | load order is important -->
<script type="text/javascript" src="./authConfig.js"></script>
<script type="text/javascript" src="./ui.js"></script>
<script type="text/javascript" src="./auth.js"></script>
</body>
</html>
Loading