Skip to content

Commit

Permalink
Added HTTP auth! closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanda committed Nov 21, 2017
1 parent f49a2c3 commit e1d61f3
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 16 deletions.
1 change: 1 addition & 0 deletions assets/layout.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{httpAuth}
<!DOCTYPE html>
<html>
<head>
Expand Down
1 change: 1 addition & 0 deletions assets/section.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{httpAuth}
<!DOCTYPE html>
<html>
<head>
Expand Down
2 changes: 1 addition & 1 deletion demoOutput/about.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html> <html> <head> <title>API Docu</title> <style>html,body{margin:0;padding:0;height:100%;width:100%;font-size:12px;line-height:18px;vertical-align:middle}h1,h2,h3,h4,h5,h6{margin:1.2em 0;font-weight:600}h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child{margin:0 0 1em 0}p{margin:0 0 1em 0}h1{font-size:2.2em}h2{font-size:1.7em}h3{font-size:1.37em}h4{font-size:1em}h5{font-size:1.03em}h6{font-size:.87em}ul{margin:1em 0 1.5em}h2:first-of-type::before{content:"Section: ";font-weight:400;color:#949aa0}a{color:#3498db;text-decoration:none}a:visited{color:#3498db}a:hover{text-decoration:underline}body{background-color:transparent;font-size:14px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;height:auto}main{background-color:#fff;padding:1em;border-radius:2px;box-sizing:border-box}pre{background-color:#ecf0f1;padding:.5em;font-size:12px;font-family:"Lucida Console",Monaco,monospace}code{background-color:#ecf0f1;color:#8e44ad;padding:2px 4px;font-size:12px;font-family:"Lucida Console",Monaco,monospace}pre code{background-color:#ecf0f1;color:#2c3e50;padding:none}pre:last-child{margin-bottom:0}.language-json-string{color:#e67e22}.language-json-number{color:#138C58}.language-json-key{color:#4a51bf}</style> </head> <body> <main> <h2>About</h2> <p>Blah blah blah about</p> </main> </body> </html>
<!DOCTYPE html> <html> <head> <title>API Docu</title> <style>html,body{margin:0;padding:0;height:100%;width:100%;font-size:12px;line-height:18px;vertical-align:middle}h1,h2,h3,h4,h5,h6{margin:1.2em 0;font-weight:600}h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child{margin:0 0 1em 0}p{margin:0 0 1em 0}h1{font-size:2.2em}h2{font-size:1.7em}h3{font-size:1.37em}h4{font-size:1em}h5{font-size:1.03em}h6{font-size:.87em}ul{margin:1em 0 1.5em}h2:first-of-type::before{content:"Section: ";font-weight:400;color:#949aa0}a{color:#3498db;text-decoration:none}a:visited{color:#3498db}a:hover{text-decoration:underline}body{background-color:transparent;font-size:14px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;height:auto}main{background-color:#fff;padding:1em;border-radius:2px;box-sizing:border-box}pre{background-color:#ecf0f1;padding:.5em;font-size:12px;font-family:"Lucida Console",Monaco,monospace}code{background-color:#ecf0f1;color:#8e44ad;padding:2px 4px;font-size:12px;font-family:"Lucida Console",Monaco,monospace}pre code{background-color:#ecf0f1;color:#2c3e50;padding:none}pre:last-child{margin-bottom:0}.language-json-string{color:#e67e22}.language-json-number{color:#138C58}.language-json-key{color:#4a51bf}</style> </head> <body> <main> <h2>About</h2> <p>Blah blah blah about</p> </main> </body> </html>
2 changes: 1 addition & 1 deletion demoOutput/home.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html> <html> <head> <title>API Docu</title> <style>html,body{margin:0;padding:0;height:100%;width:100%;font-size:12px;line-height:18px;vertical-align:middle}h1,h2,h3,h4,h5,h6{margin:1.2em 0;font-weight:600}h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child{margin:0 0 1em 0}p{margin:0 0 1em 0}h1{font-size:2.2em}h2{font-size:1.7em}h3{font-size:1.37em}h4{font-size:1em}h5{font-size:1.03em}h6{font-size:.87em}ul{margin:1em 0 1.5em}h2:first-of-type::before{content:"Section: ";font-weight:400;color:#949aa0}a{color:#3498db;text-decoration:none}a:visited{color:#3498db}a:hover{text-decoration:underline}body{background-color:transparent;font-size:14px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;height:auto}main{background-color:#fff;padding:1em;border-radius:2px;box-sizing:border-box}pre{background-color:#ecf0f1;padding:.5em;font-size:12px;font-family:"Lucida Console",Monaco,monospace}code{background-color:#ecf0f1;color:#8e44ad;padding:2px 4px;font-size:12px;font-family:"Lucida Console",Monaco,monospace}pre code{background-color:#ecf0f1;color:#2c3e50;padding:none}pre:last-child{margin-bottom:0}.language-json-string{color:#e67e22}.language-json-number{color:#138C58}.language-json-key{color:#4a51bf}</style> </head> <body> <main> <h2>Home</h2> <p>This is a documentation of our cookbook JSON-RPC API. If you are having any troubles baking your own API client, please contact our chef Pavel Janda.</p> <h3>Specification of project Awesome Cookbook (version 2.3.4)</h3> <h4>Endpoint</h4> <p>All api calls should be targeting uri <code>api.example.io</code>. According to <a href="http://www.jsonrpc.org/specification">JSON-RPC specification</a>, each and every request object has to contain following properties:</p> <ul> <li><code>jsonrpc</code>: JSON-RPC version (<code>"2.0"</code>)</li> <li><code>method</code>: Name of the method to be invoked</li> <li><code>params</code>: Parameters of particular call (optional)</li> <li><code>id</code>: An string identifying this call (may be <code>null</code>)</li> </ul> <h4>Example request payload:</h4> <pre><code class="language-json">{
<!DOCTYPE html> <html> <head> <title>API Docu</title> <style>html,body{margin:0;padding:0;height:100%;width:100%;font-size:12px;line-height:18px;vertical-align:middle}h1,h2,h3,h4,h5,h6{margin:1.2em 0;font-weight:600}h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child{margin:0 0 1em 0}p{margin:0 0 1em 0}h1{font-size:2.2em}h2{font-size:1.7em}h3{font-size:1.37em}h4{font-size:1em}h5{font-size:1.03em}h6{font-size:.87em}ul{margin:1em 0 1.5em}h2:first-of-type::before{content:"Section: ";font-weight:400;color:#949aa0}a{color:#3498db;text-decoration:none}a:visited{color:#3498db}a:hover{text-decoration:underline}body{background-color:transparent;font-size:14px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;height:auto}main{background-color:#fff;padding:1em;border-radius:2px;box-sizing:border-box}pre{background-color:#ecf0f1;padding:.5em;font-size:12px;font-family:"Lucida Console",Monaco,monospace}code{background-color:#ecf0f1;color:#8e44ad;padding:2px 4px;font-size:12px;font-family:"Lucida Console",Monaco,monospace}pre code{background-color:#ecf0f1;color:#2c3e50;padding:none}pre:last-child{margin-bottom:0}.language-json-string{color:#e67e22}.language-json-number{color:#138C58}.language-json-key{color:#4a51bf}</style> </head> <body> <main> <h2>Home</h2> <p>This is a documentation of our cookbook JSON-RPC API. If you are having any troubles baking your own API client, please contact our chef Pavel Janda.</p> <h3>Specification of project Awesome Cookbook (version 2.3.4)</h3> <h4>Endpoint</h4> <p>All api calls should be targeting uri <code>api.example.io</code>. According to <a href="http://www.jsonrpc.org/specification">JSON-RPC specification</a>, each and every request object has to contain following properties:</p> <ul> <li><code>jsonrpc</code>: JSON-RPC version (<code>"2.0"</code>)</li> <li><code>method</code>: Name of the method to be invoked</li> <li><code>params</code>: Parameters of particular call (optional)</li> <li><code>id</code>: An string identifying this call (may be <code>null</code>)</li> </ul> <h4>Example request payload:</h4> <pre><code class="language-json">{
"jsonrpc": "2.0",
"method": "Receipe.store",
"params": {
Expand Down
2 changes: 1 addition & 1 deletion demoOutput/index.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html> <html> <head> <title>Awesome cookbook JSON-RPC API doc</title> <style>html,body{margin:0;padding:0;height:100%;width:100%}h1,h2,h3,h4,h5,h6,p{margin:0}body{background-color:#2980b9;background-color:#34495e;font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;overflow:auto;box-sizing:border-box;width:100vw;max-width:100vw;height:100vh;max-height:100vh;display:grid;grid-template-columns:auto 300px 900px auto;grid-template-rows:80px auto 80px;grid-template-areas:"header header header header" "empty-left nav main empty-right" "footer footer footer footer";grid-column-gap:2em}header{grid-area:header}nav{grid-area:nav;align-self:start}.empty-left{grid-area:empty-left}.empty-right{grid-area:empty-right}main{grid-area:main}footer{grid-area:footer}button.section-method,a.section-site{font-size:12px;display:block;width:100%;border:0;margin:0;line-height:30px;vertical-align:middle;padding:0 1em;background-color:#fff;color:#505050;box-sizing:border-box;text-align:left;border-radius:0;cursor:pointer}button.section-method:hover,a.section-site:hover,button.section-method:active,a.section-site:active,button.section-method:focus,a.section-site:focus,button.section-method:target,a.section-site:target{background-color:#eee;cursor:pointer;outline:none}.section-site:first-of-type{font-weight:700}.section-method:first-of-type,.section-site:first-of-type{border-top-right-radius:2px;border-top-left-radius:2px}.section-method:last-of-type,.section-site:last-of-type{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.section-method:first-of-type{margin-top:1em}iframe{width:100%;height:0;border:0;padding:0;margin:0}</style> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/> </head> <body> <header>Awesome cookbook JSON-RPC API doc</header> <div class="empty-left"></div> <nav> <p><a data-section-href="home.php" class="section-site" data-target="home">Home</a> <a data-section-href="about.php" class="section-site" data-target="about-project">About project</a> <button data-section-href="methods/user.login.php" class="section-method" data-target="user-login">user.login</button> <button data-section-href="methods/user.logout.php" class="section-method" data-target="user-logout">user.logout</button></p></nav> <div class="empty-right"></div> <main> <iframe src="" scrolling="no"></iframe> </main> <footer></footer> <script type="text/javascript">document.addEventListener("DOMContentLoaded",function(event){var buttons=document.querySelectorAll('[data-section-href]');for(var i=0;i<buttons.length;i++){buttons[i].addEventListener("click",function(event){event.stopPropagation();event.preventDefault();window.location.hash=this.getAttribute("data-target")})} if(buttons.length){if(window.location.hash){onHashChangeRouter()}else{var sectionLink=buttons[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionLink)}}});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){this.style.height=this.contentWindow.document.body.scrollHeight+'px'});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){var jsonAreas=this.contentWindow.document.getElementsByClassName('language-json');for(var i=0;i<jsonAreas.length;i++){var content=jsonAreas[i].innerHTML;content=content.replace(/"([^"]+)":/g,"<span class=language-json-key>&quot;$1&quot;:</span>");content=content.replace(/"([^"]+)"([^:])/g,"<span class=language-json-string>&quot;$1&quot;</span>$2");content=content.replace(/([ ,:{\n])(\d+)/g,"$1<span class=language-json-number>$2</span>");jsonAreas[i].innerHTML=content}});var onHashChangeRouter=function(){if(window.location.hash){var hash=window.location.hash.replace(/#/,'');var sectionLink=document.querySelectorAll('[data-target="'+hash+'"]');if(sectionLink.length){var sectionSrc=sectionLink[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionSrc)}}};window.onhashchange=function(){onHashChangeRouter()}</script> </body> </html>
<!DOCTYPE html> <html> <head> <title>Awesome cookbook JSON-RPC API doc</title> <style>html,body{margin:0;padding:0;height:100%;width:100%}h1,h2,h3,h4,h5,h6,p{margin:0}body{background-color:#2980b9;background-color:#34495e;font-size:12px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;overflow:auto;box-sizing:border-box;width:100vw;max-width:100vw;height:100vh;max-height:100vh;display:grid;grid-template-columns:auto 300px 900px auto;grid-template-rows:80px auto 80px;grid-template-areas:"header header header header" "empty-left nav main empty-right" "footer footer footer footer";grid-column-gap:2em}header{grid-area:header}nav{grid-area:nav;align-self:start}.empty-left{grid-area:empty-left}.empty-right{grid-area:empty-right}main{grid-area:main}footer{grid-area:footer}button.section-method,a.section-site{font-size:12px;display:block;width:100%;border:0;margin:0;line-height:30px;vertical-align:middle;padding:0 1em;background-color:#fff;color:#505050;box-sizing:border-box;text-align:left;border-radius:0;cursor:pointer}button.section-method:hover,a.section-site:hover,button.section-method:active,a.section-site:active,button.section-method:focus,a.section-site:focus,button.section-method:target,a.section-site:target{background-color:#eee;cursor:pointer;outline:none}.section-site:first-of-type{font-weight:700}.section-method:first-of-type,.section-site:first-of-type{border-top-right-radius:2px;border-top-left-radius:2px}.section-method:last-of-type,.section-site:last-of-type{border-bottom-right-radius:2px;border-bottom-left-radius:2px}.section-method:first-of-type{margin-top:1em}iframe{width:100%;height:0;border:0;padding:0;margin:0}</style> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/> </head> <body> <header>Awesome cookbook JSON-RPC API doc</header> <div class="empty-left"></div> <nav> <p><a data-section-href="home.php" class="section-site" data-target="home">Home</a> <a data-section-href="about.php" class="section-site" data-target="about-project">About project</a> <button data-section-href="methods/user.login.php" class="section-method" data-target="user-login">user.login</button> <button data-section-href="methods/user.logout.php" class="section-method" data-target="user-logout">user.logout</button></p></nav> <div class="empty-right"></div> <main> <iframe src="" scrolling="no"></iframe> </main> <footer></footer> <script type="text/javascript">document.addEventListener("DOMContentLoaded",function(event){var buttons=document.querySelectorAll('[data-section-href]');for(var i=0;i<buttons.length;i++){buttons[i].addEventListener("click",function(event){event.stopPropagation();event.preventDefault();window.location.hash=this.getAttribute("data-target")})} if(buttons.length){if(window.location.hash){onHashChangeRouter()}else{var sectionLink=buttons[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionLink)}}});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){this.style.height=this.contentWindow.document.body.scrollHeight+'px'});document.getElementsByTagName("iframe")[0].addEventListener("load",function(){var jsonAreas=this.contentWindow.document.getElementsByClassName('language-json');for(var i=0;i<jsonAreas.length;i++){var content=jsonAreas[i].innerHTML;content=content.replace(/"([^"]+)":/g,"<span class=language-json-key>&quot;$1&quot;:</span>");content=content.replace(/"([^"]+)"([^:])/g,"<span class=language-json-string>&quot;$1&quot;</span>$2");content=content.replace(/([ ,:{\n])(\d+)/g,"$1<span class=language-json-number>$2</span>");jsonAreas[i].innerHTML=content}});var onHashChangeRouter=function(){if(window.location.hash){var hash=window.location.hash.replace(/#/,'');var sectionLink=document.querySelectorAll('[data-target="'+hash+'"]');if(sectionLink.length){var sectionSrc=sectionLink[0].getAttribute("data-section-href");document.getElementsByTagName('iframe')[0].setAttribute("src",sectionSrc)}}};window.onhashchange=function(){onHashChangeRouter()}</script> </body> </html>
2 changes: 1 addition & 1 deletion demoOutput/methods/user.login.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html> <html> <head> <title>API Docu</title> <style>html,body{margin:0;padding:0;height:100%;width:100%;font-size:12px;line-height:18px;vertical-align:middle}h1,h2,h3,h4,h5,h6{margin:1.2em 0;font-weight:600}h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child{margin:0 0 1em 0}p{margin:0 0 1em 0}h1{font-size:2.2em}h2{font-size:1.7em}h3{font-size:1.37em}h4{font-size:1em}h5{font-size:1.03em}h6{font-size:.87em}ul{margin:1em 0 1.5em}h2:first-of-type::before{content:"Section: ";font-weight:400;color:#949aa0}a{color:#3498db;text-decoration:none}a:visited{color:#3498db}a:hover{text-decoration:underline}body{background-color:transparent;font-size:14px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;height:auto}main{background-color:#fff;padding:1em;border-radius:2px;box-sizing:border-box}pre{background-color:#ecf0f1;padding:.5em;font-size:12px;font-family:"Lucida Console",Monaco,monospace}code{background-color:#ecf0f1;color:#8e44ad;padding:2px 4px;font-size:12px;font-family:"Lucida Console",Monaco,monospace}pre code{background-color:#ecf0f1;color:#2c3e50;padding:none}pre:last-child{margin-bottom:0}.language-json-string{color:#e67e22}.language-json-number{color:#138C58}.language-json-key{color:#4a51bf}</style> </head> <body> <main> <h2>user.login</h2> <h3>Example request:</h3> <pre><code class="language-json">{
<!DOCTYPE html> <html> <head> <title>API Docu</title> <style>html,body{margin:0;padding:0;height:100%;width:100%;font-size:12px;line-height:18px;vertical-align:middle}h1,h2,h3,h4,h5,h6{margin:1.2em 0;font-weight:600}h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child,h6:first-child{margin:0 0 1em 0}p{margin:0 0 1em 0}h1{font-size:2.2em}h2{font-size:1.7em}h3{font-size:1.37em}h4{font-size:1em}h5{font-size:1.03em}h6{font-size:.87em}ul{margin:1em 0 1.5em}h2:first-of-type::before{content:"Section: ";font-weight:400;color:#949aa0}a{color:#3498db;text-decoration:none}a:visited{color:#3498db}a:hover{text-decoration:underline}body{background-color:transparent;font-size:14px;font-family:Arial,Helvetica,sans-serif;color:#2c3e50;height:auto}main{background-color:#fff;padding:1em;border-radius:2px;box-sizing:border-box}pre{background-color:#ecf0f1;padding:.5em;font-size:12px;font-family:"Lucida Console",Monaco,monospace}code{background-color:#ecf0f1;color:#8e44ad;padding:2px 4px;font-size:12px;font-family:"Lucida Console",Monaco,monospace}pre code{background-color:#ecf0f1;color:#2c3e50;padding:none}pre:last-child{margin-bottom:0}.language-json-string{color:#e67e22}.language-json-number{color:#138C58}.language-json-key{color:#4a51bf}</style> </head> <body> <main> <h2>user.login</h2> <h3>Example request:</h3> <pre><code class="language-json">{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
Expand Down
Loading

0 comments on commit e1d61f3

Please sign in to comment.