Delete some things we don't need anymore

This commit is contained in:
Daniel Krol 2022-06-07 18:15:46 -04:00
parent 0bf11b059c
commit 41721a8f70
7 changed files with 8 additions and 80 deletions

View file

@ -18,12 +18,9 @@ type Email string
type DeviceId string
type Password string
type AuthTokenString string
type DownloadKey string
type AuthScope string
const ScopeFull = AuthScope("*")
const ScopeGetWalletState = AuthScope("get-wallet-state")
// For test stubs
type AuthInterface interface {
@ -64,20 +61,10 @@ func (a *Auth) NewToken(userId UserId, deviceId DeviceId, scope AuthScope) (*Aut
// NOTE - not stubbing methods of structs like this. more convoluted than it's worth right now
func (at *AuthToken) ScopeValid(required AuthScope) bool {
// So far the only two scopes issued
if at.Scope == ScopeFull {
return true
}
if at.Scope == ScopeGetWalletState && required == ScopeGetWalletState {
return true
}
return false
}
func (d DownloadKey) Obfuscate() string {
// TODO KDF instead
hash := sha256.Sum256([]byte(d))
return hex.EncodeToString(hash[:])
// So far the only scope issued. Used to have more, didn't want to delete
// this feature yet in case we add more again. We'll delete it if it's of
// no use and ends up complicating anything.
return at.Scope == ScopeFull
}
func (p Password) Obfuscate() string {

View file

@ -6,13 +6,6 @@ import (
// Test stubs for now
func TestAuthSignaturePass(t *testing.T) {
t.Fatalf("Test me: Valid siganture passes")
}
func TestAuthSignatureFail(t *testing.T) {
t.Fatalf("Test me: Valid siganture fails")
}
func TestAuthNewTokenSuccess(t *testing.T) {
t.Fatalf("Test me: New token passes. Different scopes etc.")
@ -24,19 +17,8 @@ func TestAuthNewTokenFail(t *testing.T) {
func TestAuthScopeValid(t *testing.T) {
t.Fatalf("Test me: Scope Valid tests")
/*
authToken.Scope = "get-wallet-state"; authToken.ScopeValid("*")
authToken.Scope = "get-wallet-state"; authToken.ScopeValid("get-wallet-state")
// even things that haven't been defined yet, for simplicity
authToken.Scope = "bananas"; authToken.ScopeValid("*")
*/
}
func TestAuthScopeInvalid(t *testing.T) {
t.Fatalf("Test me: Scope Invalid tests")
/*
authToken.Scope = "get-wallet-state"; authToken.ScopeValid("bananas")
authToken.Scope = "bananas"; authToken.ScopeValid("get-wallet-state")
*/
}

View file

@ -22,18 +22,6 @@ func (r *AuthFullRequest) validate() bool {
r.Password != auth.Password(""))
}
type AuthForGetWalletStateRequest struct {
Email auth.Email `json:"email"`
DownloadKey auth.DownloadKey `json:"downloadKey"`
DeviceId auth.DeviceId `json:"deviceId"`
}
func (r *AuthForGetWalletStateRequest) validate() bool {
return (r.Email != "" &&
r.DownloadKey != auth.DownloadKey("") &&
r.DeviceId != "")
}
func (s *Server) getAuthTokenFull(w http.ResponseWriter, req *http.Request) {
var authRequest AuthFullRequest
if !getPostData(w, req, &authRequest) {

View file

@ -157,14 +157,3 @@ func TestServerValidateAuthFullRequest(t *testing.T) {
t.Fatalf("Test me: Implement and test AuthFullRequest.validate()")
}
func TestServerValidateAuthForGetWalletStateRequest(t *testing.T) {
t.Fatalf("Test me: Implement and test AuthForGetWalletStateRequest.validate()")
}
func TestServerAuthHandlerForGetWalletStateSuccess(t *testing.T) {
t.Fatalf("Test me: getAuthTokenForGetWalletState success")
}
func TestServerAuthHandlerForGetWalletStateErrors(t *testing.T) {
t.Fatalf("Test me: getAuthTokenForGetWalletState failure")
}

View file

@ -67,7 +67,7 @@ func (s *Server) getWalletState(w http.ResponseWriter, req *http.Request) {
return
}
authToken := s.checkAuth(w, token, auth.ScopeGetWalletState)
authToken := s.checkAuth(w, token, auth.ScopeFull)
if authToken == nil {
return

View file

@ -204,9 +204,9 @@ func (s *Store) SaveToken(token *auth.AuthToken) (err error) {
return
}
/////////////////////////////////
// Wallet State / Download Key //
/////////////////////////////////
//////////////////
// Wallet State //
//////////////////
func (s *Store) GetWalletState(userId auth.UserId) (walletStateJson string, hmac wallet.WalletStateHmac, err error) {
rows, err := s.db.Query(

View file

@ -4,7 +4,6 @@ from pprint import pprint
BASE_URL = 'http://localhost:8090'
AUTH_FULL_URL = BASE_URL + '/auth/full'
AUTH_GET_WALLET_STATE_URL = BASE_URL + '/auth/get-wallet-state'
REGISTER_URL = BASE_URL + '/signup'
WALLET_STATE_URL = BASE_URL + '/wallet-state'
@ -98,23 +97,6 @@ class Client():
return
print ("Registered")
def get_download_auth_token(self, email, password):
body = json.dumps({
'email': email,
'password': create_login_password(password),
'deviceId': self.device_id,
})
response = requests.post(AUTH_GET_WALLET_STATE_URL, body)
if response.status_code != 200:
print ('Error', response.status_code)
print (response.content)
return
self.auth_token = json.loads(response.content)['token']
print ("Got auth token: ", self.auth_token)
self.email = email
self.root_password = root_password
# TODO - Rename to get_auth_token. same in go. Remember to grep, gotta change
# it in README as well.
def get_full_auth_token(self):