It looks like the implementation doesn’t exactly match the comment — should 
probably open a ticket. But, this works:

#!/usr/bin/env python3

import hashlib
import base64
import time
import requests as req

password = 'password'

millis = int(round(time.time() * 1000))
param = f'{millis}:{password}'
hash_pass = hashlib.sha1(param.encode('utf-8')).digest()
str_pass = base64.b64encode(hash_pass).decode('utf-8')

headers = { 'X-Signature' : f'{millis}:{str_pass}' }
resp = req.get('http://localhost:8080/ignite?cmd=version', headers=headers)

print (resp.text)

Basically, you pass in a X-Signature header with a string in the format “x:y”.

X = the time in ms
Y = base64 ( sha1 ( “x:secretkey" ) )

Yes, you include the time and use the time as part of the hash. For this (and 
other reasons) I’m not sure that this is a good mechanism. If you want to 
secure it, use TLS, add authentication.

Regards,
Stephen

> On 7 Sep 2021, at 12:44, satyajit.man...@barclays.com wrote:
> 
> Hi  Team,
>  
> Can  someone  please  suggest  here.  There  is  no  example  how  to  call a 
>  rest  url  with  secret  key as per  below  documentation.
>  
> setSecretKey(String)
> Defines secret key used for client authentication. When provided, client 
> request must contain HTTP header X-Signature with the string "[1]:[2]", where 
> [1] is timestamp in milliseconds and [2] is the Base64 encoded SHA1 hash of 
> the secret key.
>  
>  
> Thanks
> Satyajit
>  
>  
> Restricted - External
> From: Mandal, Satyajit: IT (PUN) 
> Sent: Friday, September 3, 2021 3:41 PM
> To: 'user' <user@ignite.apache.org>
> Subject: Calling Ignite Rest endpoint using secret key 
>  
> Hi  Team,
>  
> Can  someone  provide  example  how  we  can  invoke Ignite  Rest  Endpoint  
> using  encoded  secret  key  in  header.  There  is  not  much  example .  
> Any  sample  will  help which  is  working.
>  
>  
> https://ignite.apache.org/docs/latest/restapi 
> <https://ignite.apache.org/docs/latest/restapi>
>  
> 
>  
> 
>  
>  
> <property name="connectorConfiguration">
>                      <bean 
> class="org.apache.ignite.configuration.ConnectorConfiguration">
>                            <property name="SecretKey" 
> value="these.signatures"/>
>                      </bean>
>               </property>
> 
>  
>  
>  
> setSecretKey(String)
> Defines secret key used for client authentication. When provided, client 
> request must contain HTTP header X-Signature with the string "[1]:[2]", where 
> [1] is timestamp in milliseconds and [2] is the Base64 encoded SHA1 hash of 
> the secret key.
> Thanks
> 
> Satyajit
> 
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> “This message is for information purposes only, it is not a recommendation, 
> advice, offer or solicitation to buy or sell a product or service nor an 
> official confirmation of any transaction. It is directed at persons who are 
> professionals and is not intended for retail customer use. Intended for 
> recipient only. This message is subject to the terms at: 
> www.barclays.com/emaildisclaimer <http://www.barclays.com/emaildisclaimer>.
> 
> For important disclosures, please see: 
> www.barclays.com/salesandtradingdisclaimer 
> <http://www.barclays.com/salesandtradingdisclaimer> regarding market 
> commentary from Barclays Sales and/or Trading, who are active market 
> participants; 
> https://www.investmentbank.barclays.com/disclosures/barclays-global-markets-disclosures.html
>  
> <https://www.investmentbank.barclays.com/disclosures/barclays-global-markets-disclosures.html>
>  regarding our standard terms for the Investment Bank of Barclays where we 
> trade with you in principal-to-principal wholesale markets transactions; and 
> in respect of Barclays Research, including disclosures relating to specific 
> issuers, please see http://publicresearch.barclays.com 
> <http://publicresearch.barclays.com/>.”  
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> If you are incorporated or operating in Australia, please see 
> https://www.home.barclays/disclosures/importantapacdisclosures.html 
> <https://www.home.barclays/disclosures/importantapacdisclosures.html>for 
> important disclosure.
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> How we use personal information  see our privacy notice 
> https://www.investmentbank.barclays.com/disclosures/personalinformationuse.html
>  
> <https://www.investmentbank.barclays.com/disclosures/personalinformationuse.html>
>  
> _________________________________________________________________________________________________________________________________________________________________________________________________________________________________
> 


Reply via email to