Coder Social home page Coder Social logo

Comments (8)

joestump avatar joestump commented on September 15, 2024

If you point me in the right direction, I'll take a look at submitting a PR.

from wg-portal.

bonddim avatar bonddim commented on September 15, 2024

Suppose, there is no toggle because user is synced from external provider, in your case Authentik.
Try to use is_admin property in oauth/oidc config.
But there is also bug - once user is created, permissions aren't updated on next login sync.

from wg-portal.

joestump avatar joestump commented on September 15, 2024

@bonddim I gave that a shot, but it's not working (I'm deleting the user in between sign ins; should be fresh is_admin on each login).

auth:
  callback_url_prefix: https://<my-url>/api/v0
  oidc:
    - id: authentik
      provider_name: authentik
      display_name: Login with Authentik
      base_url: https://<my-authentik-url>/application/o/wireguard-portal/
      client_id: my-client-id
      client_secret: my-super-secret-client-secret
      extra_scopes:
        - profile
        - email
        - is_admin
      field_map:
        email: email
        user_identifier: email
      registration_enabled: true

I then have a Property Mapping with the scope is_admin in my Authentik:

return str(ak_is_group_member(request.user, name="Administrators")).lower()

Here's the test output:

image

Not quite sure where I went wrong. For now I'll manually update in the DB.

from wg-portal.

joestump avatar joestump commented on September 15, 2024

Gave it a shot with oauth and it leads to a 404 when I click the login button: https://<my-wgportal-url>/api/v0/api/v0/authentik-oauth/init. When I correct the double URI issue, it still 404s.

from wg-portal.

bonddim avatar bonddim commented on September 15, 2024

@joestump ,
try to add is_admin: "true" into field_map

from wg-portal.

joestump avatar joestump commented on September 15, 2024

@bonddim if I'm following the code correctly, that would result in true being used for the field mapping? getOauthFieldMapping would set true as the key for looking up in ParseUserInfo? Authentik doesn't appear to set admin_flag by default and my extra scopes hack didn't work either.

from wg-portal.

bonddim avatar bonddim commented on September 15, 2024

@joestump,
Correct, wg-portal expects value parsable to boolean to set admin permissions.

By providing is_admin: in field_map you set to which property in token scope to look for admin role.
If your authentick adds extra scope is_admin: true, it should work with

....
field_map:
  is_admin: is_admin
  ...

from wg-portal.

h44z avatar h44z commented on September 15, 2024

@joestump did you manage to get it working?

from wg-portal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.