Add 'Automatic' ServiceKeyApprovalType
This commit is contained in:
parent
c766727d1d
commit
2242c6773d
5 changed files with 13 additions and 10 deletions
|
@ -878,6 +878,7 @@ class TorrentInfo(BaseModel):
|
|||
class ServiceKeyApprovalType(Enum):
|
||||
SUPERUSER = 'Super User API'
|
||||
KEY_ROTATION = 'Key Rotation'
|
||||
AUTOMATIC = 'Automatic'
|
||||
|
||||
|
||||
_ServiceKeyApproverProxy = Proxy()
|
||||
|
|
|
@ -142,8 +142,6 @@ def org_view(org):
|
|||
}
|
||||
|
||||
def user_view(user, password=None):
|
||||
if user is None:
|
||||
return None
|
||||
user_data = {
|
||||
'kind': 'user',
|
||||
'name': user.username,
|
||||
|
@ -493,7 +491,7 @@ def key_view(key):
|
|||
|
||||
def approval_view(approval):
|
||||
return {
|
||||
'approver': user_view(approval.approver),
|
||||
'approver': user_view(approval.approver) if approval.approver else None,
|
||||
'approval_type': approval.approval_type,
|
||||
'approved_date': approval.approved_date,
|
||||
'notes': approval.notes,
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
color: #128E72;
|
||||
}
|
||||
|
||||
.service-keys-manager-element .approval-automatic {
|
||||
font-size: 12px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.service-keys-manager-element i.fa {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
|
|
@ -130,10 +130,10 @@
|
|||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="approval-user" bo-if="key.approval && key.approval.approval_type == 'ServiceKeyApprovalType.SUPERUSER' && !key.approval.approver">
|
||||
Generated on Boot
|
||||
<span class="approval-automatic" bo-if="key.approval && key.approval.approval_type == 'ServiceKeyApprovalType.AUTOMATIC'">
|
||||
Generated Automatically
|
||||
</span>
|
||||
<span class="approval-user" bo-if="key.approval && key.approval.approval_type == 'ServiceKeyApprovalType.SUPERUSER'&& key.approval.approver">
|
||||
<span class="approval-user" bo-if="key.approval && key.approval.approval_type == 'ServiceKeyApprovalType.SUPERUSER'">
|
||||
<span class="pretext">Approved by</span><span class="entity-reference" entity="key.approval.approver"></span>
|
||||
</span>
|
||||
<span class="approval-rotation" bo-if="key.approval && key.approval.approval_type == 'ServiceKeyApprovalType.KEY_ROTATION'">
|
||||
|
@ -362,4 +362,4 @@
|
|||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -6,7 +6,7 @@ from timeparse import ParseDatetime
|
|||
|
||||
import argparse
|
||||
|
||||
def generate_key(service, name, approver=None, expiration_date=None, notes=None):
|
||||
def generate_key(service, name, expiration_date=None, notes=None):
|
||||
metadata = {
|
||||
'created_by': 'CLI tool',
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ def generate_key(service, name, approver=None, expiration_date=None, notes=None)
|
|||
metadata=metadata,
|
||||
name=name)
|
||||
# Auto-approve the service key.
|
||||
model.service_keys.approve_service_key(key.kid, approver, ServiceKeyApprovalType.SUPERUSER,
|
||||
model.service_keys.approve_service_key(key.kid, None, ServiceKeyApprovalType.AUTOMATIC,
|
||||
notes=notes or '')
|
||||
|
||||
# Log the creation and auto-approval of the service key.
|
||||
|
@ -36,7 +36,6 @@ def generate_key(service, name, approver=None, expiration_date=None, notes=None)
|
|||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Generates a preshared key')
|
||||
parser.add_argument('approver', help='Quay username of the user approving this key')
|
||||
parser.add_argument('service', help='The service name for which the key is being generated')
|
||||
parser.add_argument('name', help='The friendly name for the key')
|
||||
parser.add_argument('--expiration', help='The optional expiration date/time for the key',
|
||||
|
|
Reference in a new issue