#NEWLINE# def sign_request( key , http_method , path , body , host , timestamp , user_id ) : #NEWLINE# #INDENT# 'Generate the needed headers for the Opscode authentication protocol.' #NEWLINE# timestamp = canonical_time ( timestamp ) #NEWLINE# hashed_body = sha1_base64 ( ( body or '' ) ) #NEWLINE# headers = { #NEWLINE# #INDENT# 'x-ops-sign' : 'version=1.0' , #NEWLINE# 'x-ops-userid' : user_id , #NEWLINE# 'x-ops-timestamp' : timestamp , #NEWLINE# 'x-ops-content-hash' : hashed_body , #NEWLINE# #UNINDENT# } #NEWLINE# req = canonical_request ( http_method , path , body , timestamp , user_id ) #NEWLINE# sig = _ruby_b64encode ( key . private_encrypt ( req ) ) #NEWLINE# for ( i , line ) in enumerate ( sig ) : #NEWLINE# #INDENT# headers [ ( 'x-ops-authorization-%s' % ( i + 1 ) ) ] = line #NEWLINE# #UNINDENT# return headers