mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-25 22:19:28 -04:00
Merge branch 'fix/apple-auth-breaks-dev' into 'main'
Disable Apple authentication if required environment variables are not provided See merge request PronounsPage/PronounsPage!344
This commit is contained in:
commit
5097e6c7a1
@ -17,7 +17,35 @@ const getAppleClientSecret = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.config = {
|
function appleIsEnabled() {
|
||||||
|
const conditions = [
|
||||||
|
"APPLE_CLIENT_ID",
|
||||||
|
"APPLE_TEAM_ID",
|
||||||
|
"APPLE_KEY_ID",
|
||||||
|
"APPLE_PRIVATE_KEY"
|
||||||
|
];
|
||||||
|
let unavailable = [];
|
||||||
|
for (const condition of conditions) {
|
||||||
|
const value = process.env[condition];
|
||||||
|
// Checks if the value is not a string or empty
|
||||||
|
if (typeof value !== "string" || value.length < 1 || value.trim().length < 1) {
|
||||||
|
unavailable.push(condition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (unavailable.length === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (unavailable.length === conditions.length) {
|
||||||
|
console.log("Apple authentication is disabled - provide the APPLE_CLIENT_ID, APPLE_TEAM_ID, and APPLE_PRIVATE_KEY to enable these");
|
||||||
|
} else {
|
||||||
|
console.warn(`Apple authentication is disabled because all required environment values were not provided (missing: ${unavailable.join(', ')})`);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const enableApple = appleIsEnabled();
|
||||||
|
|
||||||
|
const config = {
|
||||||
defaults: {
|
defaults: {
|
||||||
origin: process.env.BASE_URL,
|
origin: process.env.BASE_URL,
|
||||||
transport: 'session',
|
transport: 'session',
|
||||||
@ -49,7 +77,13 @@ module.exports.config = {
|
|||||||
callback: '/api/user/social/discord',
|
callback: '/api/user/social/discord',
|
||||||
scope: ['identify', 'email'],
|
scope: ['identify', 'email'],
|
||||||
},
|
},
|
||||||
apple: {
|
// non-grant, but things break if it's not there
|
||||||
|
mastodon: {},
|
||||||
|
indieauth: {},
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enableApple) {
|
||||||
|
config.apple = {
|
||||||
key: process.env.APPLE_CLIENT_ID,
|
key: process.env.APPLE_CLIENT_ID,
|
||||||
secret: getAppleClientSecret(),
|
secret: getAppleClientSecret(),
|
||||||
|
|
||||||
@ -61,12 +95,11 @@ module.exports.config = {
|
|||||||
response_type: 'code id_token',
|
response_type: 'code id_token',
|
||||||
response_mode: 'form_post',
|
response_mode: 'form_post',
|
||||||
},
|
},
|
||||||
},
|
}
|
||||||
// non-grant, but things break if it's not there
|
|
||||||
mastodon: {},
|
|
||||||
indieauth: {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.config = config;
|
||||||
|
|
||||||
module.exports.handlers = {
|
module.exports.handlers = {
|
||||||
twitter(r) {
|
twitter(r) {
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user