Skip to content

Commit abd2b73

Browse files
authored
Merge pull request #1816 from OpenC3/bug/misc-issues
Fix a few issues with iframes, script runner, and login
2 parents f061102 + 195974a commit abd2b73

File tree

9 files changed

+23
-31
lines changed

9 files changed

+23
-31
lines changed

openc3-cosmos-cmd-tlm-api/app/controllers/auth_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def token_exists
3333

3434
def verify
3535
begin
36-
if OpenC3::AuthModel.verify(params[:token])
36+
if OpenC3::AuthModel.verify_no_service(params[:token])
3737
render :plain => OpenC3::AuthModel.generate_session()
3838
else
3939
head :unauthorized

openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-iframe/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@astrouxds/astro-web-components": "7.24.1",
14+
"@braintree/sanitize-url": "7.1.1",
1415
"@openc3/js-common": "6.0.2-beta0",
1516
"@openc3/vue-common": "6.0.2-beta0",
1617
"axios": "1.7.9",

openc3-cosmos-init/plugins/packages/openc3-cosmos-tool-iframe/src/tools/Iframe/Iframe.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</template>
4646

4747
<script>
48+
import { sanitizeUrl } from '@braintree/sanitize-url'
4849
import { TopBar } from '@openc3/vue-common/components'
4950

5051
export default {
@@ -62,7 +63,7 @@ export default {
6263
this.title = this.$route.query.title
6364
}
6465
if (this.$route.query && this.$route.query.url) {
65-
this.url = this.$route.query.url
66+
this.url = sanitizeUrl(this.$route.query.url)
6667
}
6768
},
6869
}

openc3-cosmos-init/plugins/packages/openc3-vue-common/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
},
6666
"dependencies": {
6767
"@astrouxds/astro-web-components": "7.24.1",
68+
"@braintree/sanitize-url": "7.1.1",
6869
"@openc3/js-common": "6.0.2-beta0",
6970
"@rails/actioncable": "7.1.3-4",
7071
"axios": "1.7.9",

openc3-cosmos-init/plugins/packages/openc3-vue-common/src/widgets/IframeWidget.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
<template>
2424
<iframe
2525
title="IFrameWidget"
26-
:src="parameters[0]"
26+
:src="url"
2727
:width="width"
2828
:height="height"
2929
:style="computedStyle"
3030
/>
3131
</template>
3232

3333
<script>
34+
import { sanitizeUrl } from '@braintree/sanitize-url'
3435
import Widget from './Widget'
3536

3637
export default {
@@ -39,6 +40,7 @@ export default {
3940
return {
4041
width: 800,
4142
height: 600,
43+
url: sanitizeUrl(this.parameters[0]),
4244
}
4345
},
4446
created: function () {

openc3-cosmos-script-runner-api/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ RUN bundle config set --local without 'development' \
2121
RUN ["chown", "-R", "openc3:openc3", "/src/"]
2222
COPY --chown=${IMAGE_USER}:${IMAGE_GROUP} ./ ./
2323
RUN ["chmod", "-R", "777", "/src/"]
24+
RUN ["chmod", "-R", "555", "/src/scripts"]
2425

2526
EXPOSE 2902
2627

+4-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
# README
1+
# Setting up the Script Runner API
22

3-
This README would normally document whatever steps are necessary to get the
4-
application up and running.
3+
## Changing the service password
54

6-
Things you may want to cover:
7-
8-
* Ruby version
9-
10-
* System dependencies
11-
12-
* Configuration
13-
14-
* Database creation
15-
16-
* Database initialization
17-
18-
* How to run the test suite
19-
20-
* Services (job queues, cache servers, search engines, etc.)
21-
22-
* Deployment instructions
23-
24-
* ...
5+
Scripts use a service password to authenticate with the rest of the COSMOS system in the open source edition.
6+
You should pick a new service password by setting the value of the `OPENC3_SERVICE_PASSWORD` variable in the [.env file](../.env)

openc3/lib/openc3/models/auth_model.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ def self.set?(key = PRIMARY_KEY)
4343
end
4444

4545
def self.verify(token)
46+
# Handle a service password - Generally only used by ScriptRunner
47+
# TODO: Replace this with temporary service tokens
48+
service_password = ENV['OPENC3_SERVICE_PASSWORD']
49+
return true if service_password and service_password == token
50+
51+
return verify_no_service(token)
52+
end
53+
54+
def self.verify_no_service(token)
4655
return false if token.nil? or token.empty?
4756

4857
time = Time.now
@@ -60,11 +69,6 @@ def self.verify(token)
6069
@@token_cache_time = time
6170
return true if @@token_cache == token_hash
6271

63-
# Handle a service password - Generally only used by ScriptRunner
64-
# TODO: Replace this with temporary service tokens
65-
service_password = ENV['OPENC3_SERVICE_PASSWORD']
66-
return true if service_password and service_password == token
67-
6872
return false
6973
end
7074

playwright/tests/script-runner/file-menu.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ test('open a file', async ({ page, utils }) => {
9090
page
9191
.locator('.v-list-item-title:has-text("INST/procedures/disconnect.rb")')
9292
.click()
93-
expect(await page.locator('#sr-controls')).toContainText(
93+
await expect(page.locator('#sr-controls')).toContainText(
9494
`INST/procedures/disconnect.rb`,
9595
)
9696
})

0 commit comments

Comments
 (0)