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

Fix a few issues with iframes, script runner, and login #1816

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def token_exists

def verify
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is only called by verifyPassword in Login.vue

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"]
Copy link
Member

Choose a reason for hiding this comment

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

Looks like running_script sets the process cwd to /src/scripts and we execute out of there. Can you document why this is needed or is more secure?


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
Loading