Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions library.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
const url = require('url');
const uid = require('uid2');
const async = require('async');
const request = require('request-promise');
const axios = require('axios');
const CustomStrategy = require('passport-custom');

const passport = module.parent.require('passport');
Expand Down Expand Up @@ -208,39 +208,38 @@


Oidc.getAccessTokenFromCode = async function (settings, code) {
const options = {
method: 'POST',
url: settings.tokenEndpoint,
form: {
grant_type: 'authorization_code',
client_id: settings.clientId,
client_secret: settings.clientSecret,
code: code,
redirect_uri: settings.callbackURL
const formData = new URLSearchParams({
grant_type: 'authorization_code',
client_id: settings.clientId,
client_secret: settings.clientSecret,
code: code,
redirect_uri: settings.callbackURL
});

const response = await axios.post(settings.tokenEndpoint, formData, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}
return request(options);
});

return JSON.stringify(response.data);
};

Oidc.getAccessTokenFromId = async function (settings, id) {
const tokenUrl = new URL(settings.ssoTokenEndpoint);
tokenUrl.searchParams.append("id", id);
const options = {
method: 'GET',
url: tokenUrl.href
}
return request(options);

const response = await axios.get(tokenUrl.href);
return JSON.stringify(response.data);
};

Oidc.getUserInfo = async function (settings, accessToken) {
const options = {
method: 'GET',
url: settings.userInfoEndpoint,
const response = await axios.get(settings.userInfoEndpoint, {
headers: {
'Authorization': 'Bearer ' + accessToken
}
}
return request(options);
});
return JSON.stringify(response.data);
};

/**
Expand Down
26 changes: 12 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nodebb-plugin-sunbird-oidc",
"version": "1.0.17",
"version": "8.2.0",
"description": "Authenticate to Sunbird identity provider.",
"main": "library.js",
"repository": {
Expand All @@ -21,30 +21,28 @@
"license": "BSD-2-Clause",
"readmeFilename": "README.md",
"dependencies": {
"async": "^2",
"fs": "0.0.1-security",
"async": "^3.2.0",
"axios": "^1.7.0",
"lodash": "^4.17.20",
"mongoose": "^5.11.9",
"mongoose": "^8.0.0",
"passport-custom": "^1.1.1",
"request": "2.81.0",
"request-promise": "^4.2.6",
"uid2": "0.0.x"
},
"nbbpm": {
"compatibility": "^1.0.1"
"compatibility": "^4.0.0"
},
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-angular": "^8.3.4",
"@commitlint/cli": "^18.0.0",
"@commitlint/config-angular": "^18.0.0",
"@types/async": "^3.0.8",
"@types/express": "^4.17.3",
"@types/passport-oauth2": "^1.4.8",
"eslint": "^6.8.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.1",
"husky": "^4.2.3",
"lint-staged": "^10.0.8",
"typescript": "^3.8.3"
"husky": "^8.0.3",
"lint-staged": "^15.0.0",
"typescript": "^5.3.0"
},
"husky": {
"hooks": {}
Expand All @@ -56,4 +54,4 @@
]
},
"scripts": {}
}
}
3 changes: 1 addition & 2 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"id": "nodebb-plugin-sunbird-oidc",
"name": "Sunbird SSO Plugin for NodeBB",
"description": "Authenticate to Sunbird identity provider.",
"url": "https://github.com/vrayulu/nodebb-plugin-sunbird-oidc",
"library": "./library.js",
"url": "https://github.com/Sunbird-Lern/nodebb-plugin-sunbird-oidc",
"templates": "templates",
"hooks": [
{
Expand Down