Skip to content

Commit

Permalink
Merge pull request #15457 from schrd/fix-issue-15436
Browse files Browse the repository at this point in the history
Fix: use grails configuration for CORS settings
  • Loading branch information
antobinary committed Jan 23, 2023
2 parents d7da9f7 + e0e1d9e commit 5ea43ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
23 changes: 1 addition & 22 deletions bigbluebutton-web/bbb-web.nginx
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,16 @@

# Workaround IE refusal to set cookies in iframe
add_header P3P 'CP="No P3P policy available"';
if ($bbb_loadbalancer_node) {
add_header 'Access-Control-Allow-Origin' $bbb_loadbalancer_node always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
}


location ~ "^\/bigbluebutton\/presentation\/(?<prestoken>[a-zA-Z0-9_-]+)/upload$" {
# Grails can't handle CORS OPTION preflight requests correctly -> lets do this in nginx
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' $bbb_loadbalancer_node always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
proxy_pass http://127.0.0.1:8090;
proxy_redirect default;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Workaround IE refusal to set cookies in iframe
add_header P3P 'CP="No P3P policy available"';
if ($bbb_loadbalancer_node) {
add_header 'Access-Control-Allow-Origin' $bbb_loadbalancer_node always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}

# high limit for presentation as bbb-web will reject upload if larger than configured
client_max_body_size 1000m;
Expand Down Expand Up @@ -73,9 +57,6 @@
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Workaround IE refusal to set cookies in iframe
add_header P3P 'CP="No P3P policy available"';
if ($bbb_loadbalancer_node) {
add_header 'Access-Control-Allow-Origin' $bbb_loadbalancer_node always;
}
}

location = /bigbluebutton/presentation/checkPresentation {
Expand All @@ -87,6 +68,7 @@
proxy_set_header X-Original-URI $request_uri;
proxy_set_header Content-Length "";
proxy_set_header X-Original-Content-Length $http_content_length;
proxy_set_header X-Original-Method $request_method;

# high limit for presentation as bbb-web will reject upload if larger than configured
client_max_body_size 1000m;
Expand Down Expand Up @@ -129,9 +111,6 @@
location ~ "^/bigbluebutton\/textTrack\/(?<textTrackToken>[a-zA-Z0-9]+)\/(?<recordId>[a-zA-Z0-9_-]+)\/(?<textTrack>.+)$" {
# Workaround IE refusal to set cookies in iframe
add_header P3P 'CP="No P3P policy available"';
if ($bbb_loadbalancer_node) {
add_header 'Access-Control-Allow-Origin' $bbb_loadbalancer_node always;
}

# Allow 30M uploaded presentation document.
client_max_body_size 30m;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,27 @@ class PresentationController {
def originalContentLengthString = request.getHeader("x-original-content-length")

def originalContentLength = 0
if (originalContentLengthString.isNumber()) {
// x-original-content-length may be missing (for example in CORS OPTION requests)
if (null != originalContentLengthString && originalContentLengthString.isNumber()) {
originalContentLength = originalContentLengthString as int
}
if (request.getHeader("x-original-method") == 'OPTIONS') {
if (meetingService.authzTokenIsValid(presentationToken)) {
log.debug "OPTIONS SUCCESS \n"
response.setStatus(200)
response.addHeader("Cache-Control", "no-cache")
response.contentType = 'plain/text'
response.outputStream << 'upload-success';
return;
} else {
log.debug "OPTIONS FAIL\n"
response.setStatus(403)
response.addHeader("Cache-Control", "no-cache")
response.contentType = 'plain/text'
response.outputStream << 'upload-fail';
return;
}
}

if (null != presentationToken
&& meetingService.authzTokenIsValid(presentationToken) // this we do in the upload handling
Expand Down

0 comments on commit 5ea43ff

Please sign in to comment.