Skip to content
Snippets Groups Projects
Commit 39c9f262 authored by EorlBruder's avatar EorlBruder
Browse files

Removed JWT-based-Login

- Updated README
parent 765f0621
No related branches found
No related tags found
No related merge requests found
......@@ -26,8 +26,8 @@ funkwhale --help
# get help on a specific command
funkwhale tracks ls --help
# get login
funkwhale -H https://demo.funkwhale.audio login # credentials are demo and demo on this server
# get login - You need to create an application in your Funkwhale-settings. Then you need to provide the client-id and the client-secret of that application here
funkwhale -H https://demo.funkwhale.audio login
# Store the server URL to avoid specifying it on the CLI
echo "FUNKWHALE_SERVER_URL=https://demo.funkwhale.audio" >> .env
......
......@@ -47,18 +47,6 @@ def clean_nodeinfo(data):
return result.data
async def get_jwt_token(session, url, username, password):
url = f"{url}/api/v1/token/"
response = await session.post(
url, data={"username": username, "password": password}
)
if response.status == 400:
raise exceptions.AuthenticationError(
"Unable to log in with provided credentials"
)
return (await response.json())["token"]
async def get_oauth_token(session, url, client_id, client_secret):
args = {"response_type": "code", "redirect_uri": "urn:ietf:wg:oauth:2.0:oob", "client_id": client_id,
"client_secret": client_secret, "scope": "read write"}
......
......@@ -67,34 +67,6 @@ def init_keyring():
# /end of hack
@base.cli.command()
@click.option("-u", "--username", envvar="FUNKWHALE_USERNAME", prompt=True)
@click.option(
"-p", "--password", envvar="FUNKWHALE_PASSWORD", prompt=True, hide_input=True
)
@click.pass_context
@base.async_command
async def login(ctx, username, password):
async with api.get_session() as session:
token = await api.get_jwt_token(
session, ctx.obj["SERVER_URL"], username=username, password=password
)
try:
keyring.set_password(ctx.obj["SERVER_URL"], "_", token)
except ValueError as e:
raise click.ClickException(
"Error while retrieving password from keyring: {}. Your password may be incorrect.".format(
e.args[0]
)
)
except Exception as e:
raise click.ClickException(
"Error while retrieving password from keyring: {}".format(e.args[0])
)
click.echo("Login successfull!")
@base.cli.command()
@click.option("-i", "--client-id", envvar="FUNKWHALE_CLIENT_ID", prompt=True)
@click.option(
......@@ -102,7 +74,7 @@ async def login(ctx, username, password):
)
@click.pass_context
@base.async_command
async def login_oauth(ctx, client_id, client_secret):
async def login(ctx, client_id, client_secret):
async with api.get_session() as session:
access_token, refresh_token = await api.get_oauth_token(
session, ctx.obj["SERVER_URL"], client_id=client_id, client_secret=client_secret
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment