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

Dashboard blocked in iframe tag #1111

Closed
icyleaf opened this issue Oct 17, 2023 · 4 comments
Closed

Dashboard blocked in iframe tag #1111

icyleaf opened this issue Oct 17, 2023 · 4 comments

Comments

@icyleaf
Copy link

icyleaf commented Oct 17, 2023

I want use good_job instead of sidekiq but some issues happened to me:

  1. i can not use url_helper, because good job root path redirect to jobs. workaround GoodJob::Engine.routes.url_helpers.jobs_path
  2. good job can not use in iframe tag, brower returns blocked:other and render localhost refused to connect.

Any help please, thanks.

@bensheldon
Copy link
Owner

bensheldon commented Oct 17, 2023

For 1., you should be able to use good_jobs.jobs_path: https://guides.rubyonrails.org/engines.html#routes

For 2., can you tell me about what you want to achieve by embedding in an iframe? That is blocked by default for security:

policy.frame_ancestors(:none) if policy.frame_ancestors(*policy.frame_ancestors).blank?

If the defaults don't work for your security situation, you can override that by doing something like:

# config/initializers/good_job.rb
ActiveSupport.on_load("good_job_application_controller") do 
  content_security_policy do |policy|
    # set your own directives
  end
end

@icyleaf
Copy link
Author

icyleaf commented Oct 17, 2023

For 1., you should be able to use good_jobs.jobs_path: https://guides.rubyonrails.org/engines.html#routes

Thank you very much, I missed that part of the document!

can you tell me about what you want to achieve by embedding in an iframe?

I can re-use the dashbord web ui to developers in zealot background jobs.

I'll dig it, some breaking changes to migrating, such like:

@bensheldon
Copy link
Owner

bensheldon commented Oct 17, 2023

aha! Thanks for that context! Yep, I think do the csp-override like I shared is the best way right now to make granular changes to GoodJob's default.

I think activejob-status should continue to work, as it's compatible with Active Job and just adds some before/after/around/rescue_from hooks: https://github.com/inkstak/activejob-status/blob/main/lib/activejob-status.rb#L22-L31

...though if all you want to do is simply see if jobs are completed, you could use the GoodJob::Job model to query the table directly.

@icyleaf
Copy link
Author

icyleaf commented Oct 17, 2023

Embed dashboard works! tiny fix: ActiveSupport .on_load only accepts symbol hook name.

...though if all you want to do is simply see if jobs are completed, you could use the GoodJob::Job model to query the table directly.

I use this logical code to reslove dynamic scheduler.

I used hard code for job status (operate redis directly), may be i need rewrite full logical about this part. 😢

@icyleaf icyleaf closed this as completed Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants