mercredi 25 novembre 2020

Decoupling implementation from public API [closed]

Implementation 1

type DBAuthentication{ // talking to database
   field1 Type1
   field2 Type2 
}

func (d *DBAuthentication) f1(x str){
  // do something
}

func (d *DBAuthentication) f2(x, y int){
  // do something
}

Implementation 2

type LDAPAuthentication{ // talking to LDAP service
   field1 Type3
   field2 Type4 
}

func (d *LDAPAuthentication) g1(x []str){
  // do something
}

func (d *LDAPAuthentication) g2(x, y str){
  // do something
}

Implementation 3

type KeyStoreAuthentication{ // talking to keystore service
   field1 Type4
   field2 Type5 
}

func (d *KeyStoreAuthentication) h1(x float64){
  // do something
}

func (d *KeyStoreAuthentication) h2(y int){
  // do something
}

func (d *KeyStoreAuthentication) h3(z str){
  // do something
}

User provides credentials username/password to validate with above 3 implementations. Iterate these implementations and accept the credentials if any of the above 3 implementations validate successfully.

How should the public API Authenticate(username,password)de-couple from these three different implementations? user of the public API provides username/password

Aucun commentaire:

Enregistrer un commentaire