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

Blind authentication #675

Merged
merged 84 commits into from
Jan 30, 2025
Merged

Blind authentication #675

merged 84 commits into from
Jan 30, 2025

Conversation

callebtc
Copy link
Collaborator

@callebtc callebtc commented Nov 19, 2024

Implements clear and blind authentication NUT cashubtc/nuts#198 with keycloak (docker-compose provided)

@callebtc callebtc marked this pull request as ready for review January 27, 2025 19:47
@callebtc callebtc changed the title WIP: Blind authentication Blind authentication Jan 27, 2025
# - Add the client ID "cashu-client"
# - Enable the ES256 and RS256 algorithms for this client
# - If you want to use the authorization flow, you must add the redirect URI "http://localhost:33388/callback".
# - To support other wallets, use the well-known list of allowed redirect URIs here: https://...TODO.md
Copy link
Contributor

@ok300 ok300 Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... use the well-known list of allowed redirect URIs here https://...TODO.md

Looks like an unaddressed TODO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we will have the link only when we merge the corresponding NUT: cashubtc/nuts#198

) -> List[MeltQuote]:
rows = await (conn or db).fetchall(
f"""
SELECT * from {db.table_with_schema('melt_quotes')} WHERE quote in (SELECT DISTINCT melt_quote FROM {db.table_with_schema('proofs_pending')})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SELECT * from {db.table_with_schema('melt_quotes')} WHERE quote in (SELECT DISTINCT melt_quote FROM {db.table_with_schema('proofs_pending')})
SELECT * from {db.table_with_schema('melt_quotes')}
WHERE quote in (
SELECT DISTINCT melt_quote FROM {db.table_with_schema('proofs_pending')}
)

NIT: formatting to make it easier to read

secret TEXT NOT NULL,
y TEXT NOT NULL,
witness TEXT,
created TIMESTAMP,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created should be NOT NULL?

)
async def keys():
"""This endpoint returns a dictionary of all supported token values of the mint and their associated public key."""
logger.trace("> GET /v1/keys")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.trace("> GET /v1/keys")
logger.trace("> GET /v1/auth/blind/keys")

Comment on lines 59 to 65
# BEGIN BACKWARDS COMPATIBILITY < 0.15.0
# if keyset_id is not hex, we assume it is base64 and sanitize it
try:
int(keyset_id, 16)
except ValueError:
keyset_id = keyset_id.replace("-", "+").replace("_", "/")
# END BACKWARDS COMPATIBILITY < 0.15.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO can be removed, as there is no previous nutshell or API version that supported auth, with which we want to keep backward compatibility.

@ok300
Copy link
Contributor

ok300 commented Jan 29, 2025

ACK.

Added a few NITs and comments (see above), but otherwise LGTM.

Also ran a few tests with the provided Keycloak test data, looked good.

@callebtc callebtc merged commit a0ef44d into main Jan 30, 2025
22 checks passed
@callebtc callebtc deleted the auth-server branch January 30, 2025 04:48
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.

2 participants