question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Azure AD authentication

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Expected behavior

Validate jwt token using Azure AD.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Nest version: X.Y.Z

 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
aramalipoorcommented, Jun 21, 2020

@kamilmysliwiec looks like because of this block and they way NestJS Passport wrapper works passport-azure-ad cannot populate proper arguments to the “verify” (aka “validate”) method. Because “arity” or number of verify function arguments will be calculated as 0 😦 in here: https://github.com/AzureAD/passport-azure-ad/blob/96c7a193737f03a270b4eb0d99ce2d59256da9a9/lib/oidcstrategy.js#L109

import { Injectable } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { OIDCStrategy } from 'passport-azure-ad';

import { configService } from '../config/config.service';
import { ProfileProvider } from '../user/user.types';
import { AuthService } from './auth.service';

@Injectable()
export class AzureAdStrategy extends PassportStrategy(
  OIDCStrategy,
  'azure-ad',
) {
  constructor(private readonly authService: AuthService) {
    super(configService.getAzureAdConfig());
  }

  async validate(iss, sub, profile, accessToken, refreshToken, done: Function) {
    try {
      const jwt: string = await this.authService.handleOAuthLogin(
        accessToken,
        refreshToken,
        profile.id,
        ProfileProvider.AZURE_AD,
      );

      done(null, {
        jwt,
      });
    } catch (err) {
      console.log('Azure AD Strategy failure', err);
      done(err, false);
    }
  }
}

Using above class first argument is either request (if passReqToCallback: true) or profile object and last argument is “done” function.

Not “profile” nor “request” contain the accessToken or refreshToken 🤔

Is it possible to work-around this somehow? Like directly registering Azure-AD with passport as a quick fix for now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure services that support Azure AD authentication
List of services that support Azure AD authentication. ... Azure Databricks, Authenticate using Azure Active Directory tokens.
Read more >
Azure Active Directory authentication overview
Azure AD helps to protect a user's identity and simplify their sign-in experience. Features like self-service password reset let users update or ...
Read more >
Authentication methods and features - Azure Active Directory
Azure AD Multi-Factor Authentication (MFA) adds additional security over only using a password when a user signs in. The user can be prompted ......
Read more >
Native Azure Active Directory authentication support and ...
Native Azure AD authentication support enables user-based policies, conditional access, and multi-factor authentication (MFA) for P2S VPN.
Read more >
Configure Azure AD authentication - App Service
Enable Azure Active Directory in your App Service app · Sign in to the Azure portal and navigate to your app. · Select...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found