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 CORS allowedOrigins Property to CrossOriginResourceSharingFilter of Product REST APIs #10287

Merged
merged 1 commit into from Apr 9, 2021

Conversation

hisanhunais
Copy link
Contributor

@hisanhunais hisanhunais commented Apr 8, 2021

Purpose

This PR adds the "allowedOrigins" property to the "CrossOriginResourceSharingFilter" of the Product REST APIs.

Approach

This "allowedOrigins" property will be reading values from System parameters. The defined system parameters are as follows.

  • For Publisher REST APIs : rest.api.publisher.allowed.origins
  • For Store REST APIs : rest.api.store.allowed.origins
  • For Gateway REST APIs : rest.api.gateway.allowed.origins
  • For Service Catalog REST APIs : rest.api.service.catalog.allowed.origins

Hence, the allowed origins for a particular REST API should be configured as a system parameter as follows.

Method 1: Specify the allowed origins in the deployment.toml file under [system.parameter]

[system.parameter]
'rest.api.publisher.allowed.origins' = "https://null.jsbin.com"
'rest.api.store.allowed.origins' = "https://null.jsbin.com,https://fiddle.jshell.net"
'rest.api.gateway.allowed.origins' = "https://null.jsbin.com"
'rest.api.service.catalog.allowed.origins' = "https://js.do"

Method 2: Specify the allowed origins when starting the server

sh wso2server.sh -Drest.api.publisher.allowed.origins=https://null.jsbin.com -Drest.api.devportal.allowed.origins=https://null.jsbin.com,https://fiddle.jshell.net -Drest.api.gateway.allowed.origins=https://null.jsbin.com -Drest.api.service.catalog.allowed.origins=https://js.do

@malinthaprasan
Copy link
Contributor

is that 'rest.api.devportal.allowed.origins'? not 'rest.api.store.allowed.origins' right

@malinthaprasan
Copy link
Contributor

Shall we also mention this in https://apim.docs.wso2.com/en/latest/develop/product-apis/advanced-configurations/
Please create a doc issue and followup.

@hisanhunais
Copy link
Contributor Author

hisanhunais commented Apr 9, 2021

is that 'rest.api.devportal.allowed.origins'? not 'rest.api.store.allowed.origins' right

Sorry. Yes, it should be 'rest.api.devportal.allowed.origins'.

@hisanhunais
Copy link
Contributor Author

Updated Content

Purpose

This PR adds the "allowedOrigins" property to the "CrossOriginResourceSharingFilter" of the Product REST APIs.

Approach

This "allowedOrigins" property will be reading values from System parameters. The defined system parameters are as follows.

  • For Publisher REST APIs : rest.api.publisher.allowed.origins
  • For DevPortal REST APIs : rest.api.devportal.allowed.origins
  • For Gateway REST APIs : rest.api.gateway.allowed.origins
  • For Service Catalog REST APIs : rest.api.service.catalog.allowed.origins

Hence, the allowed origins for a particular REST API should be configured as a system parameter as follows.

Method 1: Specify the allowed origins in the deployment.toml file under [system.parameter]

[system.parameter]
'rest.api.publisher.allowed.origins' = "https://null.jsbin.com"
'rest.api.devportal.allowed.origins' = "https://null.jsbin.com,https://fiddle.jshell.net"
'rest.api.gateway.allowed.origins' = "https://null.jsbin.com"
'rest.api.service.catalog.allowed.origins' = "https://js.do"

Method 2: Specify the allowed origins when starting the server

sh wso2server.sh -Drest.api.publisher.allowed.origins=https://null.jsbin.com -Drest.api.devportal.allowed.origins=https://null.jsbin.com,https://fiddle.jshell.net -Drest.api.gateway.allowed.origins=https://null.jsbin.com -Drest.api.service.catalog.allowed.origins=https://js.do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants