Commit 5cd18d0 1 parent 41f6e3c commit 5cd18d0 Copy full SHA for 5cd18d0
File tree 3 files changed +52
-3
lines changed
3 files changed +52
-3
lines changed Original file line number Diff line number Diff line change 38
38
with_items :
39
39
- { source: 'templates/condor_config', dest: '/etc/condor/condor_config' }
40
40
- { source: 'templates/get_proxy.py', dest: '/home/censtos/get_proxy.py' }
41
+ - { source: 'templates/get_proxy.sh', dest: '/home/censtos/get_proxy.sh' }
41
42
42
43
- name : copy job example
43
44
become : yes
Original file line number Diff line number Diff line change @@ -290,14 +290,16 @@ def generate_proxy(self):
290
290
291
291
"""Execute the get_proxy routine."""
292
292
293
+ TOKEN = os .getenv ("TOKEN" )
294
+
293
295
configuration = {
294
296
'CREDENTIAL_ENDPOINT' : 'https://dodas-tts.cloud.cnaf.infn.it/api/v2/iam/credential' ,
295
297
'IAM_ENDPOINT' :'https://dodas-iam.cloud.cnaf.infn.it/' ,
296
298
'TTS' :'https://dodas-tts.cloud.cnaf.infn.it' ,
297
- 'IAM_CLIENT_ID' : "{{ iam .client_id }}" ,
298
- 'IAM_CLIENT_SECRET' : "{{ iam .client_secret }}" ,
299
+ 'IAM_CLIENT_ID' : "{{ tts .client_id }}" ,
300
+ 'IAM_CLIENT_SECRET' : "{{ tts .client_secret }}" ,
299
301
'AUDIENCE' : 'https://dodas-tts.cloud.cnaf.infn.it' ,
300
- 'IAM_TOKEN' : "{{ iam.token }}" }
302
+ 'IAM_TOKEN' : TOKEN }
301
303
302
304
proxy_manager = ProxyManager (configuration )
303
305
proxy_file = proxy_manager .generate_proxy ()
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ IAM_CLIENT_ID=dodas-demo
4
+ IAM_CLIENT_SECRET=dodas-demo
5
+ IAM_USER=
6
+
7
+ IAM_CLIENT_ID={{ iam.client_id }}
8
+ IAM_CLIENT_SECRET={{ iam.client_secret }}
9
+
10
+
11
+ if [[ -z " ${IAM_CLIENT_SECRET} " ]]; then
12
+ echo " Please provide a client secret setting the IAM_CLIENT_SECRET env variable."
13
+ exit 1;
14
+ fi
15
+
16
+ if [[ -z ${IAM_USER} ]]; then
17
+ read -p " Username: " IAM_USER
18
+ fi
19
+
20
+ echo -ne " Password:"
21
+ read -s IAM_PASSWORD
22
+ echo
23
+
24
+ result=$( curl -s -L \
25
+ -d client_id=${IAM_CLIENT_ID} \
26
+ -d client_secret=${IAM_CLIENT_SECRET} \
27
+ -d grant_type=password \
28
+ -d username=${IAM_USER} \
29
+ -d password=${IAM_PASSWORD} \
30
+ -d scope=" openid profile email offline_access" \
31
+ ${IAM_ENDPOINT:- https:// dodas-iam.cloud.cnaf.infn.it/ token} ) # | tee /tmp/response | jq
32
+
33
+ if [[ $? != 0 ]]; then
34
+ echo " Error!"
35
+ echo $result
36
+ exit 1
37
+ fi
38
+
39
+ echo $result
40
+
41
+ access_token=$( echo $result | jq -r .access_token)
42
+
43
+ echo " export TOKEN=\" ${access_token} \" "
44
+ export TOKEN=" ${access_token} "
45
+
46
+ python /home/censtos/get_proxy.py
You can’t perform that action at this time.
0 commit comments