<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by cidaas on Medium]]></title>
        <description><![CDATA[Stories by cidaas on Medium]]></description>
        <link>https://medium.com/@cidaas?source=rss-81b76d65c595------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pkwY-wqfEgSHRXLp8mbOCA.png</url>
            <title>Stories by cidaas on Medium</title>
            <link>https://medium.com/@cidaas?source=rss-81b76d65c595------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 05:57:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cidaas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Secure Kubernetes clusters with OAuth2/OpenID Connect and cidaas]]></title>
            <link>https://cidaas.medium.com/secure-kubernetes-clusters-with-oauth2-openid-connect-and-cidaas-ffc58b7274b7?source=rss-81b76d65c595------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffc58b7274b7</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[cidaas]]></category>
            <dc:creator><![CDATA[cidaas]]></dc:creator>
            <pubDate>Thu, 12 Aug 2021 14:07:30 GMT</pubDate>
            <atom:updated>2021-08-12T14:07:30.005Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vbIY_o25ju4sItEYeY_cJg.jpeg" /><figcaption>Secure Kubernetes Clusters with OAuth2/OpenID Connect and cidaas</figcaption></figure><p>This article focuses on securing a Kubernetes cluster with OAuth2 and OpenID Connect using cidaas Cloud Identity &amp; Access Management.</p><p>cidaas (<a href="https://www.cidaas.com/">https://www.cidaas.com</a>) is a modern Cloud Identity &amp; Access Management solution developed by Widas ID GmbH located in Germany. The cidaas feature set includes:</p><ul><li>Single Sign On (SSO) based on OAuth2, OpenID Connect, SAML 2.0</li><li>Multi-Factor-Authentication (MFA) with more than 14 authentication methods, including TOTP and FIDO2</li><li>password-less authentication</li><li>social login (e.g. Facebook, Google, LinkedIn, and more) as well as enterprise identity provider (e.g. SAML or AD)</li><li>security in Machine-to-Machine communications (M2M) and IoT</li></ul><h3>A short introduction on OAuth2, OpenID Connect and Kubernetes</h3><p>OAuth2 is the industry-standard protocol for authorization, and it provides different authorization flows depending on the application or client type, be it for example web or mobile applications. If you want to learn more about OAuth2 have a look at the official website at <a href="https://oauth.net/2/">https://oauth.net/2/</a>.</p><p>OpenID Connect (OIDC) is a standard authentication protocol that adds an identification layer to the previous OAuth 2.0 standard. OIDC provides information to the end user in the form of an id token, through which the identity is verified. The standard is controlled by the OpenID Foundation (<a href="https://openid.net/">https://openid.net</a>).</p><p>Kubernetes is an open-source orchestration platform for the management of containerized applications. It offers many features for an automated and stable operation of modern software architectures, including automated deployments and scaling. (<a href="https://kubernetes.io/">https://kubernetes.io</a>)</p><h3>Kubernetes OpenID Connect Tokens</h3><p>The OpenID Connect Token (<a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/#openid-connect-tokens">Kubernetes Docs</a>) feature of Kubernetes allows an out-of-the-box integration with cidaas or any other identity provider supporting the OpenID Connect protocol.</p><p>The integration of cidaas requires two steps of configuration:</p><p>First, the configuration of the API Server</p><ul><li>oidc parameters</li><li>Kubespray</li><li>Kops</li><li>Kubeadm</li></ul><p>Second, the configuration of the Kubernetes Clients</p><ul><li>Kubectl</li><li>Kubernetes Dashboard</li></ul><h3>Kubernetes API Server Configuration</h3><p>We will show 4 different ways to configure the API Server. First we will discuss the plain configuration of the API Server, additionally we will show how a configuration can be achieved with commonly used orchestration solutions Kubespray, Kops, and Kubeadm.</p><p><strong>Plain Configuration via oidc parameters</strong></p><p>The OpenID Connect Feature of Kubernetes provides several parameter options, which need to be passed while starting the Kubernetes API Server. Two of these are required:</p><pre><em>— oidc-issuer-url</em> and <em>— oidc-client-id</em></pre><p>These are also the only ones required for an integration with cidaas. Pass the cidaas issuer URL (the base URL of your cidaas instance) and the client ID of your cidaas application. If you need some information how to create an app (OAuth2 / OpenID Connect Client) in cidaas please refer to the cidaas documentation: <a href="https://docs.cidaas.com/manage-applications/app-settings.html">docs.cidaas.com</a></p><p><strong>Kubespray</strong></p><p>If you are using Kubespray to configure your Kubernetes Cluster, You can add following configuration to `group_vars/k8s_cluster/k8s-cluster.yml` file :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04cb6a1aa4a4751a017a8166a6886e67/href">https://medium.com/media/04cb6a1aa4a4751a017a8166a6886e67/href</a></iframe><p><strong>Kops</strong></p><p>If you are using kops to configure your Kubernetes Cluster, you can add following configuration to cluster manifest file as explained <a href="https://kops.sigs.k8s.io/manifests_and_customizing_via_api/">here</a> :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eabc4b0433611a60cc6bcddf990dae84/href">https://medium.com/media/eabc4b0433611a60cc6bcddf990dae84/href</a></iframe><p><strong>Kubeadm</strong></p><p>Finally, if you are using kubeadm to configure cluster add following files to cluster manifest file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9010e5980445d32aa4e119fadc53d520/href">https://medium.com/media/9010e5980445d32aa4e119fadc53d520/href</a></iframe><h3>Kubernetes Clients Configuration</h3><p>After we have configured the Kubernetes API Server, we now need to have a closer look at the Kubernetes clients, in particular the user configuration in $HOME/.kube/config used by kubectl.</p><h4><strong>Kubectl</strong></h4><p>kubectl is a commandline application used to run commands and apply configuration on the Kubernetes cluster .</p><p>There are multiple ways to configure kubectl to integrate cidaas for authentication for example OIDC Authenticator or kubelogin.</p><p>Both work perfectly well with cidaas, below you will find a short description for both options.</p><p><strong>OIDC Authenticator:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/79ecddc2bafd5380e921cb16a3e9e54d/href">https://medium.com/media/79ecddc2bafd5380e921cb16a3e9e54d/href</a></iframe><p><strong>Kubelogin:</strong></p><p>You can install <a href="https://github.com/int128/kubelogin">kubelogin</a> via following commands</p><pre># Homebrew (macOS and Linux)</pre><pre>brew install int128/kubelogin/kubelogin</pre><pre># Krew (macOS, Linux, Windows and ARM)</pre><pre>kubectl krew install oidc-login</pre><pre># Chocolatey (Windows)</pre><pre>choco install kubelogin</pre><p>You can use following command to setup kubelogin to use cidaas</p><pre>kubectl oidc-login setup --oidc-issuer-url {{ issuer_url}}--oidc-client-id {{ clientid }} --oidc-client-secret {{ clientsecret}}</pre><p><strong>Optional: Kubernetes Dashboard</strong></p><p>When operating a Kubernetes Cluster a <a href="https://github.com/kubernetes/dashboard">Kubernetes Dashboard</a> is often used to manage the cluster and its services/applications. To secure the Kubernetes Dashboard we will use <a href="https://github.com/oauth2-proxy/oauth2-proxy">OAuth2-proxy</a>. In the scenario shown below, the kubernetes-dashboard is running in a separate namespace called “kubernetes-dashboard” namespace and will be exposed on the URL kube-dashboard.cluster.de. To achieve this, the following configuration steps need to be executed:</p><ul><li>Deploy OAuth2-proxy</li><li>Deploy the Kubernetes Ingress for the Kubernetes Dashboard</li></ul><p>The OAuth2-proxy can be deployed using below configuration via kubectl:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5a7461aeb89d8ab6e252c357cc2f906/href">https://medium.com/media/c5a7461aeb89d8ab6e252c357cc2f906/href</a></iframe><p>The Kubernetes Ingress can be deployed using below configuration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/627900ba312f5e1ab97611f0ce17ecbd/href">https://medium.com/media/627900ba312f5e1ab97611f0ce17ecbd/href</a></iframe><p><strong>Access Management (RBAC — Role-based Access Control)</strong></p><p>Basic login access to Kubernetes using cidaas is now configured. Now we will have a look at access management, in particular how to manage individual user access to Kubernetes. Kubernetes is using role-based access control (RBAC), which can be integrated with the cidaas role management using Role/CusterRoles and RoleBinding/ClusterRoleBinding.</p><p>Let’s assume an easy user role setup:</p><ul><li>users with the KUBE_ADMIN role have full Kubernetes cluster access</li><li>users with the KUBE_READ role have limited read-only access to the Kubernetes cluster</li></ul><p>For KUBE_ADMIN role we create a new ClusterRoleBinding and refer to an existing role of the Kubernetes cluster using a “roleRef” to the role “cluster-admin”. This ClusterRoleBinding is the mapping between the Kubernetes ClusterRole (cluster-admin) and the cidaas role (KUBE_ADMIN). The ClusterRoleBinding in the Kubernetes config for the KUBE_ADMIN role will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ca006ae90e093d22ff13347d364a813/href">https://medium.com/media/7ca006ae90e093d22ff13347d364a813/href</a></iframe><p>Since there is no existing read role in the Kubernetes default setup, we create a new ClusterRole named “read-only-cluster-role” and define the access of this ClusterRole via the rules section. So in our use case the ClusterRole should be</p><ul><li>only allowed to perform the actions “get”, “list” and “watch” (verbs)</li><li>on all apis [“*”] (apiGroups) and</li><li>all resources [“*”] (resource)</li></ul><p>After we have defined the ClusterRole we do the same as we did for the KUBE_ADMIN mapping, we assign the ClusterRole via the ClusterRoleBinding to the KUBE_READ role in cidaas.</p><p>The ClusterRole and ClusterRoleBinding in the Kubernetes Config for the KUBE_READ role will look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/055f32e05692e0073578bc2fc29f4626/href">https://medium.com/media/055f32e05692e0073578bc2fc29f4626/href</a></iframe><p>Now we can assign the roles KUBE_ADMIN or KUBE_READ to users in cidaas to assign the required access in Kubernetes to them. If you do not know how to create roles in cidaas you can find the documentation here: <a href="https://docs.cidaas.com/user-management/user-roles.html">docs.cidaas.com</a></p><p>That’s it, we made it! We now integrated cidaas, successfully secured a Kubernetes cluster and are able to manage the access control to and in our Kubernetes cluster via the RBAC approach.</p><p>Hint: If you want to have a look what is in the token, we get back in the callback method, you can decode your Access Token easily with the <a href="https://authkit.io/">https://authkit.io/</a> online jwt decoder.</p><p>Securing a Kubernetes Cluster and managing the users as well as their access rights is crucial for a secure and productive operation. With the OAuth2 and OpenID Connect Standards it becomes easy to achieve this. This example is based on cidaas — Cloud Identity &amp; Access Management and the OpenID Connect Token feature of Kubernetes.</p><p>If you have any questions or suggestions, please leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffc58b7274b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A short introduction to Authentication in Web Apps / Single Page Applications with cidaas…]]></title>
            <link>https://cidaas.medium.com/a-short-introduction-to-authentication-in-web-apps-single-page-applications-with-cidaas-1a1429c2b377?source=rss-81b76d65c595------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a1429c2b377</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[cidaas]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[cidaas]]></dc:creator>
            <pubDate>Sun, 16 May 2021 12:53:37 GMT</pubDate>
            <atom:updated>2021-08-12T12:59:22.423Z</atom:updated>
            <content:encoded><![CDATA[<h3>A short introduction to Authentication in Web Apps / Single Page Applications with cidaas (OIDC/OAuth2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNZ7Ebm-Q67wbeKN1z8ieg.png" /><figcaption>Login and Authentication with JavaScript and cidaas</figcaption></figure><p>This story focuses on the user authentication in Web Apps / Single Page Applications using the OpenID Connect and OAuth2 Standards as well as the Cloud Identity &amp; Access Management cidaas.</p><p>cidaas (<a href="https://www.cidaas.com/">https://www.cidaas.com</a>) is a modern Cloud Identity &amp; Access Management solution developed by Widas ID located in Germany. The cidaas feature set includes:</p><ul><li>Single Sign On (SSO) based on OAuth2, OpenID Connect, SAML 2.0</li><li>Multi-Factor-Authentication with more than 14 authentication methods, including TOTP and FIDO2</li><li>Passwordless Authentication</li><li>Social Login (e.g. Facebook, Google, LinkedIn, and more) as well as Enterprise Identity Provider (e.g. SAML or AD)</li><li>Security in Machine-to-Machine (M2M) and IoT</li></ul><h3>A short introduction on OAuth2 and OpenID Connect</h3><p>OAuth2 is the industry-standard protocol for authorization, and it provides different authorization flows depending on the application or client type, be it for example web or mobile applications. If you want to learn more about OAuth2 have a look at the official website at <a href="https://oauth.net/2/">https://oauth.net/2/</a>.</p><p>OpenID Connect (OIDC) is a standard authentication protocol that adds an identification layer to the previous OAuth 2.0 standard. OIDC provides information to the end user in the form of an id token, through which the identity is verified. The standard is controlled by the OpenID Foundation (<a href="https://openid.net/">https://openid.net</a>).</p><h3>The cidaas JavaScript SDK</h3><p>Let’s get started by integrating the cidaas JavaScript SDK in a simple HTML page. The cidaas JavaScript SDK is publicly available on the cidaas github repository — <a href="https://github.com/Cidaas/cidaas-javascript-sdk">https://github.com/Cidaas/cidaas-javascript-sdk</a></p><p>The integration of the cidaas SDK is quite simple — it can be imported as script via the CDN of cidaas, as shown below:</p><p>&lt;script src=”<a href="http://cdn.cidaas.de/javascript/oidc/1.2.0/cidaas-javascript-sdk.min.js">http://cdn.cidaas.de/javascript/oidc/1.2.0/cidaas-javascript-sdk.min.js</a>&quot;&gt;&lt;/script&gt;</p><p>What’s next? — The initialization of the SDK:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8b5c9f9570683152a12cf0e4bc7f67d/href">https://medium.com/media/b8b5c9f9570683152a12cf0e4bc7f67d/href</a></iframe><p>While initializing the cidaas SDK we pass an options variable that contains a set of parameters required for the OpenID Connect and OAuth2 flows. First, we pass the authority which is basically the base URL of the cidaas tenant you are using — if you do not have a cidaas instance, you can sign up for a free cidaas Plan online (cidaas Free Plan). Next we are passing the client_id and redirect_uri of our App in the cidaas tenant. If you need some information how to create an App (OAuth2 / OpenID Connect Client) in cidaas please refer to: <a href="https://docs.cidaas.com/manage-applications/app-settings.html">docs.cidaas.com</a></p><p>Additionally, we have to pass some parameters required for the actual flows, this is especially the response_type. The Response Type parameter manages if we want to get back the authorization of a user directly as a token, e.g. as a parameter in the url, or if we want to get back a code which we exchange to a token. We recommend to use the Code Flow which prevents sharing the token publicly in the url. Moreover, it is best to use the PKCE flow to exchange the code to a token, instead of using a global Client Secret. But no worries on this, the cidaas SDK handles all that for you, so we just have to give code as parameter in the response_type and the SDK will do the trick. Next, we have to give the scopes we want to request — if you want to learn more about what scopes exactly are and how you can utilize them in cidaas, have a look at: <a href="https://docs.cidaas.com/manage-applications/scope-management.html">docs.cidaas.com</a>.</p><p>Last, we need to give the mode, this parameter defines the mechanism how the login page will be called, in our example we use redirect. To get an idea what mode means:</p><ul><li>redirect — You will be redirected to the login page</li><li>window — The login page will be opened in a new window</li><li>silent — Will initiate a silent login</li></ul><p>What’s left to do is to use the cidaas SDK to perform an authorization/authentication. The easiest way is to call the <em>cidaas.loginWithBrowser();</em> method, the SDK will then redirect to the login page on which the user can authenticate and will return after a successful authentication or a cancel event back to the redirect url configured in the options.</p><p>After we started the authentication/authorization process we now need to handle the callback to our application. As described above we either have a successful authentication or a cancel event. The cidaas SDK also provides the required functions for doing this.</p><p>On the page we redirect to, in our case …, we need the call the loginCallback method and in this, handle the successful and failed case. In the successful case, we get back the token, even so we used the code response_type, since cidaas has already exchanged the code to a token in the background. We now can use the token to get the user data or authorize against other apis. In the failure case we can just log the exception or present the user with a helpful message.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1cc80aa017d9c296bba2a8cdaaedf91b/href">https://medium.com/media/1cc80aa017d9c296bba2a8cdaaedf91b/href</a></iframe><p>That’s it we made it! We now can easily integrate the cidaas JavaScript SDK into any JavaScript application.</p><p>Hint: If you want to have a look what is in the token we get back in the callback method, you can decode your Access Token easily with the <a href="https://authkit.io/">https://authkit.io/</a> online jwt decoder.</p><p>Securing your Web Apps and Single Page Applications and managing users is important and with the OAuth2 and OpenID Connect Standards it becomes easy for consumers and developers to achieve it. This example based on the cidaas — Cloud Identity &amp; Access Management &amp; cidaas-javascript-sdk — shows how easy it can be integrated into any JavaScript application.</p><p>If you have any questions or suggestions, please leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a1429c2b377" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Login and Authentication in Android (Kotlin) with OAuth2 / OpenID Connect and cidaas]]></title>
            <link>https://cidaas.medium.com/login-and-authentication-in-android-kotlin-with-oauth2-openid-connect-and-cidaas-14b345da21df?source=rss-81b76d65c595------2</link>
            <guid isPermaLink="false">https://medium.com/p/14b345da21df</guid>
            <category><![CDATA[cidaas]]></category>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[cidaas]]></dc:creator>
            <pubDate>Wed, 14 Apr 2021 09:10:25 GMT</pubDate>
            <atom:updated>2021-04-14T09:10:25.592Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MR91MwiECSmxs1-Q-eqXDw.png" /><figcaption>Login and Authentication in Android (Kotlin) with cidaas</figcaption></figure><p>In this article we take a look at how login and authentication capabilities can be integrated into an Android App (Kotlin) based on the standards OAuth2 and OpenID Connect as well as the Cloud Identity &amp; Access Management cidaas.</p><p>cidaas (<a href="https://www.cidaas.com/">https://www.cidaas.com</a>) is a modern Cloud Identity &amp; Access Management solution developed by Widas ID located in Germany. The cidaas feature set includes:</p><ul><li>Single Sign On (SSO) based on OAuth2, OpenID Connect, SAML 2.0</li><li>Multi-Factor-Authentication with more than 14 authentication methods, including TOTP and FIDO2</li><li>Passwordless Authentication</li><li>Social Login (e.g. Facebook, Google, LinkedIn, and more) as well as Enterprise Identity Provider (e.g. SAML or AD)</li><li>Security in Machine-to-Machine (M2M) and IoT</li></ul><h3>A short introduction on OAuth2 and OpenID Connect</h3><p>OAuth2 is the industry-standard protocol for authorization, and it provides different authorization flows depending on the application or client type, be it for example web or mobile applications. If you want to learn more about OAuth2 have a look at the official website at <a href="https://oauth.net/2/">https://oauth.net/2/</a>.</p><p>OpenID Connect (OIDC) is a standard authentication protocol that adds an identification layer to the previous OAuth 2.0 standard. OIDC provides information to the end user in the form of an id token, through which the identity is verified. The standard is controlled by the OpenID Foundation (<a href="https://openid.net/">https://openid.net</a>).</p><h3>A simple Android App with Kotlin</h3><p>Let’s get started with a simple Android App based on Kotlin. We start by creating a new project with Android Studio.</p><figure><img alt="Project Setup — Android Studio" src="https://cdn-images-1.medium.com/max/454/1*paZnRMe9kiCn9Wt07ss1rw.png" /><figcaption>Project setup— Android Studio</figcaption></figure><p>As project template we choose <em>Empty Activity</em></p><figure><img alt="Project Template — Empty Activity" src="https://cdn-images-1.medium.com/max/454/1*cLyiQhbaFCvzjNzWuZ4EeQ.png" /><figcaption>Project Template — Empty Activity</figcaption></figure><p>You can select a name and package structure fitting to your purpose. For this tutorial we will go for <em>Demo App</em>and the package name: <em>de.cidaas.demoapp</em>. As programming language, we select Kotlin (this is normally prefilled) and the Minimum SDK version needs to be 21, since that is the Minimum SDK version supported by the cidaas Android SDK.</p><figure><img alt="Project Setup — Minimum SDK version" src="https://cdn-images-1.medium.com/max/453/1*--gm4-59Zhf63BbkA--Ltg.png" /><figcaption>Project Setup — Minimum SDK version</figcaption></figure><p>You will now see a simple Android project based on Kotlin, which just contains the basics. For our tutorial following files are relevant:</p><ol><li>AndroidManifest.xml</li><li>MainActivity.kt</li><li>activity_main.xml</li><li>two build.gradle files</li></ol><ul><li>one for the Project — <em>Project: Demo_App</em></li><li>one for the modules — <em>Module: Demo_App.app</em></li></ul><h3>Installation of cidaas Android SDK</h3><p>The cidaas Android SDK can be installed via jitpack.io, so we need to add jitpack to the gradle configuration in the build.gradle file for <em>Project: Demo_App.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c2c2d788d58661fe94cfcb3a11fc0bd/href">https://medium.com/media/8c2c2d788d58661fe94cfcb3a11fc0bd/href</a></iframe><p>Furthermore we need to add the cidaas Android SDK to the project by adding the dependency in the build.gradle — <em>Module: Demo_App.app.</em></p><p>The cidaas Android SDK as well as the official documentation can be found on Github: <a href="https://github.com/Cidaas/cidaas-android-sdk">https://github.com/Cidaas/cidaas-android-sdk</a> the current version while writing this tutorial is 3.0.8, please have a look at Github and use the latest version of the SDK.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a8f600e9e17851734e66041e27bf685e/href">https://medium.com/media/a8f600e9e17851734e66041e27bf685e/href</a></iframe><p>After working on the gradle files it is a good idea to build the project</p><figure><img alt="Gradle Buid" src="https://cdn-images-1.medium.com/max/433/1*SbK_xoM6WQ5rGI4KIYdk0A.png" /><figcaption>Gradle Buid</figcaption></figure><p>After the cidaas Android SDK was successfully installed we need to configure it. That is quite easy we need to get the Domain URL of our cidaas tenant as well as the ClientID and Redirect URL of our App in the tenant. If you do not have a cidaas instance, you can sign up for a free cidaas Plan online (<a href="https://sales.cidaas.com/sales-user-ui/register?plan=free">cidaas Free Plan</a>). If you need some information how to create an App (OAuth2 / OpenID Connect Client) in cidaas please refer to: <a href="https://docs.cidaas.com/manage-applications/app-settings.html#how-do-i-create-an-app">docs.cidaas.com</a></p><figure><img alt="Android project structure — cidaas.xml" src="https://cdn-images-1.medium.com/max/329/1*i3MOefAOw-W9V02exBTDxg.png" /><figcaption>Android project structure — cidaas.xml</figcaption></figure><p>The three parameters we need to enter to an XML file — cidaas.xml in the assets folder. For that you need to first create the assets folder — <em>Go to new -&gt; folder -&gt; Assets folder and click the finish button</em>. Next create a cidaas.xml file in the folder and add the three mentioned values.</p><p>In this example we used our cidaas Demo environment with a sample Client and the user profile URL as Redirect URL.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/145fe64b2f13af2787cf55c4afb8d041/href">https://medium.com/media/145fe64b2f13af2787cf55c4afb8d041/href</a></iframe><h3>Integration of Login and Authentication into the App</h3><p>Now let’s start to integrate Login and Authentication into the app. What do we want to achieve?</p><p><em>The App should display a Login Button, when clicking on the button a custom Chrome Tab should open and display the Login UI. After a successful login we want to jump back into the Android App and display the token.</em></p><p>First, we remove the present Text and add a Button to the activity_main.xml.</p><figure><img alt="Layout — activity_main.xml" src="https://cdn-images-1.medium.com/max/454/1*AE7SejJci60vo4WmgHnslA.png" /><figcaption>Layout — activity_main.xml</figcaption></figure><p>To give the button a proper text we go to the strings.xml in res/values and add a new entry for the button, for this tutorial we choose button_login_browser. Now go back to the activity_main.xml and select the button. Have a look on the right side in the Common Attributes section, there is a text parameter and click next to it to the textbox on the button to select the just defined strings.xml entry.</p><p>Next, we will implement the login functionality in the MainActivity.kt. We define a variable cidaas and initialize it in the onCreate function by <strong><em>cidaas </em></strong><em>= Cidaas.getInstance(</em><strong><em>this</em></strong><em>)</em> — the parameter <em>this</em> is the ActivityContext. The cidaas SDK instance will use the cidaas.xml as configuration file. Additionally, we can enable the cidaas SDK logs, even thus the integration of the cidaas SDK is quite simple, it can be helpful to have logs in the development process.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3135f2ff5abdf28fa6c9076373886ed7/href">https://medium.com/media/3135f2ff5abdf28fa6c9076373886ed7/href</a></iframe><p>After the cidaas SDK is initialized, we implement a Method loginWithNativeBrowser which we can assign to the onClick Event of the button we just added to the UI. In the loginWithNativeBrowser function we create a extraParam hashmap that contains the scopes we want to pass to the Authorization URL (to learn more about Scopes have a look at <a href="https://docs.cidaas.com/manage-applications/scope-management.html">docs.cidaas.com</a>). In this example we will use openid, profile and email as scopes. The extraParam hashmap we add to the cidaas Instance with <em>Cidaas.extraParams = extraParam</em>. Now it is time to call the loginWithBrowser method of the cidaas SDK which takes care of the magic, including openind the Chrome Custom Tab, calling the Authorization URL and more. While calling the loginWithBrowser function we pass the <em>ActivityContext (this)</em>, the color (in this case <em>#009900</em>) and the <em>EventResult&lt;AccessTokenEntity&gt;</em>. Moreover, we need to override/implement the two functions <em>success</em> and <em>failure</em>. The failure function should handle all failures which occur during the login process. In our tutorial we just print them to the UI with Toast.makeText. In the success case, the user is logged in and we get back a Access Token, which we can use to call further APIs, display the user Data and more. In this tutorial we just print the Access Token to the UI by <em>Toast.makeText</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b19e54f010a5554aaead304e0368a83/href">https://medium.com/media/0b19e54f010a5554aaead304e0368a83/href</a></iframe><p>After we finished the loginWithNativeBrowser function we now need to add it to the button we create above. We therefore go back to the activity_main.xml and select the button. On the right side we can select on the onClick Event the loginWithNativeBrowser function, which will then be called when clicking on the button. (Hint: if you do not see the new function in the list, save all files and build the project)</p><h3>Callback to App with In-App Links or Custom Scheme</h3><p>Whats left? — We need to handle the callback of the Custom Chrome Tab after a successful authentication.</p><p>In this tutorial we use App Links. For that we go to Tools and open the App Links Assistant. The assistant will guide us through the creation of App Links. In the first step we will add a URL intent filter and assign it to the MainActivity. Second, we need to associate the website with our App Link if you do not use the cidaas domain URL you need to publish the assetslinks file on your associated website.</p><figure><img alt="App Link Assistant — Android Studio" src="https://cdn-images-1.medium.com/max/454/1*7FBdfolsKREV7MWlTCtX2Q.png" /><figcaption>App Link Assistant — Android Studio</figcaption></figure><p>If you use the cidaas domain URL, cidaas provides you with a mobile settings section in your app settings in which you can enter your package name and the fingerprint (more at <a href="https://docs.cidaas.com/manage-applications/app-settings/native-apps/android-app.html">docs.cidaas.com</a>)</p><figure><img alt="cidaas Mobile Settings section — In App Links" src="https://cdn-images-1.medium.com/max/454/1*CqXiYgZKxHaw3TRuqm8TnA.png" /><figcaption>cidaas Mobile Settings section — In App Links</figcaption></figure><p>After this you have associated the website and the App Links you can finish the setup by clicking the button <em>Link and Verify</em> in step 3. If you want, you additionally can test the setup with the emulator in step 4.</p><figure><img alt="Android Manifest with In App Link to cidaas" src="https://cdn-images-1.medium.com/max/380/1*3uKDS-yhbJ2dShE5fLldaQ.png" /><figcaption>Android Manifest with In App Link to cidaas</figcaption></figure><p>The App Link Assistant basically creates an intent filter in the AndroidManifest.xml — in this example you will see the App Link we just created with the scheme https, the host as well as the path we added (with this path only this exact URL will redirect into the app).</p><p>After we have created App Links we need to adopt the activity to which we have added the new intent filter.</p><p>In this case the .MainActivity in the AndroidManifest.xml <br><em>&lt;activity android:name=”.MainActivity” android:launchMode=”singleTop”&gt;</em></p><p>In addition, we need to add one more function in the ActivityMain.kt, the onNewIntent, to resume the SDK after the authentication is done and the callback to the app happened.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a62d02f602ccada5d4dfdcd20a45e710/href">https://medium.com/media/a62d02f602ccada5d4dfdcd20a45e710/href</a></iframe><p>That’s it we made it! You can now either run our App on the emulator or on your real Android device. When clicking on the button, the Chrome Custom Tab opens with the Login UI of your cidaas tenant and cidaas App. When you login you get redirected back to the app and see the Access Token. Same happens if you register and the auto login feature is enabled, you will also get redirected back into the app and see the Access Token in the UI.</p><p>The Auto Login will happen either after registering directly or after verifying your email address (either by clicking on the link or entering a code in the registration process), depending on the configuration you have done in cidaas.</p><p>Hint: you can decode your Access Token easily with the <a href="https://authkit.io/">https://authkit.io/</a> online jwt decoder.</p><p>Securing Apps and managing users is important and with the OAuth2 and OpenID Connect Standards it becomes easy for consumers and developers to achieve it. This example based on the cidaas — Cloud Identity &amp; Access Management &amp; cidaas-android-sdk — shows how easy it can be integrated into your Android application.</p><p>If you have any questions or suggestions, please leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14b345da21df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure REST APIs in Golang with OAuth2 and cidaas]]></title>
            <link>https://cidaas.medium.com/secure-rest-apis-in-golang-with-oauth2-and-cidaas-c265af796890?source=rss-81b76d65c595------2</link>
            <guid isPermaLink="false">https://medium.com/p/c265af796890</guid>
            <category><![CDATA[access-management]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[cidaas]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[cidaas]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 13:37:07 GMT</pubDate>
            <atom:updated>2021-04-13T11:00:37.590Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mSrQ62COXJDqaEsMWItJXA.png" /><figcaption>Secure Rest APIs in Golang with OAuth2 and cidaas</figcaption></figure><p>This article focuses on how to secure REST APIs in Golang by using the OAuth2 standard and cidaas as Cloud Identity &amp; Access Management.</p><p>cidaas (<a href="https://www.cidaas.com/">https://www.cidaas.com</a>) is a modern Cloud Identity &amp; Access Management solution developed by Widas ID located in Germany. The cidaas feature set includes:</p><ul><li>Single Sign On (SSO) based on OAuth2, OpenID Connect, SAML 2.0</li><li>Multi-Factor-Authentication with more than 14 authentication methods, including TOTP and FIDO2</li><li>Passwordless Authentication</li><li>Social Login (e.g. Facebook, Google, LinkedIn, and more) as well as Enterprise Identity Provider (e.g. SAML or AD)</li><li>Security in Machine-to-Machine (M2M) and IoT</li></ul><h3><strong>A short introduction on OAuth2</strong></h3><p>OAuth2 is the industry-standard protocol for authorization, and it provides different authorization flows depending on the application or client type, be it for example web or mobile applications. If you want to learn more about OAuth2 have a look at the official website at <a href="https://oauth.net/2/">https://oauth.net/2/</a>.</p><h3><strong>A simple REST API with GO</strong></h3><p>The sample project created in this project uses the gorilla/mux package (<a href="https://github.com/gorilla/mux">https://github.com/gorilla/mux</a>) to create a REST API as well as the cidaas go-interceptor (<a href="https://github.com/Cidaas/go-interceptor">https://github.com/Cidaas/go-interceptor</a>) to secure the REST API via OAuth2 and cidaas.</p><p>Let’s get started with our Go application.</p><p>First, we start with creating a simple Go project with just one file: main.go</p><p>The main.go consists of the import section, the main function as well as a further function “returnHelloWorld”.</p><p>The import section imports 3 standard library packages: net/http, log and fmt as well as the gorilla/mux package via github. The main function initializes the mux router implements a HandlerFunc and the Handle to link the “/world” path with the returnHelloWorld function as well as in the end starts the server with “http.ListenAndServe”. The returnHelloWorld function returns a simple “Hello World!” when it gets called.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/572348d213b472ef62a06840482a6812/href">https://medium.com/media/572348d213b472ef62a06840482a6812/href</a></iframe><p>Give it a try. Let’s test the API and see if all works as expected. Start the go application by <em>go run main.go</em> or if you are using Visual Studio Code by <em>Run and Debug</em>. The API will be accessible via <em>localhost:8080/api/world</em>, you can call the API via any API Client, e.g. Postman (as in this example). If all goes well, you see “Hello World!” as a response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TGNERzGfcOvxzI_pZpC4xQ.png" /><figcaption>Postman API Client — Hello World! Response</figcaption></figure><h3><strong>Securing the REST API with OAuth2 and cidaas</strong></h3><p>After we have created a simple rest API we want to <strong>secure the API based on the OAuth2</strong> Standard. This means, that we have to pass a so-called Access Token while calling the API as a mean of authorization. The Access Token needs to be passed as Bearer Token in the Authorization Header. Most API Clients show a separate menu for the authorization, as postman does in our example. If you are using curl or implement it straight in your code, you should use the following Header configuration. “Authorization” : “Bearer {{token}}”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PgMaMej6qpB9kVcjjsZk6w.png" /><figcaption>Postman Authorization Header with cidaas Bearer Token</figcaption></figure><p>Now we need to have a look at how the authorization is handled in the code.</p><p>First, we install the cidaas go-interceptor</p><p>go get https://github.com/Cidaas/go-interceptor</p><p>Second, we initialize the go-interceptor in the main function. This is quite simple, the go-interceptor provides a <strong><em>New</em></strong> function with which the initialization of a new go-interceptor instance will be quite easy.</p><p>cidaasInterceptor, err := cidaasinterceptor.New(cidaasinterceptor.Options{BaseURI:&quot;https://{tenant}.cidaas.de&quot;})</p><p>The New function has one mandatory parameter, the <strong><em>BaseURI</em></strong>, which is basically the URL of the cidaas instance you are verifying the authorization too. If you do not have a cidaas instance, you can sign up for a free cidaas Plan online (<a href="https://sales.cidaas.com/sales-user-ui/register?plan=free">cidaas Free Plan</a>).</p><p>Additionally, the New function has one optional parameter <strong><em>ClientID</em></strong>, which can be passed if you want to check if the Access Token is issued by a specific OAuth2 client in cidaas. The verification with a ClientID will be helpful if you want to ensure an API can only be called by one specific application, e.g. the payment gateway which can only be called from a specific shop system.</p><p>The parameters of the go-interceptor are passed as an Options struct in the New function. The New function also returns an error, which you can use to validate the initialization, if you get an error you should handle it properly, in our example we log the error with panic.</p><p>After the cidaas go-interceptor is initialized, we can use the instance (in this example it is named cidaasInterceptor) and add it as a middleware to the Handle function. The cidaas go-interceptor offers two different verification options:</p><ul><li>VerifyTokenBySignature — verifies the token locally by decoding the Token, evaluating the expiration Time (exp) as well as the expected versus in the Token encoded scopes and roles</li><li>VerifyTokenByIntrospect — verifies the token by calling the cidaas Introspect Endpoint, to ensure the token is still valid and not expired, logged out, or revoked, as well as evaluates the expected versus the in the Token encoded scopes and roles</li></ul><p>To add either of the two verification options to the API, we just implement any of the options around the <em>httpHandler</em> in the Handle function and add the expected scopes and roles as string slice as further parameters. If no check on scopes or roles is required, we can just pass <em>nil</em> as value. In our current example, we use the scope “profile” and the role “USER” as required and the VerifyTokenBySignature option. That’s it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f179daee477a93b9ae487920f5acb4c/href">https://medium.com/media/2f179daee477a93b9ae487920f5acb4c/href</a></iframe><p>When we now call the API without a token, we get Unauthorized as response and 401 as Status Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7vPhwlLgKFUjw4OCMXqtA.png" /><figcaption>Postman Unauthorized Response — calling REST API without valid Access Token</figcaption></figure><p>But when adding a valid Token with the proper scopes from our assigned cidaas instance to the Authorization Header, we will see our “Hello World!” response.</p><p>Hint: you can decode your Access Token easily with the <a href="https://authkit.io/">https://authkit.io/</a> online jwt decoder.</p><p>Securing REST APIs is important and with the OAuth2 Standard it becomes easy for consumers and developers of an API to achieve it. This example based on the cidaas — Cloud Identity &amp; Access Management &amp; go-interceptor — shows how easy it can be integrated into your Go application.</p><p>If you have any questions or suggestions, please leave a comment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c265af796890" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>