Merge pull request #19741 from strapi/feat/keycloak-grant

feat: Add keycloak native users-permissions provider
This commit is contained in:
DMehaffy 2024-03-15 06:17:59 -07:00 committed by GitHub
commit 3cc05002fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View File

@ -128,4 +128,13 @@ module.exports = (baseURL) => ({
callback: `${baseURL}/patreon/callback`,
scope: ['identity', 'identity[email]'],
},
keycloak: {
enabled: false,
icon: '',
key: '',
secret: '',
subdomain: 'myKeycloakProvider.com/realms/myrealm',
callback: `${baseURL}/keycloak/callback`,
scope: ['openid', 'email', 'profile'],
},
});

View File

@ -331,6 +331,21 @@ const getInitialProviders = ({ purest }) => ({
};
});
},
async keycloak({ accessToken, providers }) {
const keycloak = purest({ provider: 'keycloak' });
return keycloak
.subdomain(providers.keycloak.subdomain)
.get('protocol/openid-connect/userinfo')
.auth(accessToken)
.request()
.then(({ body }) => {
return {
username: body.preferred_username,
email: body.email,
};
});
},
});
module.exports = () => {