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
@@ -43,13 +37,13 @@ BearerStrategy uses Bearer Token protocol to protect web resource/api. It works
43
37
User sends a request to the protected web api which contains an access_token in either the authorization header or body. Passport extracts and validates the access_token, and propagates the claims in access_token to the verify callback and let the framework finish the remaining authentication procedure. On successful authentication, passport adds the user information to `req.user` and passes it to the next middleware, which is usually the business logic of the web resource/api. In case of error, passport sends back an unauthorized response.
44
38
45
39
46
-
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.
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://aka.ms/appregistrations. 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:
401
395
@@ -416,11 +410,11 @@ Passport framework uses session to keep a persistent login session. As a plug in
416
410
417
411
```
418
412
419
-
### 5.2 BearerStrategy
413
+
### 4.2 BearerStrategy
420
414
421
-
#### 5.2.1 Configure strategy and provide callback function
415
+
#### 4.2.1 Configure strategy and provide callback function
422
416
423
-
##### 5.2.1.1 Sample using the BearerStrategy
417
+
##### 4.2.1.1 Sample using the BearerStrategy
424
418
425
419
```javascript
426
420
@@ -464,7 +458,7 @@ var bearerStrategy = new BearerStrategy(options,
464
458
);
465
459
```
466
460
467
-
##### 5.2.1.2 Options
461
+
##### 4.2.1.2 Options
468
462
469
463
*`identityMetadata` (Required)
470
464
@@ -543,7 +537,7 @@ var bearerStrategy = new BearerStrategy(options,
543
537
544
538
This value is the proxy settings object: { port: 'proxyport', host: 'proxyhost', protocol: 'http' }
545
539
546
-
##### 5.2.1.3 Verify callback
540
+
##### 4.2.1.3 Verify callback
547
541
548
542
If you set `passReqToCallback` option to false, you can use the following verify callback
549
543
@@ -557,15 +551,15 @@ If you set `passReqToCallback` option to true, you can use the following verify
557
551
function(req, token, done)
558
552
```
559
553
560
-
#### 5.2.2 Use `passport.authenticate` to protect resources or APIs
554
+
#### 4.2.2 Use `passport.authenticate` to protect resources or APIs
561
555
562
556
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:
583
577
584
578
```
585
579
$ npm install
586
580
```
587
581
588
-
### 6.1. Run all tests except the end to end tests
582
+
### 5.1. Run all tests except the end to end tests
589
583
590
584
Type the following command to run tests:
591
585
592
586
```
593
587
$ npm test
594
588
```
595
589
596
-
### 6.2. Run all tests including the end to end tests
590
+
### 5.2. Run all tests including the end to end tests
597
591
598
-
#### 6.2.1. Create test applications
592
+
#### 5.2.1. Create test applications
599
593
600
594
First you need to register one application in v1 tenant, one in v2 tenant and one in B2C tenant.
601
595
@@ -621,13 +615,13 @@ access token for the scope, and use BearerStrategy to validate the scope. Note f
621
615
`b2c_params.scopeForOIDC` but only the name in `b2c_params.scopeForBearer`. For example,
622
616
`b2c_params.scopeForOIDC=['https://sijun1b2c.onmicrosoft.com/oidc-b2c/read']` and `b2c_params.scopeForBearer=['read']`.
623
617
624
-
#### 6.2.2. Fill the test parameters
618
+
#### 5.2.2. Fill the test parameters
625
619
626
620
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.
627
621
628
622
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.
629
623
630
-
#### 6.2.3. Run the tests
624
+
#### 5.2.3. Run the tests
631
625
632
626
Type the following commands to run the tests:
633
627
@@ -640,7 +634,7 @@ Type the following commands to run the tests:
640
634
641
635
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).
642
636
643
-
## 7. Logging
637
+
## 6. Logging
644
638
#### Personal Identifiable Information (PII) & Organizational Identifiable Information (OII)
645
639
646
640
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.
@@ -662,7 +656,7 @@ var options = {
662
656
```
663
657
664
658
665
-
## 8. Samples and Documentation
659
+
## 7. Samples and Documentation
666
660
667
661
[We provide a full suite of sample applications and documentation on GitHub](https://azure.microsoft.com/en-us/documentation/samples/?service=active-directory)
668
662
to help you get started with learning the Azure Identity system. This includes
@@ -672,50 +666,50 @@ OAuth2, OpenID Connect, Graph API, and other awesome features.
672
666
673
667
Azure Identity samples for this plug-in can be found in the following links:
674
668
675
-
### 8.1 Samples for [OpenID connect strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/oidcstrategy.js)
669
+
### 7.1 Samples for [OpenID connect strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/oidcstrategy.js)
676
670
677
671
*[sample using v1 endpoint](https://github.com/AzureADQuickStarts/WebApp-OpenIDConnect-NodeJS)
678
672
679
673
*[sample using v2 endpoint](https://github.com/AzureADQuickStarts/AppModelv2-WebApp-OpenIDConnect-nodejs)
680
674
681
675
*[sample using B2C tenant](https://github.com/AzureADQuickStarts/B2C-WebApp-OpenIDConnect-NodeJS)
682
676
683
-
### 8.2 Samples for [Bearer strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/bearerstrategy.js)
677
+
### 7.2 Samples for [Bearer strategy](https://github.com/AzureAD/passport-azure-ad/blob/master/lib/bearerstrategy.js)
684
678
685
679
*[sample using v1 endpoint](https://github.com/AzureADQuickStarts/WebAPI-Bearer-NodeJS)
686
680
687
681
*[sample using v2 endpoint](https://github.com/AzureADQuickStarts/AppModelv2-WebAPI-nodejs)
688
682
689
683
*[sample using B2C tenant](https://github.com/AzureADQuickStarts/B2C-WebApi-Nodejs)
690
684
691
-
## 9. Community Help and Support
685
+
## 8. Community Help and Support
692
686
693
687
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.
694
688
695
689
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)
696
690
697
-
## 10. Security Reporting
691
+
## 9. Security Reporting
698
692
699
693
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.
700
694
701
-
## 11. Contributing
695
+
## 10. Contributing
702
696
703
697
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.
704
698
705
699
More details [about contribution](https://github.com/AzureAD/passport-azure-ad/blob/master/contributing.md)
706
700
707
-
## 12. Releases
701
+
## 11. Releases
708
702
709
703
Please check the [releases](https://github.com/AzureAD/passport-azure-ad/releases) for updates.
710
704
711
-
## 13. Acknowledgements
705
+
## 12. Acknowledgements
712
706
713
707
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).
714
708
715
-
## 14. License
709
+
## 13. License
716
710
Copyright (c) Microsoft Corp. All rights reserved. Licensed under the MIT License;
717
711
718
-
## 15. Microsoft Open Source Code of Conduct
712
+
## 14. Microsoft Open Source Code of Conduct
719
713
720
714
We Value and Adhere to the Microsoft Open Source Code of Conduct
0 commit comments