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

[PUI] Login silently fails with MFA enabled #8595

Closed
2 of 6 tasks
sur5r opened this issue Nov 29, 2024 · 7 comments · Fixed by #8600
Closed
2 of 6 tasks

[PUI] Login silently fails with MFA enabled #8595

sur5r opened this issue Nov 29, 2024 · 7 comments · Fixed by #8600
Assignees
Labels
bug Identifies a bug which needs to be addressed Platform UI Related to the React based User Interface
Milestone

Comments

@sur5r
Copy link
Contributor

sur5r commented Nov 29, 2024

Please verify that this bug has NOT been raised before.

  • I checked and didn't find a similar issue

Describe the bug*

In inventree/inventree-brother-plugin#49 @matmair said that PUI is supposed to redirect to PUI during login when a user has MFA enabled. Unfortunately, this does not work for me.

The POST request to /api/auth/login made by PUI results in 403 with

{"detail":"MFA required for this user"}

Also, the Console in WebDevTools spits this:

Uncaught (in promise) TypeError: r.hasOwn is not a function
    de                  https://inventree.domain.tld/static/web/assets/index-B0j1uz07.js:3
    e                   https://inventree.domain.tld/static/web/assets/index-B0j1uz07.js:3
    promise callback*$e https://inventree.domain.tld/static/web/assets/index-B0j1uz07.js:3
    c                   https://inventree.domain.tld/static/web/assets/Login-34CefvDW.js:1
    eR                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    nR                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    rR                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    Lg                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    lS                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    If                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    c0                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:62
    Tb                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    If                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    jm                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
    wR                  https://inventree.domain.tld/static/web/assets/vendor-50JW9u3H.js:59
[index-B0j1uz07.js:3:5055](https://inventree.domain.tld/static/web/assets/index-B0j1uz07.js)

Assuming this is as helpful to you as it is to me, I disabled obfuscation in vite.config.ts which turns it to

Uncaught (in promise) TypeError: params.hasOwn is not a function
    post                          https://inventree.domain.tld/static/web/assets/index-D1HeuvK-.js:791
    doBasicLogin                  https://inventree.domain.tld/static/web/assets/index-D1HeuvK-.js:832
    promise callback*doBasicLogin https://inventree.domain.tld/static/web/assets/index-D1HeuvK-.js:829
    handleLogin                   https://inventree.domain.tld/static/web/assets/Login-D6W4F6wJ.js:99
    Nb                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:7195
    Tb                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:7207
    Ub                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:7210
    nf                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8147
    se                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8170
    hd                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8442
    Qk                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:11746
    Jb                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:7148
    hd                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8243
    fd                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:7641
    ed                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:7624
    addEventListener eval:4
    pf                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8213
    qf                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8186
    sf                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8193
    sf                            https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:8192
    createRoot                    https://inventree.domain.tld/static/web/assets/vendor-givYlcs0.js:12867
    <anonymous>                   https://inventree.domain.tld/static/web/assets/index-D1HeuvK-.js:1344

I hope this helps.

Steps to Reproduce

  1. Open a private browser window
  2. Go to /platform
  3. Try and log in with an account that has MFA enabled
  4. Observe an eternal spinning circle and nothing else

Expected behaviour

After clicking "Log in", get redirected to CUI to complete MFA authentication.

Deployment Method

  • Docker
  • Package
  • Bare metal
  • Other - added info in Steps to Reproduce

Version Information

Version Information:

InvenTree-Version: 0.17.0 dev
Django Version: 4.2.16
Commit Hash: 327884c
Commit Date: 2024-11-29
Commit Branch: master
Database: postgresql
Debug-Mode: False
Deployed using Docker: False
Platform: Linux-6.1.0-13-cloud-amd64-x86_64-with-glibc2.36
Installer: GIT

Active plugins: [{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.1.0'}, {'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'}, {'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'}, {'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.1.0'}, {'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'}, {'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'}, {'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'}, {'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'}, {'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'}, {'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'}, {'name': 'Brother Labels', 'slug': 'brother', 'version': '1.0.0'}]

Please verify if you can reproduce this bug on the demo site.

  • I can reproduce this bug on the demo site.

Relevant log output

@sur5r sur5r added bug Identifies a bug which needs to be addressed question This is a question triage:not-checked Item was not checked by the core team labels Nov 29, 2024
@SchrodingersGat SchrodingersGat added the Platform UI Related to the React based User Interface label Nov 30, 2024
@SchrodingersGat
Copy link
Member

SchrodingersGat commented Nov 30, 2024

@matmair this is the only instance of hasOwn in the code:

Image

which was recently changed (in #8317)

Image

@SchrodingersGat SchrodingersGat added this to the 0.17.0 milestone Nov 30, 2024
@SchrodingersGat SchrodingersGat removed the triage:not-checked Item was not checked by the core team label Nov 30, 2024
@matmair matmair removed the question This is a question label Nov 30, 2024
@matmair matmair self-assigned this Nov 30, 2024
@sur5r
Copy link
Contributor Author

sur5r commented Nov 30, 2024

I just reverted that line and it solves the issue.

It now behaves as follows:

  1. For short moment, a popup appears in the lower right corner stating "Login failed"
  2. Redirect to CUI with MFA prompt
  3. Redirect to PUI

@SchrodingersGat
Copy link
Member

@sur5r thanks for the feedback.

From here: https://stackoverflow.com/questions/69561596/object-hasown-vs-object-prototype-hasownproperty

Object.hasOwn() is intended as a replacement for Object.hasOwnProperty() and is a new method available to use (yet still not fully supported by all browsers like safari yet but soon will be)

Are you using Safari?

SchrodingersGat added a commit to SchrodingersGat/InvenTree that referenced this issue Nov 30, 2024
- Also add null check on function call
- Closes inventree#8595
@sur5r
Copy link
Contributor Author

sur5r commented Nov 30, 2024

No, I'm on Firefox 133.

SchrodingersGat added a commit that referenced this issue Nov 30, 2024
- Also add null check on function call
- Closes #8595
@sur5r
Copy link
Contributor Author

sur5r commented Nov 30, 2024

Thanks! Tried it here and it works now.

@SchrodingersGat
Copy link
Member

Awesome, thanks for letting me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies a bug which needs to be addressed Platform UI Related to the React based User Interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants