-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Createing a custom Auth Provider Module for azure (SSO) #10860
Comments
Hi, would you be able to provide a reproduction repository with a minimal implementation please? |
kindly go through the below attached file, I have attached my project zip file |
do you have any other logs with any warning or error during the loading process by any chance? |
I was more asking for the log when you start your application, in case there is a hidden warning of some sort, let me check on my side in a sec |
@adrien2p I understand what you're saying. Even if I comment out the Passport configuration, the provider works fine. Could you guide me on how to implement SSO for Azure in Medusa? I expect the Azure integration to work similarly to Google SSO. I'm using the Passport package for Azure integration. If I initialize it in the provider, I encounter an error. However, if I comment out the Passport initialization, the Azure provider is invoked correctly. Can you please guide me on what I need to do to resolve this issue? My project has SSO for Google as well as Azure. |
when you are initializing your passport strategy, do you see any errors in the terminal when starting the app? |
scenario 1 scenario 2 now @adrien2p Can you please guide me on what I need to do to resolve this issue? My project has SSO for Google as well as Azure |
No i didn't find any error I'm just initializing it in my azure provider only |
Ok I found out what is happening, currently, no matter the error happening it will tell you that the provider is not registered. That is because of two things
Let me fix that already and that way you will have the proper error to help you fix the issue with your passport strategy |
This pr will help you find out why your passport strategy is not working #10900 try {
this.passport.use(
new OIDCStrategy(
{
clientID: options.clientID,
clientSecret: options.clientSecret,
identityMetadata: `https://login.microsoftonline.com/${options.tenantID}/.well-known/openid-configuration`,
redirectUrl: options.callbackUrl,
responseType: "code id_token",
responseMode: "form_post",
scope: ["openid", "profile", "email"],
passReqToCallback: false,
},
(issuer, sub, profile, accessToken, refreshToken, done) => {
// Ensure that all necessary data is provided and sanitized
const authIdentity = {
// provider: this.provider,
entity_id: profile._json.upn, // Example: using the user's UPN (email)
provider_metadata: profile,
user_metadata: {
name: profile.displayName,
email: profile._json.upn,
},
};
// Done callback should return the authIdentity
return done(null, authIdentity);
}
)
);
} catch (e) {
this.logger_.error(e)
throw e
} |
Package.json file
Node.js version
v22.11.0
Database and its version
16.2
Operating system name and version
windows
Browser name
No response
What happended?
I have added the custom AUTH for Azure. I have added an identifier as azure
class AzureAuthProviderService extends AbstractAuthModuleProvider {
static identifier = "azure"; // Correct provider identifier
protected logger_: Logger;
protected options_: Options;
protected passport;
this is my config
{
resolve: "@medusajs/medusa/auth", // Medusa's authentication module
options: {
providers: [
{
resolve: "./src/modules/azure", // Path to your custom Azure auth provider
id: "azure",
options: {
clientId: process.env.AZURE_CLIENT_ID,
clientSecret: process.env.AZURE_CLIENT_SECRET,
tenantId: process.env.AZURE_TENANT_ID,
Expected behavior
provided url to login with azure (microsoft)
Actual behavior
getting error
{
"type": "unauthorized",
"message": "\n Unable to retrieve the auth provider with id: azure\n Please make sure that the provider is registered in the container and it is configured correctly in your project configuration file.\n "
}
Link to reproduction repo
The text was updated successfully, but these errors were encountered: