Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add role validation checks and portal settings pages #75

Merged
merged 47 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
9ad8de5
add settings route
SachiniSiriwardene Nov 21, 2024
31a0541
Merge branch 'release-1.0.0-m0' of https://github.com/wso2/api-develo…
SachiniSiriwardene Nov 21, 2024
713f890
Merge branch 'release-1.0.0-m0' of https://github.com/wso2/api-develo…
SachiniSiriwardene Nov 21, 2024
d25cf92
add settings page
SachiniSiriwardene Nov 22, 2024
3743e89
Merge branch 'release-1.0.0-m0' of https://github.com/wso2/api-develo…
SachiniSiriwardene Nov 23, 2024
6a0f39b
add IDP for devportal
SachiniSiriwardene Nov 25, 2024
03a9791
Merge branch 'release-1.0.0-m0' of https://github.com/wso2/api-develo…
SachiniSiriwardene Nov 25, 2024
2c8b7e5
remove logs
SachiniSiriwardene Nov 26, 2024
8bf9295
add ui for uploading org content
SachiniSiriwardene Dec 2, 2024
417eb96
add portal settings pages
SachiniSiriwardene Dec 3, 2024
d2aea9c
Merge branch 'release-1.0.0-m1' of https://github.com/wso2/api-develo…
SachiniSiriwardene Dec 4, 2024
dc82167
add changes to create org
SachiniSiriwardene Dec 6, 2024
8fd17ba
role validation
SachiniSiriwardene Dec 9, 2024
d606dc2
Merge branch 'release-1.0.0-m1' of https://github.com/wso2/api-develo…
SachiniSiriwardene Dec 9, 2024
70e9e58
reolve merge conflicts
SachiniSiriwardene Dec 9, 2024
6632be8
get access token from request
SachiniSiriwardene Dec 9, 2024
814104e
Merge branch 'release-1.0.0-m1' of https://github.com/wso2/api-develo…
SachiniSiriwardene Dec 9, 2024
dee8f96
send logged in user access token in api calls
SachiniSiriwardene Dec 10, 2024
1e31aa0
Merge branch 'release-1.0.0-m1' of https://github.com/wso2/api-develo…
SachiniSiriwardene Dec 10, 2024
b8432c8
resolve merge conflicts for application save
SachiniSiriwardene Dec 10, 2024
2c60f1a
add org settings pages
SachiniSiriwardene Dec 10, 2024
22efe21
add missing column to db script
SachiniSiriwardene Dec 10, 2024
ab68579
update config file
SachiniSiriwardene Dec 10, 2024
5dd372e
remove commented lines
SachiniSiriwardene Dec 10, 2024
e652c1f
change method to refer req
SachiniSiriwardene Dec 10, 2024
6907bf5
Merge branch 'release-1.0.0-m1' of https://github.com/wso2/api-develo…
SachiniSiriwardene Dec 10, 2024
ea49f7e
resolve merge conflicts
SachiniSiriwardene Dec 10, 2024
231dd9e
load control plane api path from a constant
SachiniSiriwardene Dec 10, 2024
3f25ae4
add defaullt pages for configure and portal
SachiniSiriwardene Dec 10, 2024
2721ae6
add logs for debug
SachiniSiriwardene Dec 11, 2024
71c8d98
copy axios
SachiniSiriwardene Dec 11, 2024
0b9a2f8
fix errors
SachiniSiriwardene Dec 11, 2024
8566386
copy startup.bat
SachiniSiriwardene Dec 11, 2024
d328afe
add build options
SachiniSiriwardene Dec 11, 2024
909cfd7
Update src/pages/portal/page.hbs
DivyaPremanantha Dec 11, 2024
2a6e93a
Update src/scripts/createOrg.js
DivyaPremanantha Dec 11, 2024
a7f9257
Update src/scripts/createOrg.js
DivyaPremanantha Dec 11, 2024
4265a83
fix bugs and pr comments
SachiniSiriwardene Dec 11, 2024
4666f29
Update src/scripts/createOrg.js
DivyaPremanantha Dec 11, 2024
f202e15
Update src/middlewares/ensureAuthenticated.js
DivyaPremanantha Dec 11, 2024
61614ff
Update src/routes/authRoute.js
DivyaPremanantha Dec 11, 2024
8ffb330
Merge branch 'login' of https://github.com/SachiniSiriwardene/api-dev…
SachiniSiriwardene Dec 11, 2024
f9e42f1
add conf
SachiniSiriwardene Dec 11, 2024
79269e3
Update src/pages/scripts/createOrg.js
DivyaPremanantha Dec 11, 2024
46f009b
Merge branch 'login' of https://github.com/SachiniSiriwardene/api-dev…
SachiniSiriwardene Dec 11, 2024
0ec2183
fix lint issue
SachiniSiriwardene Dec 11, 2024
a93b3a5
remove unwanted code
SachiniSiriwardene Dec 11, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
mkdir -p ./temp-dir/developer-portal

# Copy the additional files and folders into developer-portal
cp -r bin artifacts InstallationGuide.md QuickStart.md README.md config.json ./temp-dir/developer-portal/
cp -r bin/startup.sh bin/startup.bat artifacts InstallationGuide.md QuickStart.md README.md config.json ./temp-dir/developer-portal/

# Move the current dist file into developer-portal
mv "$file" ./temp-dir/developer-portal/
Expand Down
10 changes: 10 additions & 0 deletions artifacts/script.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ CREATE TABLE "DP_ORGANIZATION" (
"BUSINESS_OWNER" VARCHAR(256) NOT NULL,
"BUSINESS_OWNER_CONTACT" VARCHAR(256) NOT NULL,
"BUSINESS_OWNER_EMAIL" VARCHAR(256) NOT NULL,
"DEV_PORTAL_URL_IDENTIFIER" VARCHAR(255),
"ROLE_CLAIM_NAME" VARCHAR(255) NOT NULL,
"GROUPS_CLAIM_NAME" VARCHAR(255) NOT NULL,
"ORGANIZATION_CLAIM_NAME" VARCHAR(255) NOT NULL,
"ORGANIZATION_IDENTIFIER" VARCHAR(255) NOT NULL,
"ADMIN_ROLE" VARCHAR(255) NOT NULL,
"SUBSCRIBER_ROLE" VARCHAR(255) NOT NULL,
"GROUP_CLAIM_NAME" VARCHAR(255) NOT NULL,
"SUPER_ADMIN_ROLE" VARCHAR(255) NOT NULL
UNIQUE ("ORG_NAME"),
PRIMARY KEY("ORG_ID")
);
Expand Down Expand Up @@ -66,6 +75,7 @@ CREATE TABLE "DP_API_METADATA" (
"PRODUCTION_URL" VARCHAR(256),
"SANDBOX_URL" VARCHAR(256),
"METADATA_SEARCH" JSON,
"PROVIDER" VARCHAR(256)
PRIMARY KEY ("API_ID"),
FOREIGN KEY ("ORG_ID") REFERENCES "DP_ORGANIZATION"("ORG_ID") ON DELETE CASCADE
);
Expand Down
45 changes: 41 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"pathToContent": "../src/",
"mode": "production",
"controlPlane" : {
"url": "https://localhost:9443/api/am/devportal/v3",
"accessToken" :"Bearer <control-plane-access-token>",
"disableCertValidation": false,
"url": "https://127.0.0.1:9443/api/am/devportal/v3",
"disableCertValidation": true,
"pathToCertificate": "../api-developer-portal/conf/security/client-truststore.pem"
},
"db": {
Expand All @@ -17,5 +16,43 @@
},
"providerURL": {
"AWS": "https://aws.amazon.com"
}
},
"identityProvider" : {
"name": "IS",
"issuer": "https://127.0.0.1:9443/oauth2/token",
"authorizationURL": "https://localhost:9443/oauth2/authorize",
"tokenURL": "https://127.0.0.1:9443/oauth2/token",
"userInfoURL": "https://localhost:9443/oauth2/userinfo",
"clientId": "",
"callbackURL": "http://localhost:3000/ACME/callback",
"scope": "openid email profile apim:subscribe role",
"signUpURL": "",
"logoutURL": "https://localhost:9443/oidc/logout",
"logoutRedirectURI": "http://localhost:3000/ACME"
},
"roleClaim": "roles",
"orgIDClaim": "organizationID",
"groupsClaim": "groups",
"adminRole": "admin",
"subscriberRole": "Interna/subscriber",
"superAdminRole": "superAdmin",
"authenticatedPages": [
"/*/configure",
"/portal",
"/*/applications",
"/*/applications/*",
"/*/api/*",
"/*/myAPIs",
"/*/myAPIs/*"

],
"authorizedPages": [
"/*/applications",
"/*/applications/*",
"/*/configure",
"/portal",
"/*/api/*",
"/*/myAPIs",
"/*/myAPIs/*"
]
}
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"express": "^4.21.0",
"express-handlebars": "^7.1.3",
"express-session": "^1.18.0",
"express-validator": "^7.2.0",
"fs-extra": "^11.2.0",
"graphiql": "^3.7.1",
"graphql": "^16.9.0",
Expand Down Expand Up @@ -69,15 +70,11 @@
],
"assets": [
"src/pages/**/*",
"src/styles/**/*"
"src/styles/**/*",
"node_modules/axios/**/*"
],
"targets": [
"node18-macos-x64",
"node18-linux-x64",
"node18-win-x64",
"node18-macos-x86",
"node18-linux-x86",
"node18-win-x86"
"node18-macos-x64"
],
"outputPath": "dist"
},
Expand Down
2 changes: 2 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const config = require(process.cwd() + '/config.json');
const Handlebars = require('handlebars');
const constants = require("./utils/constants");
const designRoute = require('./routes/designModeRoute');
const settingsRoute = require('./routes/configureRoute');

