Skip to content

Commit b880518

Browse files
authored
Merge pull request #121 from ARGOeu/devel
Version 0.1.4
2 parents 7a5ff19 + 3486501 commit b880518

File tree

414 files changed

+824
-191485
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

414 files changed

+824
-191485
lines changed

Gopkg.lock

Lines changed: 0 additions & 91 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 51 deletions
This file was deleted.

Jenkinsfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pipeline {
22
agent {
33
docker {
4-
image 'argo.registry:5000/epel-7-mgo'
4+
image 'argo.registry:5000/epel-7-mgo1.14'
55
args '-u jenkins:jenkins'
66
}
77
}
@@ -63,6 +63,12 @@ pipeline {
6363
}
6464
success {
6565
script{
66+
if ( env.BRANCH_NAME == 'devel' ) {
67+
build job: '/ARGO-utils/argo-swagger-docs', propagate: false
68+
build job: '/ARGO/argodoc/devel', propagate: false
69+
} else if ( env.BRANCH_NAME == 'master' ) {
70+
build job: '/ARGO/argodoc/master', propagate: false
71+
}
6672
if ( env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'devel' ) {
6773
slackSend( message: ":rocket: New version for <$BUILD_URL|$PROJECT_DIR>:$BRANCH_NAME Job: $JOB_NAME !")
6874
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Before you start, you need to issue a valid certificate.
1515

1616
## Set Up
1717

18-
1. Install Golang 1.10
18+
1. Install Golang 1.14
1919
2. Create a new work space:
2020

2121
`mkdir ~/go-workspace`

argo-api-authn.spec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
Name: argo-api-authn
55
Summary: ARGO Authentication API. Map X509, OICD to token.
6-
Version: 0.1.3
6+
Version: 0.1.4
77
Release: 1%{?dist}
88
License: ASL 2.0
99
Buildroot: %{_tmppath}/%{name}-buildroot
@@ -57,6 +57,8 @@ go clean
5757
%attr(0644,root,root) /usr/lib/systemd/system/argo-api-authn.service
5858

5959
%changelog
60+
* Thu Jun 13 2019 Agelos Tsalapatis <agelos.tsal@gmail.com> - 0.1.4-1%{?dist}
61+
- Release of argo-api-authn version 0.1.4
6062
* Thu Jun 13 2019 Agelos Tsalapatis <agelos.tsal@gmail.com> - 0.1.3-1%{?dist}
6163
- ARGO-1773 Update authn scripts to filter service endpoints before creating the respective user
6264
- ARGO-1615 update authn scripts to get site-mail from gocdb

auth/certificate_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ lBlGGSW4gNfL1IYoakRwJiNiqZ+Gb7+6kHDSVneFeO/qJakXzlByjAA6quPbYzSf
154154

155155
// mismatch
156156
crt = ParseCert(commonCert)
157+
crt.Subject.CommonName = "example.com"
157158
err2 := ValidateClientCertificate(crt, "127.0.0.1:8080")
158-
suite.Equal("x509: certificate is valid for COMODO RSA Domain Validation Secure Server CA, not localhost", err2.Error())
159+
suite.Equal("x509: certificate is valid for example.com, not localhost", err2.Error())
159160

160161
// mismatch
161162
crt = ParseCert(commonCert)

authmethods/authmethods_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/stretchr/testify/suite"
88
"io"
99
"io/ioutil"
10+
"reflect"
1011
"testing"
1112
)
1213

@@ -148,7 +149,7 @@ func (suite *AuthMethodsTestSuite) TestAuthMethodFIndAll() {
148149
mockstore.AuthMethods = []stores.QAuthMethod{}
149150
aMList2, err2 := AuthMethodFindAll(mockstore)
150151

151-
suite.Equal(expAmList, aMList)
152+
suite.True(reflect.DeepEqual(expAmList, aMList))
152153
suite.Equal(0, len(aMList2.AuthMethods))
153154

154155
suite.Nil(err1)

bin/argo-api-authn-scripts/ams-create-users-cloud-info.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,19 @@ def create_users(config, verify):
220220
# user count
221221
user_count = 0
222222

223+
# updated bindings count
224+
update_binding_count= 0
225+
226+
# updated bindings names
227+
update_bindings_names= []
228+
223229
# form the goc db url
224230
goc_db_url = goc_db_url_arch.replace("{{service-type}}", srv_type)
225231
LOGGER.info("\nAccessing url: " + goc_db_url)
226232
LOGGER.info("\nStarted the process for service-type: " + srv_type)
227233

228234
# grab the xml data from goc db
229-
goc_request = requests.get(goc_db_url, verify=False)
235+
goc_request = requests.get(url=goc_db_url, cert=cert_creds, verify=False)
230236
LOGGER.info(goc_request.text)
231237

232238
# users from goc db that don't have a dn registered
@@ -260,7 +266,7 @@ def create_users(config, verify):
260266
site_url = goc_db_site_url.replace("{{sitename}}", site_name)
261267
goc_site_request = requests.get(site_url, cert=cert_creds, verify=False)
262268
site_xml_obj = ET.fromstring(goc_site_request.text)
263-
269+
264270
# check if the site is in production
265271
in_prod = site_xml_obj.find("SITE").find("PRODUCTION_INFRASTRUCTURE")
266272
if in_prod.text != 'Production':
@@ -269,7 +275,7 @@ def create_users(config, verify):
269275
# check for certified or uncertified
270276
cert_uncert = site_xml_obj.find("SITE").find("CERTIFICATION_STATUS")
271277
if cert_uncert.text != "Certified" and cert_uncert.text != "Uncertified":
272-
raise Exception("Neither certified not uncertified")
278+
raise Exception("Neither certified nor uncertified")
273279

274280
contact_email = site_xml_obj.find("SITE").find("CONTACT_EMAIL").text
275281
site_contact_emails[site_name] = contact_email
@@ -295,10 +301,8 @@ def create_users(config, verify):
295301
usr_create = {'projects': [project], 'email': contact_email}
296302

297303
# create the user
298-
ams_usr_crt_req = requests.post(
299-
"https://" + ams_host + "/v1/users/" + user_binding_name +
300-
"?key=" + ams_token,
301-
data=json.dumps(usr_create), verify=verify)
304+
api_url = 'https://{0}/v1/projects/{1}/members/{2}?key={3}'.format(ams_host, ams_project, user_binding_name, ams_token)
305+
ams_usr_crt_req = requests.post(url=api_url, data=json.dumps(usr_create), verify=verify)
302306
LOGGER.info(ams_usr_crt_req.text)
303307

304308
ams_user_uuid = ""
@@ -320,10 +324,8 @@ def create_users(config, verify):
320324

321325
# If the user already exists, Get user by username
322326
if ams_usr_crt_req.status_code == 409:
323-
324-
ams_usr_get_req = requests.get(
325-
"https://" + ams_host + "/v1/users/" +
326-
user_binding_name + "?key=" + ams_token, verify=verify)
327+
proj_member_list_url = "https://{0}/v1/projects/{1}/members/{2}?key={3}".format(ams_host, ams_project, user_binding_name, ams_token)
328+
ams_usr_get_req = requests.get(url=proj_member_list_url, verify=verify)
327329

328330
# if the user retrieval was ok
329331
if ams_usr_get_req.status_code == 200:
@@ -337,17 +339,16 @@ def create_users(config, verify):
337339

338340
# Create the respective AUTH binding
339341
bd_data = {
340-
'name': user_binding_name,
341342
'service_uuid': authn_service_uuid,
342343
'host': authn_service_host,
343344
'auth_identifier': service_dn,
344345
'unique_key': ams_user_uuid,
345346
"auth_type": "x509"
346347
}
347-
348-
authn_binding_crt_req = requests.post(
349-
"https://"+authn_host+"/v1/bindings?key="+authn_token,
350-
data=json.dumps(bd_data), verify=verify)
348+
349+
create_binding_url = "https://{0}/v1/bindings/{1}?key={2}".format(authn_host, user_binding_name, authn_token)
350+
351+
authn_binding_crt_req = requests.post(url=create_binding_url, data=json.dumps(bd_data), verify=verify)
351352
LOGGER.info(authn_binding_crt_req.text)
352353

353354
# if the response is neither a 201(Created) nor a 409(already exists)
@@ -358,6 +359,32 @@ def create_users(config, verify):
358359
authn_binding_crt_req.text)
359360
continue
360361

362+
# if the binding already exists, check for an updated DN from gocdb
363+
if authn_binding_crt_req.status_code == 409:
364+
retrieve_binding_url = "https://{0}/v1/bindings/{1}?key={2}".format(authn_host, user_binding_name, authn_token)
365+
authn_ret_bind_req = requests.get(url=retrieve_binding_url, verify=verify)
366+
# if the binding retrieval was ok
367+
if authn_ret_bind_req.status_code == 200:
368+
LOGGER.info("\nSuccessfully retrieved binding {} from authn. Checking for DN update.".format(user_binding_name))
369+
binding = authn_ret_bind_req.json()
370+
# check if the dn has changed
371+
if binding["auth_identifier"] != service_dn:
372+
# update the respective binding with the new dn
373+
bind_upd_req_url = "https://{0}/v1/bindings/{1}?key={2}".format(authn_host, user_binding_name, authn_token)
374+
upd_bd_data = {
375+
"auth_identifier": service_dn
376+
}
377+
authn_bind_upd_req = requests.put(url=bind_upd_req_url, data=json.dumps(upd_bd_data), verify=verify)
378+
LOGGER.info(authn_bind_upd_req.text)
379+
if authn_bind_upd_req.status_code == 200:
380+
update_binding_count += 1
381+
update_bindings_names.append(user_binding_name)
382+
else:
383+
LOGGER.critical(
384+
"\nCould not retrieve binding {} from authn."
385+
"\n Response {}".format(user_binding_name, authn_ret_bind_req.text))
386+
continue
387+
361388
# since both the ams user was created or already existed AND the authn binding was created or already existed
362389
# move to topic and subscription creation
363390

@@ -442,6 +469,10 @@ def create_users(config, verify):
442469
LOGGER.critical("Service Type: " + srv_type)
443470
LOGGER.critical("Missing DNS: " + str(missing_dns))
444471
LOGGER.critical("Total Users Created: " + str(user_count))
472+
LOGGER.critical("Total Bindings Updated: " + str(update_binding_count))
473+
LOGGER.critical("Updated bingings: " + str(update_bindings_names))
474+
475+
445476
LOGGER.critical("-----------------------------------------")
446477

447478

@@ -490,4 +521,4 @@ def main(args=None):
490521
"-verify", "--Verify", help="SSL verification for requests",
491522
action="store_true")
492523

493-
sys.exit(main(parser.parse_args()))
524+
sys.exit(main(parser.parse_args()))

0 commit comments

Comments
 (0)