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

Add DummyProvider for quick password based auth #4684

Merged
merged 7 commits into from
Apr 25, 2023

Conversation

MridulS
Copy link
Contributor

@MridulS MridulS commented Apr 23, 2023

This hopefully gives a solution of quick password based authentication. No need to setup a full fledged OAuth app.

This fixes #2575 and also addresses https://discourse.holoviz.org/t/tips-guide-on-creating-a-simple-username-password-auth-for-panel-app/2582/13.

The PR adds 2 config options: --dummy-auth and --dummy-login-template. With --dummy-auth user can set the password and with --dummy-login-template they can override the default user login page (which I stole from https://github.com/bokeh/bokeh/tree/branch-3.2/examples/server/app/server_auth).

An example how to use this:

$ panel serve --dummy-auth "panel" --cookie-secret "SECRET" .......

This should open up something like:

Screenshot 2023-04-24 at 1 29 32 AM

I also changed couple of things in auth.py let me know if I should make another PR instead:

TODO:

  • Add to Authentication docs
  • Maybe add an example test for dummy auth?

@codecov
Copy link

codecov bot commented Apr 23, 2023

Codecov Report

Merging #4684 (a2c47ab) into main (e812632) will decrease coverage by 12.68%.
The diff coverage is 54.03%.

@@             Coverage Diff             @@
##             main    #4684       +/-   ##
===========================================
- Coverage   83.16%   70.49%   -12.68%     
===========================================
  Files         266      267        +1     
  Lines       37453    37531       +78     
===========================================
- Hits        31148    26456     -4692     
- Misses       6305    11075     +4770     
Flag Coverage Δ
ui-tests ?
unitexamples-tests 70.49% <54.03%> (-2.76%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
panel/auth.py 37.07% <24.00%> (-1.41%) ⬇️
panel/command/serve.py 38.61% <30.00%> (+0.14%) ⬆️
panel/tests/ui/test_auth.py 50.00% <50.00%> (ø)
panel/tests/util.py 82.65% <80.95%> (-9.16%) ⬇️
panel/config.py 68.62% <100.00%> (+0.43%) ⬆️
panel/io/resources.py 84.08% <100.00%> (+0.04%) ⬆️
panel/tests/command/test_serve.py 100.00% <100.00%> (+10.61%) ⬆️

... and 70 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@philippjfr
Copy link
Member

Love this, thanks @MridulS! Some docs would indeed be nice, on the naming side I think we can name this something like SimpleAuth. Some other thoughts:

  • Might be nice to allow the user to specify a json or yaml file with username: password pairs

Adding tests would also be nice, think the best way is probably just a UI/integration test (using playwright) that starts a server and then goes through the login flow.

@MarcSkovMadsen
Copy link
Collaborator

BasicAuth could be an alternative to SimpleAuth. In user forums people use the term "basic" rather than "simple" when searching for this type of auth.

@philippjfr
Copy link
Member

Renamed to BasicAuth, added docs and added a test.

@philippjfr philippjfr merged commit 179aa16 into holoviz:main Apr 25, 2023
@philippjfr
Copy link
Member

Thanks @MridulS!

@MridulS
Copy link
Contributor Author

MridulS commented Apr 25, 2023

Wohoo! Thanks @philippjfr

@cdeil
Copy link
Contributor

cdeil commented Apr 25, 2023

This is cool. Thanks!

Why does it not show up in the dev docs yet?
https://pyviz-dev.github.io/panel/how_to/authentication/index.html

@cdeil cdeil mentioned this pull request Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simple login/password auth example without oauth
4 participants