const app = express();
const secret = crypto.randomBytes(64).toString('hex');
Expand Down Expand Up @@ -93,6 +94,7 @@ if (config.mode === constants.DEV_MODE) {
app.use(constants.ROUTE.DEFAULT, applicationContent);
app.use(constants.ROUTE.DEFAULT, orgContent);
app.use(constants.ROUTE.DEFAULT, myAPIs);
app.use(constants.ROUTE.DEFAULT, settingsRoute);
app.use(constants.ROUTE.DEFAULT, customContent);
}

Expand Down
15 changes: 8 additions & 7 deletions src/controllers/apiContentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ const loadAPIs = async (req, res) => {
html = await renderTemplateFromAPI(templateContent, orgID, orgName, "pages/apis");
} catch (error) {
console.error(`Error while loading organization content ,${error}`);
console.log("Rendering default api listing page from file");
const templateContent = {
baseUrl: constants.BASE_URL + config.port
}
html = renderTemplate(filePrefix + 'pages/apis/page.hbs', filePrefix + 'layout/main.hbs', templateContent, false);
return res.redirect('configure');
}
}
res.send(html);
Expand Down Expand Up @@ -137,7 +133,7 @@ const loadAPIContent = async (req, res) => {

const loadSubscriptionPlan = async (req, res, policyId) => {
try {
return await util.invokeApiRequest('GET', `${config.controlPlane.url}/throttling-policies/subscription/${policyId}`);
return await util.invokeApiRequest(req, 'GET', `${config.controlPlane.url}/throttling-policies/subscription/${policyId}`);
} catch (error) {
console.error("Error occurred while loading subscription plans", error);
util.handleError(res, error);
Expand Down Expand Up @@ -166,7 +162,12 @@ const loadTryOutPage = async (req, res) => {
const orgID = await adminDao.getOrgId(orgName);
const apiID = await apiDao.getAPIId(apiName);
const metaData = await loadAPIMetaData(req, orgID, apiID);
let apiDefinition = await apiDao.getAPIFile(constants.FILE_NAME.API_DEFINITION_FILE_NAME, orgID, apiID);
let apiDefinition;
if (metaData.apiType === "GraphQL") {
apiDefinition = await apiDao.getAPIFile(constants.FILE_NAME.API_DEFINITION_GRAPHQL, orgID, apiID);
} else {
apiDefinition = await apiDao.getAPIFile(constants.FILE_NAME.API_DEFINITION_FILE_NAME, orgID, apiID);
}
apiDefinition = apiDefinition.API_FILE.toString(constants.CHARSET_UTF8);
const templateContent = {
apiMetadata: metaData,
Expand Down
45 changes: 23 additions & 22 deletions src/controllers/applicationsContentController.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-undef */
const { renderTemplate, renderGivenTemplate, loadLayoutFromAPI, invokeApiRequest } = require('../utils/util');
const config = require(process.cwd() + '/config');
const constants = require('../utils/constants');
Expand Down Expand Up @@ -33,7 +34,7 @@ const loadApplications = async (req, res) => {
else {
const orgName = req.params.orgName;
const orgID = await orgIDValue(orgName);
metaData = await getAPIMApplications();
metaData = await getAPIMApplications(req);
templateContent = {
applicationsMetadata: metaData,
baseUrl: '/' + orgName
Expand All @@ -51,8 +52,8 @@ async function getMockApplications() {
return mockApplicationsMetaData.list;
}

async function getAPIMApplications() {
const responseData = await invokeApiRequest('GET', controlPlaneUrl + '/applications', null, null);
async function getAPIMApplications(req) {
const responseData = await invokeApiRequest(req, 'GET', controlPlaneUrl + '/applications', null, null);
return responseData.list;
}

Expand All @@ -71,7 +72,7 @@ const loadThrottlingPolicies = async (req, res) => {
else {
const orgName = req.params.orgName;
const orgID = await orgIDValue(orgName);
metaData = await getAPIMThrottlingPolicies();
metaData = await getAPIMThrottlingPolicies(req);
templateContent = {
throttlingPoliciesMetadata: metaData,
baseUrl: '/' + orgName
Expand All @@ -90,8 +91,8 @@ async function getMockThrottlingPolicies() {
return mockThrottlingPoliciesMetaData.list;
}

async function getAPIMThrottlingPolicies() {
const responseData = await invokeApiRequest('GET', controlPlaneUrl + '/throttling-policies/application', null, null);
async function getAPIMThrottlingPolicies(req) {
const responseData = await invokeApiRequest(req, 'GET', controlPlaneUrl + '/throttling-policies/application', null, null);
return responseData.list;
}

Expand All @@ -113,9 +114,9 @@ const loadApplication = async (req, res) => {
} else {
const orgName = req.params.orgName;
const orgID = await orgIDValue(orgName);
metaData = await getAPIMApplication(applicationId);
const allApis = await getAllAPIs();
const subApis = await getSubscribedApis(applicationId);
metaData = await getAPIMApplication(req, applicationId);
const allApis = await getAllAPIs(req);
const subApis = await getSubscribedApis(req, applicationId);
const subApiMap = new Map();
subApis.list.forEach(subApi => subApiMap.set(subApi.apiId, { policy: subApi.throttlingPolicy, id: subApi.subscriptionId }));
const apiList = [];
Expand All @@ -142,7 +143,7 @@ const loadApplication = async (req, res) => {

});

kMmetaData = await getAPIMKeyManagers();
kMmetaData = await getAPIMKeyManagers(req);
templateContent = {
applicationMetadata: metaData,
keyManagersMetadata: kMmetaData,
Expand All @@ -162,28 +163,28 @@ const loadApplication = async (req, res) => {
}


async function getAllAPIs() {
async function getAllAPIs(req) {
try {
return await util.invokeApiRequest('GET', `${controlPlaneUrl}/apis`);
return await util.invokeApiRequest(req, 'GET', `${controlPlaneUrl}/apis`);
} catch (error) {
console.error("Error occurred while loading APIs", error);
throw error;
}
}

const getSubscribedApis = async (appId) => {
const getSubscribedApis = async (req, appId) => {
try {
return await util.invokeApiRequest('GET', `${controlPlaneUrl}/subscriptions?applicationId=${appId}`);
return await util.invokeApiRequest(req, 'GET', `${controlPlaneUrl}/subscriptions?applicationId=${appId}`);
} catch (error) {
console.error("Error occurred while loading subscriptions", error);
throw error;
}
}

const loadApplicationForEdit = async (req, res) => {
const orgName = req.params.orgName;

const applicationId = req.params.applicationid;
let html, templateContent, metaData;
let html, templateContent, metaData, throttlingMetaData;
if (config.mode === constants.DEV_MODE) {
metaData = await getMockApplication();
throttlingMetaData = await getMockThrottlingPolicies();
Expand All @@ -196,8 +197,8 @@ const loadApplicationForEdit = async (req, res) => {
} else {
const orgName = req.params.orgName;
const orgID = await orgIDValue(orgName);
metaData = await getAPIMApplication(applicationId);
throttlingMetaData = await getAPIMThrottlingPolicies();
metaData = await getAPIMApplication(req, applicationId);
throttlingMetaData = await getAPIMThrottlingPolicies(req);
templateContent = {
applicationMetadata: metaData,
throttlingPoliciesMetadata: throttlingMetaData,
Expand All @@ -223,13 +224,13 @@ async function getMockKeyManagers() {
return mockKeyManagersMetaData.list;
}

async function getAPIMApplication(applicationId) {
const responseData = await invokeApiRequest('GET', controlPlaneUrl + '/applications/' + applicationId, null, null);
async function getAPIMApplication(req, applicationId) {
const responseData = await invokeApiRequest(req, 'GET', controlPlaneUrl + '/applications/' + applicationId, null, null);
return responseData;
}

async function getAPIMKeyManagers() {
const responseData = await invokeApiRequest('GET', controlPlaneUrl + '/key-managers', null, null);
async function getAPIMKeyManagers(req) {
const responseData = await invokeApiRequest(req, 'GET', controlPlaneUrl + '/key-managers', null, null);
return responseData.list;
}

Expand Down
Loading