Skip to content

Commit

Permalink
Merge pull request #1816 from OpenC3/bug/misc-issues
Browse files Browse the repository at this point in the history
Fix a few issues with iframes, script runner, and login
  • Loading branch information
ryan-pratt authored Jan 9, 2025
2 parents f061102 + 195974a commit abd2b73
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def token_exists

def verify
begin
if OpenC3::AuthModel.verify(params[:token])
if OpenC3::AuthModel.verify_no_service(params[:token])
render :plain => OpenC3::AuthModel.generate_session()
else
head :unauthorized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@astrouxds/astro-web-components": "7.24.1",
"@braintree/sanitize-url": "7.1.1",
"@openc3/js-common": "6.0.2-beta0",
"@openc3/vue-common": "6.0.2-beta0",
"axios": "1.7.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</template>

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

export default {
Expand All @@ -62,7 +63,7 @@ export default {
this.title = this.$route.query.title
}
if (this.$route.query && this.$route.query.url) {
this.url = this.$route.query.url
this.url = sanitizeUrl(this.$route.query.url)
}
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"dependencies": {
"@astrouxds/astro-web-components": "7.24.1",
"@braintree/sanitize-url": "7.1.1",
"@openc3/js-common": "6.0.2-beta0",
"@rails/actioncable": "7.1.3-4",
"axios": "1.7.9",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
<template>
<iframe
title="IFrameWidget"
:src="parameters[0]"
:src="url"
:width="width"
:height="height"
:style="computedStyle"
/>
</template>

<script>
import { sanitizeUrl } from '@braintree/sanitize-url'
import Widget from './Widget'

export default {
Expand All @@ -39,6 +40,7 @@ export default {
return {
width: 800,
height: 600,
url: sanitizeUrl(this.parameters[0]),
}
},
created: function () {
Expand Down
1 change: 1 addition & 0 deletions openc3-cosmos-script-runner-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RUN bundle config set --local without 'development' \
RUN ["chown", "-R", "openc3:openc3", "/src/"]
COPY --chown=${IMAGE_USER}:${IMAGE_GROUP} ./ ./
RUN ["chmod", "-R", "777", "/src/"]
RUN ["chmod", "-R", "555", "/src/scripts"]

EXPOSE 2902

Expand Down
26 changes: 4 additions & 22 deletions openc3-cosmos-script-runner-api/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# README
# Setting up the Script Runner API

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

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...
Scripts use a service password to authenticate with the rest of the COSMOS system in the open source edition.
You should pick a new service password by setting the value of the `OPENC3_SERVICE_PASSWORD` variable in the [.env file](../.env)
14 changes: 9 additions & 5 deletions openc3/lib/openc3/models/auth_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def self.set?(key = PRIMARY_KEY)
end

def self.verify(token)
# Handle a service password - Generally only used by ScriptRunner
# TODO: Replace this with temporary service tokens
service_password = ENV['OPENC3_SERVICE_PASSWORD']
return true if service_password and service_password == token

return verify_no_service(token)
end

def self.verify_no_service(token)
return false if token.nil? or token.empty?

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

# Handle a service password - Generally only used by ScriptRunner
# TODO: Replace this with temporary service tokens
service_password = ENV['OPENC3_SERVICE_PASSWORD']
return true if service_password and service_password == token

return false
end

Expand Down
2 changes: 1 addition & 1 deletion playwright/tests/script-runner/file-menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ test('open a file', async ({ page, utils }) => {
page
.locator('.v-list-item-title:has-text("INST/procedures/disconnect.rb")')
.click()
expect(await page.locator('#sr-controls')).toContainText(
await expect(page.locator('#sr-controls')).toContainText(
`INST/procedures/disconnect.rb`,
)
})
Expand Down

0 comments on commit abd2b73

Please sign in to comment.