mirror of
https://github.com/plankanban/planka.git
synced 2025-08-09 15:35:29 +02:00
- added the ability to skip user info
- added error handling if values are missing.
This commit is contained in:
parent
b60f3fe463
commit
b0e73700d6
2 changed files with 17 additions and 1 deletions
|
@ -5,7 +5,11 @@ const { getRemoteAddress } = require('../../../utils/remoteAddress');
|
||||||
|
|
||||||
const Errors = {
|
const Errors = {
|
||||||
INVALID_TOKEN: {
|
INVALID_TOKEN: {
|
||||||
invalidToken: 'Invalid email or username',
|
invalidToken: 'Access Token is invalid',
|
||||||
|
},
|
||||||
|
MISSING_VALUES: {
|
||||||
|
missingValues:
|
||||||
|
'Unable to retrieve required values. Verify the access token or UserInfo endpoint has email, username and name claims',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,6 +58,9 @@ const validateAndDecodeToken = async (accessToken, options) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserInfo = async (accessToken, options) => {
|
const getUserInfo = async (accessToken, options) => {
|
||||||
|
if (sails.config.custom.oidcSkipUserInfo) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
const issuer = await openidClient.Issuer.discover(options.issuer);
|
const issuer = await openidClient.Issuer.discover(options.issuer);
|
||||||
const oidcClient = new issuer.Client({
|
const oidcClient = new issuer.Client({
|
||||||
client_id: 'irrelevant',
|
client_id: 'irrelevant',
|
||||||
|
@ -88,6 +95,9 @@ module.exports = {
|
||||||
invalidToken: {
|
invalidToken: {
|
||||||
responseType: 'unauthorized',
|
responseType: 'unauthorized',
|
||||||
},
|
},
|
||||||
|
missingValues: {
|
||||||
|
responseType: 'unauthorized',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
async fn(inputs) {
|
async fn(inputs) {
|
||||||
|
@ -115,6 +125,11 @@ module.exports = {
|
||||||
locked: true,
|
locked: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (!newUser.email || !newUser.username || !newUser.name) {
|
||||||
|
sails.log.error(Errors.MISSING_VALUES.missingValues);
|
||||||
|
throw Errors.MISSING_VALUES;
|
||||||
|
}
|
||||||
|
|
||||||
const identityProviderUser = await IdentityProviderUser.findOne({
|
const identityProviderUser = await IdentityProviderUser.findOne({
|
||||||
where: {
|
where: {
|
||||||
issuer: oidcUser.iss,
|
issuer: oidcUser.iss,
|
||||||
|
|
|
@ -39,4 +39,5 @@ module.exports.custom = {
|
||||||
oidcredirectUri: process.env.OIDC_REDIRECT_URI,
|
oidcredirectUri: process.env.OIDC_REDIRECT_URI,
|
||||||
oidcJwksUri: process.env.OIDC_JWKS_URI,
|
oidcJwksUri: process.env.OIDC_JWKS_URI,
|
||||||
oidcScopes: process.env.OIDC_SCOPES || 'openid profile email',
|
oidcScopes: process.env.OIDC_SCOPES || 'openid profile email',
|
||||||
|
oidcSkipUserInfo: process.env.OIDC_SKIP_USER_INFO === 'true',
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue