mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-22 03:24:18 +01:00
Blind authentication (#675)
* auth server * cleaning up * auth ledger class * class variables -> instance variables * annotations * add models and api route * custom amount and api prefix * add auth db * blind auth token working * jwt working * clean up * JWT works * using openid connect server * use oauth server with password flow * new realm * add keycloak docker * hopefully not garbage * auth works * auth kinda working * fix cli * auth works for send and receive * pass auth_db to Wallet * auth in info * refactor * fix supported * cache mint info * fix settings and endpoints * add description to .env.example * track changes for openid connect client * store mint in db * store credentials * clean up v1_api.py * load mint info into auth wallet * fix first login * authenticate if refresh token fails * clear auth also middleware * use regex * add cli command * pw works * persist keyset amounts * add errors.py * do not start auth server if disabled in config * upadte poetry * disvoery url * fix test * support device code flow * adopt latest spec changes * fix code flow * mint max bat dynamic * mypy ignore * fix test * do not serialize amount in authproof * all auth flows working * fix tests * submodule * refactor * test * dont sleep * test * add wallet auth tests * test differently * test only keycloak for now * fix creds * daemon * fix test * install everything * install jinja * delete wallet for every test * auth: use global rate limiter * test auth rate limit * keycloak hostname * move keycloak test data * reactivate all tests * add readme * load proofs * remove unused code * remove unused code * implement change suggestions by ok300 * add error codes * test errors
This commit is contained in:
@@ -18,6 +18,7 @@ class NotAllowedError(CashuError):
|
||||
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
||||
super().__init__(detail or self.detail, code=code or self.code)
|
||||
|
||||
|
||||
class OutputsAlreadySignedError(CashuError):
|
||||
detail = "outputs have already been signed before."
|
||||
code = 10002
|
||||
@@ -25,6 +26,7 @@ class OutputsAlreadySignedError(CashuError):
|
||||
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
||||
super().__init__(detail or self.detail, code=code or self.code)
|
||||
|
||||
|
||||
class InvalidProofsError(CashuError):
|
||||
detail = "proofs could not be verified"
|
||||
code = 10003
|
||||
@@ -32,6 +34,7 @@ class InvalidProofsError(CashuError):
|
||||
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
||||
super().__init__(detail or self.detail, code=code or self.code)
|
||||
|
||||
|
||||
class TransactionError(CashuError):
|
||||
detail = "transaction error"
|
||||
code = 11000
|
||||
@@ -76,12 +79,14 @@ class TransactionUnitError(TransactionError):
|
||||
def __init__(self, detail):
|
||||
super().__init__(detail, code=self.code)
|
||||
|
||||
|
||||
class TransactionAmountExceedsLimitError(TransactionError):
|
||||
code = 11006
|
||||
|
||||
def __init__(self, detail):
|
||||
super().__init__(detail, code=self.code)
|
||||
|
||||
|
||||
class KeysetError(CashuError):
|
||||
detail = "keyset error"
|
||||
code = 12000
|
||||
@@ -113,7 +118,7 @@ class QuoteNotPaidError(CashuError):
|
||||
code = 20001
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=2001)
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class QuoteSignatureInvalidError(CashuError):
|
||||
@@ -121,7 +126,7 @@ class QuoteSignatureInvalidError(CashuError):
|
||||
code = 20008
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=20008)
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class QuoteRequiresPubkeyError(CashuError):
|
||||
@@ -129,4 +134,52 @@ class QuoteRequiresPubkeyError(CashuError):
|
||||
code = 20009
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=20009)
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class ClearAuthRequiredError(CashuError):
|
||||
detail = "Endpoint requires clear auth"
|
||||
code = 80001
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class ClearAuthFailedError(CashuError):
|
||||
detail = "Clear authentication failed"
|
||||
code = 80002
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class BlindAuthRequiredError(CashuError):
|
||||
detail = "Endpoint requires blind auth"
|
||||
code = 81001
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class BlindAuthFailedError(CashuError):
|
||||
detail = "Blind authentication failed"
|
||||
code = 81002
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
|
||||
class BlindAuthAmountExceededError(CashuError):
|
||||
detail = "Maximum blind auth amount exceeded"
|
||||
code = 81003
|
||||
|
||||
def __init__(self, detail: Optional[str] = None):
|
||||
super().__init__(detail or self.detail, code=self.code)
|
||||
|
||||
|
||||
class BlindAuthRateLimitExceededError(CashuError):
|
||||
detail = "Blind auth token mint rate limit exceeded"
|
||||
code = 81004
|
||||
|
||||
def __init__(self):
|
||||
super().__init__(self.detail, code=self.code)
|
||||
|
||||
Reference in New Issue
Block a user