Allow specification of full name when creating service account
This commit is contained in:
parent
c12b646b09
commit
50d62f17b8
@ -186,12 +186,15 @@ def manage_user_group_membership(db_user, role, action):
|
|||||||
return user_groups
|
return user_groups
|
||||||
|
|
||||||
|
|
||||||
def create_service_account(email: str, roles: typing.Iterable, service: dict):
|
def create_service_account(email: str, roles: typing.Iterable, service: dict,
|
||||||
|
*, full_name: str=None):
|
||||||
"""Creates a service account with the given roles + the role 'service'.
|
"""Creates a service account with the given roles + the role 'service'.
|
||||||
|
|
||||||
:param email: optional email address associated with the account.
|
:param email: optional email address associated with the account.
|
||||||
:param roles: iterable of role names
|
:param roles: iterable of role names
|
||||||
:param service: dict of the 'service' key in the user.
|
:param service: dict of the 'service' key in the user.
|
||||||
|
:param full_name: Full name of the service account. If None, will be set to
|
||||||
|
something reasonable.
|
||||||
|
|
||||||
:return: tuple (user doc, token doc)
|
:return: tuple (user doc, token doc)
|
||||||
"""
|
"""
|
||||||
@ -207,7 +210,7 @@ def create_service_account(email: str, roles: typing.Iterable, service: dict):
|
|||||||
'roles': roles,
|
'roles': roles,
|
||||||
'settings': {'email_communications': 0},
|
'settings': {'email_communications': 0},
|
||||||
'auth': [],
|
'auth': [],
|
||||||
'full_name': f'SRV-{user_id}',
|
'full_name': full_name or f'SRV-{user_id}',
|
||||||
'service': service}
|
'service': service}
|
||||||
if email:
|
if email:
|
||||||
user['email'] = email
|
user['email'] = email
|
||||||
|
@ -311,14 +311,16 @@ def badger(action, user_email, role):
|
|||||||
log.info('Status : %i', status)
|
log.info('Status : %i', status)
|
||||||
|
|
||||||
|
|
||||||
def create_service_account(email, service_roles, service_definition):
|
def create_service_account(email, service_roles, service_definition,
|
||||||
|
*, full_name: str=None):
|
||||||
from pillar.api import service
|
from pillar.api import service
|
||||||
from pillar.api.utils import dumps
|
from pillar.api.utils import dumps
|
||||||
|
|
||||||
account, token = service.create_service_account(
|
account, token = service.create_service_account(
|
||||||
email,
|
email,
|
||||||
service_roles,
|
service_roles,
|
||||||
service_definition
|
service_definition,
|
||||||
|
full_name=full_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
print('Service account information:')
|
print('Service account information:')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user