<s> """<STR_LIT>""" <EOL> from eve import Eve <EOL> from eve . auth import BasicAuth <EOL> from werkzeug . security import check_password_hash <EOL> class RolesAuth ( BasicAuth ) : <EOL> def check_auth ( self , username , password , allowed_roles ) : <EOL> accounts = app . data . driver . db [ '<STR_LIT>' ] <EOL> lookup = { '<STR_LIT:username>' : username } <EOL> if allowed_roles : <EOL> lookup [ '<STR_LIT>' ] = { '<STR_LIT>' : allowed_roles } <EOL> account = accounts . find_one ( lookup ) <EOL> return account and check_password_hash ( account [ '<STR_LIT:password>' ] , password ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app = Eve ( auth = RolesAuth ) <EOL> app . run ( ) </s>
