-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
[FEAT] Auth, Login, OAuth, create account with username and password #1653 #2092
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
lnbits/core/views/user_api.py
Outdated
) | ||
from ..models import CreateUser, LoginUser | ||
|
||
user_router = APIRouter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would be nice to add more openapi documentation to APIRouter
and the corresponding user_router
routes
0ca0dba
to
07d399c
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev #2092 +/- ##
==========================================
- Coverage 60.45% 59.39% -1.06%
==========================================
Files 58 59 +1
Lines 8464 8832 +368
==========================================
+ Hits 5117 5246 +129
- Misses 3347 3586 +239 ☔ View full report in Codecov by Sentry. |
293eab3
to
478e67e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
918184b
to
7cd55ff
Compare
47e9643
to
d73fc0c
Compare
Question: @motorina0 When
|
|
lnbits/helpers.py
Outdated
|
||
|
||
def is_valid_username(username: str) -> bool: | ||
username_regex = r"\b(?=[a-zA-Z0-9._]{2,20}$)(?!.*[_.]{2})[^_.].*[^_.]\b" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am clueless. Where does this come from and why is it so complicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adapted from here: https://stackoverflow.com/questions/12018245/regular-expression-to-validate-username
- allowed characters: a-zA-Z0-9._
- username is 2-20 characters long
- no __ or _. or ._ or .. inside
- no _ or . at the beginning
- no _ or . at the end
8f9948e
to
e4e36d4
Compare
wip wip wip update deps revert tests formatting bundle refactor into new init fix latest fastapi issue fixup, working again bundle no more superuser url! delete cookie on logout add usr login feature remove unused tests fix node management bundle
overrides for fastapi-sso, types-passlib, types-pyasn1, types-python-jose were upstreamed in nix-community/poetry2nix#1463
Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
b693a1d
to
7cbdee1
Compare
Summary
Add login functionality. Supported methods:
user-id-only
usr
(user id) from the url params is automatically removedusername-password
google-auth
- use google SSOgithub-auth
- use github SSOThe auth fields are documented in
.env.example
.Based on the
AUTH_ALLOWED_METHODS
different Login/Register options will be available to the end user.Login Page (all options)
Login Page (no
usr
allowed)Google SSO:
https://github.com/lnbits/lnbits/assets/2951406/5f7ce5a7-7a9a-479b-b948-71c5cfbb39d4
On the Account Settings page the user can verify its email address via SSO (google and github at the moment).
Test Scenarios
Scenario 1 (backwards compatibility)
usr
in URL query paramsLogin with user ID
Create New Wallet
Scenario 2
Scenario 3
Scenario 4
Scenario 5 (Account Settings page)
username
(username cannot be updated)Scenario 6 (Change password)
Account Settings
clickChange Password
Scenario 7 (add email)
usr
orRegister
flow has no emailAccount Settings
Scenario 8 (token expire)
AUTH_TOKEN_EXPIRE_MINUTES
Dependencies
itsdangerous
is required byfrom starlette.middleware.sessions import SessionMiddleware
Notes
Stuff that is still open but the PR can be reviewed without: