You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2023. It is now read-only.
This library contains two strategies: OIDCStrategy and BearerStrategy.
38
32
@@ -45,11 +39,11 @@ User sends a request to the protected web api which contains an access_token in
45
39
46
40
We support AAD v1, v2 and B2C tenants for both strategies. Please check out [section 8](#8-samples-and-documentation) for the samples. You can manage v1 tenants and register applications at https://manage.windowsazure.com. For v2 tenants and applications, you should go to https://apps.dev.microsoft.com. For B2C tenants, go to https://manage.windowsazure.com and click 'Manage B2C settings' to register applications and policies.
47
41
48
-
### 5.1 OIDCStrategy
42
+
### 4.1 OIDCStrategy
49
43
50
-
#### 5.1.1 Configure strategy and provide callback function
44
+
#### 4.1.1 Configure strategy and provide callback function
Passport framework uses session to keep a persistent login session. As a plug in, we also use session to store state and nonce by default, regardless whether you use { session: false } option in passport.authenticate or not. To be completely session free, you must configure passport-azure-ad to create state/nonce cookie instead of saving them in session. Please follow the following example:
400
394
@@ -415,11 +409,11 @@ Passport framework uses session to keep a persistent login session. As a plug in
415
409
416
410
```
417
411
418
-
### 5.2 BearerStrategy
412
+
### 4.2 BearerStrategy
419
413
420
-
#### 5.2.1 Configure strategy and provide callback function
414
+
#### 4.2.1 Configure strategy and provide callback function
421
415
422
-
##### 5.2.1.1 Sample using the BearerStrategy
416
+
##### 4.2.1.1 Sample using the BearerStrategy
423
417
424
418
```javascript
425
419
@@ -463,7 +457,7 @@ var bearerStrategy = new BearerStrategy(options,
463
457
);
464
458
```
465
459
466
-
##### 5.2.1.2 Options
460
+
##### 4.2.1.2 Options
467
461
468
462
*`identityMetadata` (Required)
469
463
@@ -538,7 +532,7 @@ var bearerStrategy = new BearerStrategy(options,
538
532
539
533
This value is the clock skew (in seconds) allowed in token validation. It must be a positive integer. The default value is 300 seconds.
540
534
541
-
##### 5.2.1.3 Verify callback
535
+
##### 4.2.1.3 Verify callback
542
536
543
537
If you set `passReqToCallback` option to false, you can use the following verify callback
544
538
@@ -552,15 +546,15 @@ If you set `passReqToCallback` option to true, you can use the following verify
552
546
function(req, token, done)
553
547
```
554
548
555
-
#### 5.2.2 Use `passport.authenticate` to protect resources or APIs
549
+
#### 4.2.2 Use `passport.authenticate` to protect resources or APIs
556
550
557
551
In the following example, we are using passport to protect '/api/tasks'. User sends a GET request to '/api/tasks' with access_token in authorization header or body. Passport validates the access_token, adds the related claims from access_token to `req.user`, and passes the request to listTasks middleware. The listTasks middleware can then read the user information in `req.user` and list all the tasks related to this user. Note that we do authentication every time, so we don't need to keep this user in session, and this can be achieved by using `session: false` option.
In the library root folder, type the following command to install the dependency packages:
578
572
579
573
```
580
574
$ npm install
581
575
```
582
576
583
-
### 6.1. Run all tests except the end to end tests
577
+
### 5.1. Run all tests except the end to end tests
584
578
585
579
Type the following command to run tests:
586
580
587
581
```
588
582
$ npm test
589
583
```
590
584
591
-
### 6.2. Run all tests including the end to end tests
585
+
### 5.2. Run all tests including the end to end tests
592
586
593
-
#### 6.2.1. Create test applications
587
+
#### 5.2.1. Create test applications
594
588
595
589
First you need to register one application in v1 tenant, one in v2 tenant and one in B2C tenant.
596
590
@@ -616,13 +610,13 @@ access token for the scope, and use BearerStrategy to validate the scope. Note f
616
610
`b2c_params.scopeForOIDC` but only the name in `b2c_params.scopeForBearer`. For example,
617
611
`b2c_params.scopeForOIDC=['https://sijun1b2c.onmicrosoft.com/oidc-b2c/read']` and `b2c_params.scopeForBearer=['read']`.
618
612
619
-
#### 6.2.2. Fill the test parameters
613
+
#### 5.2.2. Fill the test parameters
620
614
621
615
Open `test/End_to_end_test/script.js`, set `is_test_parameters_completed` parameter to true. For `test_parameters` variable, fill in the tenant id/client id/client secret of your applications, and the username/password of your application user.
622
616
623
617
For `thumbprint` and `privatePEMKey` parameters, you need to specify a certificate for your app and register the public key in Azure Active Directory. `thumbprint` is the base64url format of the thumbprint of the public key, and `privatePEMKey` is the private pem key string. For a v1 tenant, you can follow [this post](http://www.andrewconnell.com/blog/user-app-app-only-permissions-client-credentials-grant-flow-in-azure-ad-office-365-apis) to generate a certificate and register the public key. For a v2 tenant, you can go to your application page in the [v2 portal](https://apps.dev.microsoft.com) and click `Generate New Key Pair`. A certificate will be generated for you to download. The corresponding public key is automatically registered in this case.
624
618
625
-
#### 6.2.3. Run the tests
619
+
#### 5.2.3. Run the tests
626
620
627
621
Type the following commands to run the tests:
628
622
@@ -635,7 +629,7 @@ Type the following commands to run the tests:
635
629
636
630
Tests will run automatically and in the terminal you can see how many tests are passing/failing. More details can be found [here](https://github.com/AzureAD/passport-azure-ad/blob/master/contributing.md).
637
631
638
-
## 7. Logging
632
+
## 6. Logging
639
633
#### Personal Identifiable Information (PII) & Organizational Identifiable Information (OII)
640
634
641
635
By default, passport-azure-ad logging does not capture or log any PII or OII. The library allows app developers to turn this on by configuring `loggingNoPII` in the config options. By turning on PII or OII, the app takes responsibility for safely handling highly-sensitive data and complying with any regulatory requirements.
@@ -657,7 +651,7 @@ var options = {
657
651
```
658
652
659
653
660
-
## 8. Samples and Documentation
654
+
## 7. Samples and Documentation
661
655
662
656
[We provide a full suite of sample applications and documentation on GitHub](https://azure.microsoft.com/en-us/documentation/samples/?service=active-directory)
663
657
to help you get started with learning the Azure Identity system. This includes
@@ -667,50 +661,50 @@ OAuth2, OpenID Connect, Graph API, and other awesome features.
667
661
668
662
Azure Identity samples for this plug-in can be found in the following links:
669
663
670
-
### 8.1 Samples for [OpenID connect strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/oidcstrategy.js)
664
+
### 7.1 Samples for [OpenID connect strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/oidcstrategy.js)
671
665
672
666
*[sample using v1 endpoint](https://github.com/AzureADQuickStarts/WebApp-OpenIDConnect-NodeJS)
673
667
674
668
*[sample using v2 endpoint](https://github.com/AzureADQuickStarts/AppModelv2-WebApp-OpenIDConnect-nodejs)
675
669
676
670
*[sample using B2C tenant](https://github.com/AzureADQuickStarts/B2C-WebApp-OpenIDConnect-NodeJS)
677
671
678
-
### 8.2 Samples for [Bearer strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/bearerstrategy.js)
672
+
### 7.2 Samples for [Bearer strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/bearerstrategy.js)
679
673
680
674
*[sample using v1 endpoint](https://github.com/AzureADQuickStarts/WebAPI-Bearer-NodeJS)
681
675
682
676
*[sample using v2 endpoint](https://github.com/AzureADQuickStarts/AppModelv2-WebAPI-nodejs)
683
677
684
678
*[sample using B2C tenant](https://github.com/AzureADQuickStarts/B2C-WebApi-Nodejs)
685
679
686
-
## 9. Community Help and Support
680
+
## 8. Community Help and Support
687
681
688
682
We leverage [Stack Overflow](http://stackoverflow.com/) to work with the community on supporting Azure Active Directory and its SDKs, including this one. We highly recommend you ask your questions on Stack Overflow (we're all on there!) Also browser existing issues to see if someone has had your question before.
689
683
690
684
We recommend you use the "msal" tag so we can see it! Here is the latest Q&A on Stack Overflow for MSAL: [http://stackoverflow.com/questions/tagged/msal](http://stackoverflow.com/questions/tagged/msal)
691
685
692
-
## 10. Security Reporting
686
+
## 9. Security Reporting
693
687
694
688
If you find a security issue with our libraries or services please report it to [secure@microsoft.com](mailto:secure@microsoft.com) with as much detail as possible. Your submission may be eligible for a bounty through the [Microsoft Bounty](http://aka.ms/bugbounty) program. Please do not post security issues to GitHub Issues or any other public site. We will contact you shortly upon receiving the information. We encourage you to get notifications of when security incidents occur by visiting [this page](https://technet.microsoft.com/en-us/security/dd252948) and subscribing to Security Advisory Alerts.
695
689
696
-
## 11. Contributing
690
+
## 10. Contributing
697
691
698
692
All code is licensed under the MIT license and we triage actively on GitHub. We enthusiastically welcome contributions and feedback. You can clone the repo and start contributing now.
699
693
700
694
More details [about contribution](https://github.com/AzureAD/passport-azure-ad/blob/master/contributing.md)
701
695
702
-
## 12. Releases
696
+
## 11. Releases
703
697
704
698
Please check the [releases](https://github.com/AzureAD/passport-azure-ad/releases) for updates.
705
699
706
-
## 13. Acknowledgements
700
+
## 12. Acknowledgements
707
701
708
702
The code is based on Henri Bergius's [passport-saml](https://github.com/bergie/passport-saml) library and Matias Woloski's [passport-wsfed-saml2](https://github.com/auth0/passport-wsfed-saml2) library as well as Kiyofumi Kondoh's [passport-openid-google](https://github.com/kkkon/passport-google-openidconnect).
709
703
710
-
## 14. License
704
+
## 13. License
711
705
Copyright (c) Microsoft Corp. All rights reserved. Licensed under the MIT License;
712
706
713
-
## 15. Microsoft Open Source Code of Conduct
707
+
## 14. Microsoft Open Source Code of Conduct
714
708
715
709
We Value and Adhere to the Microsoft Open Source Code of Conduct
0 commit comments