GDRP update

2018-05-19 16:37:00 +0200

In less then a week GDRP will be enforced in the European Union. A good reason to update my homepage. I’ve done the following

  • Google analytics is removed from the homepage. I never look at those statistics anyway.
  • Also, sumo is removed, some embedded script which offers some functionality. Embedding script is a popular way to add functionality to your homepage, but in my opinion a display of the poor state of software development in the world. There is and should be better ways to compose functionality without loosing control.
  • For the same reason, the embedded twitter feed from my homepage is removed.
  • I still use Disquss for the comment-section on posts.

When you visit this homepage, your ip-address will be logged, but no other information that could be linked to personal. Also if you’d use VPN, Tor, or other similar software no attempt is made to reveal your true ip-address. My homepage is hosted at Transip, a Dutch provider. I pay them, which mean I am their customer and not the other way around. They don’t earn any money on advertising on my homepage.

Read more

Using Swagger to access your secured api

2017-04-18 21:01:00 +0200

Swagger, http://swagger.io/ is a great way make your api accessible. Not only documentation is provided, but your users, your co-developers or your self can try out your api. But what if your API is secured using a token based security system like webtokens?

Well, it’s quite easy to modify your swagger frontend to allow adding any token to requests.

First somewhere in your swagger template file, add the following:

            <form onsubmit="addApiKeyAuthorization()">
                <div class="input">
                    <input placeholder="access_token" id="input_apiKey" name="input_apiKey" type="text">
                    <input type="submit" value="Authenticate"/>
                </div>
            </form>

Then in the header add the following Javascript

<script>
    function addApiKeyAuthorization(){
        var apiKey = getUrlVars().input_apiKey;

        if (apiKey && apiKey.trim() != "") {
            console.log("initialzing oauth via api-key")
            var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("Authorization", "Bearer " + apiKey, "header");
            window.swaggerUi.api.clientAuthorizations.add("bearer", apiKeyAuth );
            //For clarity, also add in the input field
            $('#input_apiKey')[0].value=apiKey
        }
    }

</script>

Read more

Archive

subscribe via RSS