strapi-custom-auth 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server/index.js +10 -0
- package/dist/server/index.mjs +10 -0
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -3275,6 +3275,7 @@ async function microsoftSignIn(ctx) {
|
|
|
3275
3275
|
const endpoint = OAUTH_ENDPOINT(config2["ENTRA_OAUTH_TENANT_ID"]);
|
|
3276
3276
|
const url = `${endpoint}?client_id=${config2["ENTRA_OAUTH_CLIENT_ID"]}&response_type=${OAUTH_RESPONSE_TYPE}&redirect_uri=${redirectUri}&response_mode=${OAUTH_RESPONSE_MODE}&scope=${OAUTH_SCOPE}`;
|
|
3277
3277
|
ctx.set("Location", url);
|
|
3278
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign In URL:", url);
|
|
3278
3279
|
return ctx.send({}, 302);
|
|
3279
3280
|
}
|
|
3280
3281
|
async function microsoftSignInCallback(ctx) {
|
|
@@ -3283,6 +3284,7 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3283
3284
|
const tokenService = strapi.service("admin::token");
|
|
3284
3285
|
const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
|
|
3285
3286
|
const roleService = strapi.plugin("strapi-custom-auth").service("role");
|
|
3287
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback query code:", ctx?.query?.code);
|
|
3286
3288
|
if (!ctx.query.code) {
|
|
3287
3289
|
return ctx.send(oauthService.renderSignUpError(`code Not Found`));
|
|
3288
3290
|
}
|
|
@@ -3302,11 +3304,13 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3302
3304
|
}
|
|
3303
3305
|
}
|
|
3304
3306
|
);
|
|
3307
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback TOKEN RESPONSE", tokenResponse?.data.access_token);
|
|
3305
3308
|
const userResponse = await axios.get("https://graph.microsoft.com/v1.0/me", {
|
|
3306
3309
|
headers: {
|
|
3307
3310
|
Authorization: `Bearer ${tokenResponse?.data.access_token}`
|
|
3308
3311
|
}
|
|
3309
3312
|
});
|
|
3313
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback USER RESPONSE", userResponse?.data);
|
|
3310
3314
|
const groupResponse = await axios.get(`https://graph.microsoft.com/v1.0/me/memberOf`, {
|
|
3311
3315
|
headers: {
|
|
3312
3316
|
Authorization: `Bearer ${tokenResponse?.data.access_token}`
|
|
@@ -3317,21 +3321,27 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3317
3321
|
const dbUser = await userService.findOneByEmail(mail);
|
|
3318
3322
|
let activateUser;
|
|
3319
3323
|
let jwtToken;
|
|
3324
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: check user existence");
|
|
3320
3325
|
if (dbUser) {
|
|
3326
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user exists generating token");
|
|
3321
3327
|
activateUser = dbUser;
|
|
3322
3328
|
jwtToken = await tokenService.createJwtToken(activateUser);
|
|
3323
3329
|
} else {
|
|
3330
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user does not exist, creating it");
|
|
3324
3331
|
const roles2 = await roleService.retrieveMicrosoftUserRole(groupsList, config2);
|
|
3325
3332
|
const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
|
|
3326
3333
|
activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
|
|
3334
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
|
|
3327
3335
|
jwtToken = await tokenService.createJwtToken(activateUser);
|
|
3328
3336
|
}
|
|
3329
3337
|
oauthService.triggerSignInSuccess(activateUser);
|
|
3330
3338
|
const nonce = v4();
|
|
3331
3339
|
const html = oauthService.renderSignUpSuccess(jwtToken, activateUser, nonce, tokenResponse.data?.refresh_token, "microsoft");
|
|
3332
3340
|
ctx.set("Content-Security-Policy", `script-src 'nonce-${nonce}'`);
|
|
3341
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: All went well, redirecting user");
|
|
3333
3342
|
return ctx.send(html);
|
|
3334
3343
|
} catch (e2) {
|
|
3344
|
+
console.log("[STRAPI-CUSTOM-AUTH-ERROR] Microsoft Sign Callback: ", e2);
|
|
3335
3345
|
console.error(e2.message);
|
|
3336
3346
|
return ctx.send(oauthService.renderSignUpError(e2.message));
|
|
3337
3347
|
}
|
package/dist/server/index.mjs
CHANGED
|
@@ -3260,6 +3260,7 @@ async function microsoftSignIn(ctx) {
|
|
|
3260
3260
|
const endpoint = OAUTH_ENDPOINT(config2["ENTRA_OAUTH_TENANT_ID"]);
|
|
3261
3261
|
const url = `${endpoint}?client_id=${config2["ENTRA_OAUTH_CLIENT_ID"]}&response_type=${OAUTH_RESPONSE_TYPE}&redirect_uri=${redirectUri}&response_mode=${OAUTH_RESPONSE_MODE}&scope=${OAUTH_SCOPE}`;
|
|
3262
3262
|
ctx.set("Location", url);
|
|
3263
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign In URL:", url);
|
|
3263
3264
|
return ctx.send({}, 302);
|
|
3264
3265
|
}
|
|
3265
3266
|
async function microsoftSignInCallback(ctx) {
|
|
@@ -3268,6 +3269,7 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3268
3269
|
const tokenService = strapi.service("admin::token");
|
|
3269
3270
|
const oauthService = strapi.plugin("strapi-custom-auth").service("oauth");
|
|
3270
3271
|
const roleService = strapi.plugin("strapi-custom-auth").service("role");
|
|
3272
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback query code:", ctx?.query?.code);
|
|
3271
3273
|
if (!ctx.query.code) {
|
|
3272
3274
|
return ctx.send(oauthService.renderSignUpError(`code Not Found`));
|
|
3273
3275
|
}
|
|
@@ -3287,11 +3289,13 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3287
3289
|
}
|
|
3288
3290
|
}
|
|
3289
3291
|
);
|
|
3292
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback TOKEN RESPONSE", tokenResponse?.data.access_token);
|
|
3290
3293
|
const userResponse = await axios.get("https://graph.microsoft.com/v1.0/me", {
|
|
3291
3294
|
headers: {
|
|
3292
3295
|
Authorization: `Bearer ${tokenResponse?.data.access_token}`
|
|
3293
3296
|
}
|
|
3294
3297
|
});
|
|
3298
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback USER RESPONSE", userResponse?.data);
|
|
3295
3299
|
const groupResponse = await axios.get(`https://graph.microsoft.com/v1.0/me/memberOf`, {
|
|
3296
3300
|
headers: {
|
|
3297
3301
|
Authorization: `Bearer ${tokenResponse?.data.access_token}`
|
|
@@ -3302,21 +3306,27 @@ async function microsoftSignInCallback(ctx) {
|
|
|
3302
3306
|
const dbUser = await userService.findOneByEmail(mail);
|
|
3303
3307
|
let activateUser;
|
|
3304
3308
|
let jwtToken;
|
|
3309
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: check user existence");
|
|
3305
3310
|
if (dbUser) {
|
|
3311
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user exists generating token");
|
|
3306
3312
|
activateUser = dbUser;
|
|
3307
3313
|
jwtToken = await tokenService.createJwtToken(activateUser);
|
|
3308
3314
|
} else {
|
|
3315
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user does not exist, creating it");
|
|
3309
3316
|
const roles2 = await roleService.retrieveMicrosoftUserRole(groupsList, config2);
|
|
3310
3317
|
const defaultLocale = oauthService.localeFindByHeader(ctx.request.headers);
|
|
3311
3318
|
activateUser = await oauthService.createUser(mail, surname, givenName, defaultLocale, roles2);
|
|
3319
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: user created, generating token");
|
|
3312
3320
|
jwtToken = await tokenService.createJwtToken(activateUser);
|
|
3313
3321
|
}
|
|
3314
3322
|
oauthService.triggerSignInSuccess(activateUser);
|
|
3315
3323
|
const nonce = v4();
|
|
3316
3324
|
const html = oauthService.renderSignUpSuccess(jwtToken, activateUser, nonce, tokenResponse.data?.refresh_token, "microsoft");
|
|
3317
3325
|
ctx.set("Content-Security-Policy", `script-src 'nonce-${nonce}'`);
|
|
3326
|
+
console.log("[STRAPI-CUSTOM-AUTH] Microsoft Sign Callback: All went well, redirecting user");
|
|
3318
3327
|
return ctx.send(html);
|
|
3319
3328
|
} catch (e2) {
|
|
3329
|
+
console.log("[STRAPI-CUSTOM-AUTH-ERROR] Microsoft Sign Callback: ", e2);
|
|
3320
3330
|
console.error(e2.message);
|
|
3321
3331
|
return ctx.send(oauthService.renderSignUpError(e2.message));
|
|
3322
3332
|
}
|
package/package.json
CHANGED