Repository: rucio/rucio

Issue:
Default identity not transferred end to end
Motivation
----------
CMS would like to be able to obtain a token without specifying the Rucio account name


Modification
------------
This value is there in most places it needs to be, but there are a couple of places it's missing leading to this breakage. 

The value is USED if it is present in the database.





Discussion:

Resolving patch:
diff --git a/lib/rucio/core/identity.py b/lib/rucio/core/identity.py
--- a/lib/rucio/core/identity.py
+++ b/lib/rucio/core/identity.py
@@ -105,7 +105,8 @@ def add_account_identity(identity, type, account, email, default=False, password
         add_identity(identity=identity, type=type, email=email, password=password, session=session)
         id = session.query(models.Identity).filter_by(identity=identity, identity_type=type).first()
 
-    iaa = models.IdentityAccountAssociation(identity=id.identity, identity_type=id.identity_type, account=account)
+    iaa = models.IdentityAccountAssociation(identity=id.identity, identity_type=id.identity_type, account=account,
+                                            is_default=default)
 
     try:
         iaa.save(session=session)
diff --git a/lib/rucio/web/rest/flaskapi/v1/account.py b/lib/rucio/web/rest/flaskapi/v1/account.py
--- a/lib/rucio/web/rest/flaskapi/v1/account.py
+++ b/lib/rucio/web/rest/flaskapi/v1/account.py
@@ -469,6 +469,7 @@ def post(self, account):
             authtype = parameter['authtype']
             email = parameter['email']
             password = parameter.get('password', None)
+            default = parameter.get('default', False)
         except KeyError as error:
             if error.args[0] == 'authtype' or error.args[0] == 'identity' or error.args[0] == 'email':
                 return generate_http_error_flask(400, 'KeyError', '%s not defined' % str(error))
@@ -476,7 +477,8 @@ def post(self, account):
             return generate_http_error_flask(400, 'TypeError', 'body must be a json dictionary')
 
         try:
-            add_account_identity(identity_key=identity, id_type=authtype, account=account, email=email, password=password, issuer=request.environ.get('issuer'))
+            add_account_identity(identity_key=identity, id_type=authtype, account=account, email=email,
+                                 password=password, issuer=request.environ.get('issuer'), default=default)
         except AccessDenied as error:
             return generate_http_error_flask(401, 'AccessDenied', error.args[0])
         except Duplicate as error:
diff --git a/lib/rucio/web/rest/webpy/v1/account.py b/lib/rucio/web/rest/webpy/v1/account.py
--- a/lib/rucio/web/rest/webpy/v1/account.py
+++ b/lib/rucio/web/rest/webpy/v1/account.py
@@ -548,6 +548,7 @@ def POST(self, account):
             authtype = parameter['authtype']
             email = parameter['email']
             password = parameter.get('password', None)
+            default = parameter.get('default', False)
         except KeyError as error:
             if error.args[0] == 'authtype' or error.args[0] == 'identity' or error.args[0] == 'email':
                 raise generate_http_error(400, 'KeyError', '%s not defined' % str(error))
@@ -555,7 +556,8 @@ def POST(self, account):
             raise generate_http_error(400, 'TypeError', 'body must be a json dictionary')
 
         try:
-            add_account_identity(identity_key=identity, id_type=authtype, account=account, email=email, password=password, issuer=ctx.env.get('issuer'))
+            add_account_identity(identity_key=identity, id_type=authtype, account=account, email=email,
+                                 password=password, issuer=ctx.env.get('issuer'), default=default)
         except AccessDenied as error:
             raise generate_http_error(401, 'AccessDenied', error.args[0])
         except Duplicate as error:


Test patch: