How to use /admin-ui, admin role required

Hi,
we have our own auth2 provider that handles security.
I have added

AdminAuthSecret = "secretz",

http://localhost:58999/admin-ui/?provider=authsecret

And when i login with this i get

Admin role required

How can i get the correct role for this?

i

Looks like you’re signed in as another user, the AdminAuthSecret enables the Admin user which you’d need to Sign In with the built-in SignIn dialog using the AuthSecret.

I get this response when signing in with secretz on /admin-ui

{
  "UserId": "0",
  "SessionId": "d5e7592e890e497797f4e3c563c1bd5f",
  "UserName": "authsecret",
  "DisplayName": "Admin",
  "ReferrerUrl": "http://localhost:58999/admin-ui/?provider=authsecret",
  "ProfileUrl": "data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3E .path%7B%7D %3C/style%3E%3Cg id='male-svg'%3E%3Cpath fill='%23556080' d='M1 92.84V84.14C1 84.14 2.38 78.81 8.81 77.16C8.81 77.16 19.16 73.37 27.26 69.85C31.46 68.02 32.36 66.93 36.59 65.06C36.59 65.06 37.03 62.9 36.87 61.6H40.18C40.18 61.6 40.93 62.05 40.18 56.94C40.18 56.94 35.63 55.78 35.45 47.66C35.45 47.66 32.41 48.68 32.22 43.76C32.1 40.42 29.52 37.52 33.23 35.12L31.35 30.02C31.35 30.02 28.08 9.51 38.95 12.54C34.36 7.06 64.93 1.59 66.91 18.96C66.91 18.96 68.33 28.35 66.91 34.77C66.91 34.77 71.38 34.25 68.39 42.84C68.39 42.84 66.75 49.01 64.23 47.62C64.23 47.62 64.65 55.43 60.68 56.76C60.68 56.76 60.96 60.92 60.96 61.2L64.74 61.76C64.74 61.76 64.17 65.16 64.84 65.54C64.84 65.54 69.32 68.61 74.66 69.98C84.96 72.62 97.96 77.16 97.96 81.13C97.96 81.13 99 86.42 99 92.85L1 92.84Z'/%3E%3C/g%3E%3C/svg%3E",
  "Roles": [
    "Admin",
    "bookingsupplier-administrator-write",
    "superadmin",
    "bookingsupplier-administrator-read",
  ],
  "Permissions": []
}

What role do i need to add in the array as this is the roles from my oauth2 provider

The Admin role should be all that you need, does the built-in /auth page show that you have the Admin role?

Not sure where you saw ?provider=authsecret from but to make an authenticated request with the AdminAuthSecret you would instead use ?authsecret=secretz

If i go to /auth i get this login form

If i go to /admin-ui i get this and there i select Auth Secret and add the Auth Secret secretz


Then i get

Not sure, it should work by default, I’m assuming there’s some conflict with your custom Auth Provider, you can try removing it and just try signing in with the AdminAuthSecret to see if it’s causing it.

Can you also share what the /admin-ui thinks you’re signed in as by running this in the WebInspector console:

JSON.stringify(window.AUTH)

It gives me this

{"UserId":"0","SessionId":"756b3ec83fd74085a805ace42e19cb10","UserName":"authsecret","DisplayName":"Admin","ReferrerUrl":"http://localhost:58999/admin-ui/?provider=authsecret","ProfileUrl":"data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cstyle%3E .path%7B%7D %3C/style%3E%3Cg id='male-svg'%3E%3Cpath fill='%23556080' d='M1 92.84V84.14C1 84.14 2.38 78.81 8.81 77.16C8.81 77.16 19.16 73.37 27.26 69.85C31.46 68.02 32.36 66.93 36.59 65.06C36.59 65.06 37.03 62.9 36.87 61.6H40.18C40.18 61.6 40.93 62.05 40.18 56.94C40.18 56.94 35.63 55.78 35.45 47.66C35.45 47.66 32.41 48.68 32.22 43.76C32.1 40.42 29.52 37.52 33.23 35.12L31.35 30.02C31.35 30.02 28.08 9.51 38.95 12.54C34.36 7.06 64.93 1.59 66.91 18.96C66.91 18.96 68.33 28.35 66.91 34.77C66.91 34.77 71.38 34.25 68.39 42.84C68.39 42.84 66.75 49.01 64.23 47.62C64.23 47.62 64.65 55.43 60.68 56.76C60.68 56.76 60.96 60.92 60.96 61.2L64.74 61.76C64.74 61.76 64.17 65.16 64.84 65.54C64.84 65.54 69.32 68.61 74.66 69.98C84.96 72.62 97.96 77.16 97.96 81.13C97.96 81.13 99 86.42 99 92.85L1 92.84Z'/%3E%3C/g%3E%3C/svg%3E","Roles":["Admin","bookingsupplier-administrator-write","superadmin","bookingsupplier-administrator-read"],"Permissions":[]}`

I do get this

Metadata not found for: Authenticate
in the console

Could be because i removed them from

        //Remove authenticate endpoint and roles 
        typeof(Authenticate)
            .AddAttributes(new ExcludeMetadataAttribute());
        authFeature.IncludeAssignRoleServices = false;

But didnt help to delete that code, still the same even if the message dissapeared

Strange, it says you have the Admin role so you should be able to access it.

It might be due to another issue like this, are you using the latest ServiceStack v6.10?

Yes latest version of servicestack v6.10

ok not sure then, if you can put a minimal stand-alone repro on GitHub I can take a look.

Hi, have added an example project which you have access to here

https://github.com/bokamera/test-project

Can you ensure this project works stand-alone without any custom nuget feeds, i.e. it’s unable to find these packages:

<PackageReference Include="BokaMera.CodeLock.Model" Version="0.1.45" />
<PackageReference Include="BokaMera.Message.Service.Clients" Version="0.1.84" />

Source code in source control shouldn’t include binaries, the solution should just be able to restore its packages dependencies from public NuGet feeds then run.

Yes it runs without those packages, i just forgot to remove those when creating the example project. Pushed the changes now without the packages

Hi, Did you get a chance to look on the project again?

This was due to using PascalCase which should be resolved from the latest v6.10.1+ that’s now available in our pre-release packages.

1 Like