Merge pull request #1613 from synth3tk/auth-microsoft

Add Microsoft Graph auth provider
This commit is contained in:
Jim LAURIE 2018-08-09 17:10:08 +02:00 committed by GitHub
commit eada18a619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

View File

@ -51,6 +51,8 @@ class PopUpForm extends React.Component { // eslint-disable-line react/prefer-st
return `${strapi.backendURL}/connect/google/callback`;
case 'github':
return get(this.props.values, 'redirect_uri', '');
case 'microsoft':
return `${strapi.backendURL}/connect/microsoft/callback`;
default: {
const value = get(this.props.values, 'callback', '');

View File

@ -168,6 +168,7 @@
"PopUpForm.Providers.facebook.providerConfig.redirectURL": "The redirect URL to add in your Facebook application configurations",
"PopUpForm.Providers.google.providerConfig.redirectURL": "The redirect URL to add in your Google application configurations",
"PopUpForm.Providers.github.providerConfig.redirectURL": "The redirect URL to add in your GitHub application configurations",
"PopUpForm.Providers.microsoft.providerConfig.redirectURL": "The redirect URL to add in your Microsoft application configurations",
"PopUpForm.Providers.linkedin2.providerConfig.redirectURL": "The redirect URL to add in your Linkedin application configurations",
"PopUpForm.Providers.twitter.providerConfig.redirectURL": "The redirect URL to add in your Twitter application configurations",

View File

@ -77,6 +77,14 @@ module.exports = async cb => {
'user:email'
]
},
microsoft: {
enabled: false,
icon: 'windows',
key: '',
secret: '',
callback: '/auth/microsoft/callback',
scope: ['user.read']
},
twitter: {
enabled: false,
icon: 'twitter',

View File

@ -208,6 +208,40 @@ const getProfile = async (provider, query, callback) => {
});
break;
}
case 'microsoft': {
const microsoft = new Purest({
provider: 'microsoft',
config:{
'microsoft': {
'https://graph.microsoft.com': {
'__domain': {
'auth': {
'auth': {'bearer': '[0]'}
}
},
'[version]/{endpoint}': {
'__path': {
'alias': '__default',
'version': 'v1.0'
}
}
}
}
}
});
microsoft.query().get('me').auth(access_token).request((err, res, body) => {
if (err) {
callback(err);
} else {
callback(null, {
username: body.userPrincipalName,
email: body.userPrincipalName
});
}
});
break;
}
case 'twitter': {
const twitter = new Purest({
provider: 'twitter',