mirror of
				https://github.com/laurivosandi/certidude
				synced 2025-10-31 01:19:11 +00:00 
			
		
		
		
	Add request submission from web interface
This commit is contained in:
		| @@ -33,6 +33,10 @@ class RequestListResource(object): | ||||
|  | ||||
|         body = req.stream.read(req.content_length) | ||||
|  | ||||
|         # Normalize body, TODO: newlines | ||||
|         if not body.endswith("\n"): | ||||
|             body += "\n" | ||||
|  | ||||
|         csr = Request(body) | ||||
|  | ||||
|         if not csr.common_name: | ||||
|   | ||||
| @@ -168,8 +168,8 @@ pre { | ||||
|  | ||||
| .icon{ | ||||
|     background-size: 24px; | ||||
|     background-position: 6px 2px; | ||||
|     padding-left: 32px; | ||||
|     background-position: 8px 5px; | ||||
|     padding-left: 36px; | ||||
|     background-repeat: no-repeat; | ||||
|     display: block; | ||||
|     vertical-align: text-bottom; | ||||
| @@ -225,5 +225,7 @@ select { | ||||
| .icon.wireless { background-image: url("../img/iconmonstr-wireless-6.svg"); } | ||||
| .icon.password { background-image: url("../img/iconmonstr-lock-3.svg"); } | ||||
|  | ||||
| .icon.upload { background-image: url("../img/iconmonstr-upload-17.svg"); } | ||||
|  | ||||
| /* Make sure this is the last one */ | ||||
| .icon.busy{background-image:url("https://software.opensuse.org/assets/ajax-loader-ea46060b6c9f42822a3d58d075c83ea2.gif");} | ||||
|   | ||||
							
								
								
									
										1
									
								
								certidude/static/img/iconmonstr-upload-17.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								certidude/static/img/iconmonstr-upload-17.svg
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | ||||
| <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M16 16h-3v5h-2v-5h-3l4-4 4 4zm3.479-5.908c-.212-3.951-3.473-7.092-7.479-7.092s-7.267 3.141-7.479 7.092c-2.57.463-4.521 2.706-4.521 5.408 0 3.037 2.463 5.5 5.5 5.5h3.5v-2h-3.5c-1.93 0-3.5-1.57-3.5-3.5 0-2.797 2.479-3.833 4.433-3.72-.167-4.218 2.208-6.78 5.567-6.78 3.453 0 5.891 2.797 5.567 6.78 1.745-.046 4.433.751 4.433 3.72 0 1.93-1.57 3.5-3.5 3.5h-3.5v2h3.5c3.037 0 5.5-2.463 5.5-5.5 0-2.702-1.951-4.945-4.521-5.408z"/></svg> | ||||
| After Width: | Height: | Size: 522 B | 
| @@ -287,6 +287,33 @@ $(document).ready(function() { | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|  | ||||
|             if (session.request_submission_allowed) { | ||||
|                 $("#request_submit").click(function() { | ||||
|                     $(this).addClass("busy"); | ||||
|                     $.ajax({ | ||||
|                         method: "POST", | ||||
|                         contentType: "application/pkcs10", | ||||
|                         url: "/api/request/", | ||||
|                         data: $("#request_body").val(), | ||||
|                         dataType: "text", | ||||
|                         complete: function(xhr, status) { | ||||
|                             console.info("Request submitted successfully, server returned", xhr.status,  status); | ||||
|                             $("#request_submit").removeClass("busy"); | ||||
|                         }, | ||||
|                         success: function() { | ||||
|                             // Clear textarea on success | ||||
|                             $("#request_body").val(""); | ||||
|                         }, | ||||
|                         error: function(xhr, status, e) { | ||||
|                             console.info("Submitting request failed with:", status, e); | ||||
|                             alert(e); | ||||
|                         } | ||||
|                     }); | ||||
|  | ||||
|                 }); | ||||
|             } | ||||
|  | ||||
|             /** | ||||
|              * Fetch leases associated with certificates | ||||
|              */ | ||||
|   | ||||
| @@ -126,8 +126,24 @@ forbidden | ||||
| <section id="requests"> | ||||
|     <h1>Pending requests</h1> | ||||
|  | ||||
|     {% if session.request_submission_allowed %} | ||||
|       <p>Generate private key and certificate signing request:</p> | ||||
|  | ||||
|       <pre> | ||||
| openssl genrsa -out example.key 2048 | ||||
| openssl req -new -sha256 -key example.key -out example.csr | ||||
| cat example.csr | ||||
| </pre> | ||||
|  | ||||
|       <p>Paste the contents here and click submit:</p> | ||||
|       <textarea id="request_body" style="width:100%; min-height: 4em;" placeholder="-----BEGIN CERTIFICATE REQUEST----- | ||||
| ... | ||||
| -----END CERTIFICATE REQUEST-----"></textarea> | ||||
|       <button class="icon upload" id="request_submit" style="float:none;">Submit</button> | ||||
|     {% else %} | ||||
|       <p>Submit a certificate signing request with Certidude:</p> | ||||
|       <pre>certidude setup client {{session.common_name}}</pre> | ||||
|     {% endif %} | ||||
|  | ||||
|     <ul id="pending_requests"> | ||||
|       {% for request in session.authority.requests %} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user