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 support for third-party services #1303

Merged
merged 11 commits into from
Oct 7, 2024

Conversation

cmeessen
Copy link
Contributor

@cmeessen cmeessen commented Sep 20, 2024

Fixes #1288

Changes proposed in this pull request:

  • adds support for third-party services via plugin slots in the user interface. The plugin slots are links that are provided by third-party services
  • supports an arbitrary amount of plugins
  • currently implemented slots are: userMenu and softwareEditNav (see type PluginSlot)
  • adds a documentation
  • adds syntax highlighting in docusaurus for json, nginx and typescript
  • adds a data attribute to the user token which contains eduPersonEntitlements if the user logs in via HelmholtzID

How to test:

  • follow steps to setup example plugin container in research-software-directory/RSD-plugin-example (in progress)
  • login
  • verify that plugin slots are shown including svg icons in the user menu and in the software edit navigation sidebar

PR Checklist:

  • Increase version numbers in docker-compose.yml
  • Link to a GitHub issue
  • Update documentation
  • Tests

@cmeessen cmeessen force-pushed the 1288-integrating-third-party-services branch 7 times, most recently from c7aae51 to ab028b4 Compare September 26, 2024 14:29
@cmeessen cmeessen force-pushed the 1288-integrating-third-party-services branch from ab028b4 to 07ba123 Compare September 27, 2024 09:20
@cmeessen cmeessen changed the title feat: provide eduperson_entitlements in user token Add support for third-party services Sep 27, 2024
@cmeessen cmeessen self-assigned this Sep 27, 2024
@cmeessen cmeessen marked this pull request as ready for review September 27, 2024 09:32
@cmeessen cmeessen force-pushed the 1288-integrating-third-party-services branch from 07ba123 to f6018a2 Compare September 27, 2024 09:36
Copy link
Contributor

@dmijatovic dmijatovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!
I have some improvement suggestions. Let's discuss how and when to implement these.

frontend/auth/index.tsx Show resolved Hide resolved
frontend/config/RsdPluginContext.tsx Outdated Show resolved Hide resolved
frontend/components/software/edit/editSoftwarePages.tsx Outdated Show resolved Hide resolved
frontend/utils/svgFromString.tsx Outdated Show resolved Hide resolved
frontend/config/menuItems.tsx Show resolved Hide resolved
frontend/utils/userPlugins.ts Outdated Show resolved Hide resolved
frontend/utils/userPlugins.ts Outdated Show resolved Hide resolved
@dmijatovic dmijatovic self-requested a review September 30, 2024 13:13
Copy link
Contributor

@dmijatovic dmijatovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice team work!
Now let other perform double check, especially documentation.

@cmeessen cmeessen force-pushed the 1288-integrating-third-party-services branch 3 times, most recently from 19cc951 to 9580d69 Compare October 2, 2024 10:10
Copy link
Collaborator

@ewan-escience ewan-escience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm requesting changes here to prevent this PR from being merged while not being ready. First, #1310 should be improved upon and merged into this branch, resolving the issue that the plugins are not reachable from the Next.js server when running the frontend in prod mode (i.e. built in Docker).

cmeessen and others added 5 commits October 7, 2024 09:20
refactor: user menu hook moved inside component
fix: create license files
tests: create svg component test and fix muiSnackbar test
refactor: update plugin config url
Listen to main server block so that requests to port 80 that do not match server_names are not handled by the first block
@cmeessen cmeessen force-pushed the 1288-integrating-third-party-services branch from 5ec608d to f201d6a Compare October 7, 2024 07:22
Comment on lines 14 to 25
if (/^(https?:\/\/)/.test(pluginName)) {
return pluginName
} else if (process.env.NODE_ENV === 'development') {
return `http://localhost/plugin/${pluginName}`
} else {
const baseUrl = process.env.RSD_REVERSE_PROXY_URL
return `${baseUrl}/plugin/${pluginName}`
}
}

async function getPlugin({pluginName, token}:{pluginName: string, token?: string}){
const url = getPluginBaseUrl(pluginName) + '/api/v1/config'
Copy link
Contributor

@dmijatovic dmijatovic Oct 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move /api/v1/config into getPluginUrl and use it only in elseif cases (when only plugin name is provided)?

} else if (process.env.NODE_ENV === 'development') {
return `http://localhost/plugin/${pluginName}`
} else {
const baseUrl = process.env.RSD_REVERSE_PROXY_URL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add default http://nginx?

const baseUrl = process.env.RSD_REVERSE_PROXY_URL ?? 'http://nginx'

BREAKING: adds a new environment variable RSD_REVERSE_PROXY url that is
required by the frontend container to construct the plugin base url when
running it in the same docker network.
@cmeessen cmeessen force-pushed the 1288-integrating-third-party-services branch from f201d6a to c0e9d0c Compare October 7, 2024 10:21
Copy link

sonarcloud bot commented Oct 7, 2024

Copy link

sonarcloud bot commented Oct 7, 2024

Quality Gate Failed Quality Gate failed for 'rsd-frontend'

Failed conditions
1 Security Hotspot

See analysis details on SonarCloud

@cmeessen
Copy link
Contributor Author

cmeessen commented Oct 7, 2024

Sonar cloud complains about http being insecure. This is not relevant here, because the communication happens inside the docker network.

@cmeessen cmeessen merged commit c7b0320 into main Oct 7, 2024
4 of 5 checks passed
@dmijatovic dmijatovic deleted the 1288-integrating-third-party-services branch November 11, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrating third party services into the RSD
4 participants