Hangfire Dashboard authorization
# help-with-other
b
Using Vite and so on, I'm registering a Hangfire dashboard, which does work completely fine locally. But when using it on Umbraco Cloud I'm getting a 401. Here's the dashboard code:
Copy code
ts
import { LitElement, customElement, css, html } from '@umbraco-cms/backoffice/external/lit';

@customElement('hangfire-dashboard')
export class HangfireDashboard extends LitElement {
  render() {
    return html`
      <iframe name="hangfireIframe" class="hangfireContent" id="Hangfire" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0"
        src="/umbraco/backoffice/hangfire/" allowfullscreen="true"
        webkitallowfullscreen="true" mozallowfullscreen="true"
        oallowfullscreen msallowfullscreen="true">
      </iframe>
    `;
  }

  static styles = css`
    :host {
        display: block;
        padding: 24px;
        height: 94%;
    }

    .hangfireContent {
        min-width: 100% !important;
        min-height: 100% !important;
    }
  `
}

declare global {
  interface HTMLElementTagNameMap {
    'hangfire-dashboard': HangfireDashboard
  }
}
And this is my C# code:
Copy code
cs
// in a Compose method:
AddHangfireDashboard( builder );

private static void AddHangfireDashboard( IUmbracoBuilder builder ) {
  builder.Services.Configure<UmbracoPipelineOptions>( options => {
    options.AddFilter( new UmbracoPipelineFilter( HangfireConstants.HangfireDashboard ) {
      Endpoints = app => app.UseEndpoints( endpoints => {
        endpoints.MapHangfireDashboard(
            pattern: "/umbraco/backoffice/hangfire",
            options: new DashboardOptions() {
              // Authorization = [] // something here maybe?
            } );
      } ).UseHangfireDashboard()
    } );
  } );
}
I know that the default
IDashboardAuthorizationFilter
is
LocalRequestsOnlyAuthorizationFilter
, but I'm not sure which filter to use instead.
s
I've built this so you don't have to! https://marketplace.umbraco.com/package/cultiv.hangfire
And there's a link to the source code if you need the details.
b
I'll try to install it again, but I've had some issues on previous attempts.
s
Sorry, I see you said cloud! And are basically using my code.. don't try then
It doesn't yet work on cloud 😦
something to do with the UmbracoId authentication clashing.. and I am not clever enough to make it work 😢
b
That makes two of us. 😅
s
Is that just for v14? I have it running in v13 on Cloud, no problems
s
v14 broke it yeah
I need an OpenIddict specialist to tell me what's the problem! Can't remember exactly where I landed last time I tried, but from what I remember, I couldn't get the correct Claim out of UmbracoId so I have no idea what role the user is in. I'll dig up some info and create an issue for it so maybe I can get some help!
19 Views