<?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 Narendran Lingaraj on Medium]]></title>
        <description><![CDATA[Stories by Narendran Lingaraj on Medium]]></description>
        <link>https://medium.com/@narendran.lingaraj?source=rss-e01d1c03725------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nHPcH81paaKAl7LypOg5GQ.png</url>
            <title>Stories by Narendran Lingaraj on Medium</title>
            <link>https://medium.com/@narendran.lingaraj?source=rss-e01d1c03725------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:29:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@narendran.lingaraj/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[OKTA-hook-AAD — Part1: InlineHook]]></title>
            <link>https://medium.com/@narendran.lingaraj/okta-hook-aad-part1-inlinehook-dee5304b5452?source=rss-e01d1c03725------2</link>
            <guid isPermaLink="false">https://medium.com/p/dee5304b5452</guid>
            <dc:creator><![CDATA[Narendran Lingaraj]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 00:48:35 GMT</pubDate>
            <atom:updated>2022-06-01T12:01:28.130Z</atom:updated>
            <content:encoded><![CDATA[<h4>OKTA Token Inline Hook for Azure AD Group Claims as Name</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2iKpA01gZP0ptSb6gkFjSw.png" /><figcaption>OKTA WEDS Azure AD:(Image Sources: Google)</figcaption></figure><p>Integrating Azure AD with OKTA as External IDP and extract MS Graph Claims. GroupNames as Claims from Azure without GUID.</p><p>#OKTAINLINEHOOK #GROUPNAMECLAIMS</p><p><strong>Pre-requisite:</strong></p><ol><li>OKTA Developer/Trial Account [<a href="https://www.okta.com/free-trial/">https://www.okta.com/free-trial/</a>]</li><li>Azure Trial Subscription [<a href="https://azure.microsoft.com/free/?WT.mc_id=A261C142F">Create an account for free</a>.]</li><li>OIDC/OAUTH Knowledge [<a href="https://auth0.com/intro-to-iam/what-is-oauth-2/">https://auth0.com/intro-to-iam/what-is-oauth-2/</a>]</li><li>Python/Nodejs scripting basics</li><li>AWS Lambda/Azure Functions or self hosting capability.</li></ol><p>A. <a href="https://docs.aws.amazon.com/lambda/latest/dg/welcome.html">https://docs.aws.amazon.com/lambda/latest/dg/welcome.html</a></p><p>B. <a href="https://azure.microsoft.com/en-us/services/functions/">https://azure.microsoft.com/en-us/services/functions/</a></p><p><strong>Description:</strong></p><p>We would be going to add Azure AD as an external Identity Provider [IDP] in OKTA and use OKTA IDP rule to perform Discovery {Home Realm Discovery — if your are from Active Directory Federation Services Background} based on Domain Name.</p><p>This is purely a lab based setup and please do cautiously perform the actions on any of your required environment and I do not guarantee or promise for any liabilities….blah..blah</p><p><strong>Picture Paints 1000 words:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmBvjL8tKQK1cAedxnwaVA.png" /><figcaption>Azure AD as External IDP and Microsoft Graph Inline Usage.[icon sources: Google]</figcaption></figure><p>Hope you understood. Stop talking., lets do it…oops(did you really count the words… not 1000).</p><p><strong>Azure AD Setup:</strong></p><ol><li>Guide to create an App registration: <a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app">https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app</a></li></ol><p>Boring to read article: Yea’h Picture Again navigate to <a href="https://portal.azure.com/#home">https://portal.azure.com/#home</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_iD1AFhIE9Wk5qV6sOp8Ng.png" /></figure><p>please click the burger before I say click :) look for Azure Active Directory</p><p>Click and select App Registrations from the Overview Page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yfCMjGo3w5t76hTIT_t3XQ.png" /><figcaption>Home &gt; Azure Active Directory &gt; App Registration</figcaption></figure><p>Keep Clicking…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VX3VIj9gRXtAGLz-GsMU8Q.png" /><figcaption>New App Registration.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxuAz8zKxj6RmVlTiVFBdA.png" /><figcaption>Sample App Registration</figcaption></figure><p>a. Enter an Unique Application Name</p><p>b. Select tenancy coverage, remember MS warns Multi tenancy with MPN ID</p><p>c. Choose Web from platform and just enter <a href="https://jwt.ms,/">https://jwt.ms,</a> we will replace with OKTA URL Later.</p><p>d. Yes, Click Register</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7f4xIRnhWQ-LV5oH6mxlw.png" /><figcaption>Client ID and Tenant ID</figcaption></figure><ol><li>Capture Application/Client ID</li></ol><p>2. Capture Tenant / Organization ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M_xBhP6w5YJqdPMP2ySzRg.png" /><figcaption>Add New Client Secret</figcaption></figure><p>3. Create a new Secret for Graph Access with Application Token. I chose Secret, if you wish Certificates you can generate one :).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y_F5lE1HS92Ao5HxhdSajg.png" /><figcaption>Client Secret Naming Ceremony</figcaption></figure><p>Copy the secret before Microsoft Hides it and you cant retrieve it again :) Handy Vault Helps…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6zYj7Jck5gE07dS0RkKZQ.png" /><figcaption>Client Secret: This is OPEN : HE-HE-HE</figcaption></figure><p>Now we have captured CLIENT_ID, TENANT_ID,CLIENT_SECRET.</p><p>Lets set some Scope for Consumption:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcbq0GJK1prmpdFBn2YQDA.png" /><figcaption>Add Permission for Graph</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxixiD5ZK3OfOklbslArSQ.png" /><figcaption>Complete Permission</figcaption></figure><p>Consent for the Claims, if you dont have access, you know, please reach out to your Global Administrator, You need Privileged Identity Role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oB0J-58USGoBrT68Hz7tXQ.png" /><figcaption>Granting Admin Consent</figcaption></figure><p><strong>OKTA Setup:</strong></p><p>Login to OKTA Tenant as Admin <a href="https://dev-24236525-admin.okta.com/admin/access/identity-providers">https://dev-{YourDomainID}-admin.okta.com/</a> and navigate to Security and Identity Providers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z3fTGM8VGoO2UNIN1pXw8w.png" /><figcaption>OKTA External Identity Providers</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoNXZcTh6OJqs8anH-880w.png" /><figcaption>Select Microsoft/OpenID for External IDP</figcaption></figure><p>Both Microsoft and OpenID options work, the only disadvantage over the template version to OpenID is that you would be able to create custom Claims to map in OpenID while Microsoft Template do not provide any options to add at the time of this writing….#Hope they will take the feedback.</p><p>Fill in all the Captured information earlier into OKTA Configuration Page</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f9TT9F9R9_vFBLj20IptLg.png" /><figcaption>Section 1: External IDP — Add Client_ID and Secret</figcaption></figure><p>Section 2: Continue remaining half of the Image</p><p>Since I am using JIT [ Just-In-Time] provisioning dynamically keep user in OKTA and do not Synchronize I have chosen these options. You can perform this at your own preferences.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6fYTxSRTXzw6Vqv3jpwB-Q.png" /><figcaption>Complete Just-in-Time if required.</figcaption></figure><p>Navigate to IDP rules once you add the IDP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DBeo1peqT0-JuaicKzHYw.png" /></figure><p>Name your rule, choose other options necessary and remember to chose the IDP for AzureAD. If you need all of the users to login with AzureAD then leave the Domain list on login to default. Since I had to redirect for my customer based on their preference I have chosen based on domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcuRuXWZulDjXvJVUMGExA.png" /><figcaption>IDP Routing Rule.</figcaption></figure><p><strong>Setting Up InlineHook [AWS-LAMBDA/AZURE-FUNCTIONS]</strong></p><p>I have provided a Python Code which works for both Azure Functions {HTTP Trigger}and AWS Lambda. The code is based on Python.</p><p>You can place them on your environment with any API / Token Credentials</p><p>&lt;pre&gt;</p><p>import json</p><p>import os</p><p>import logging</p><p>import traceback</p><p>import requests</p><p>import azure.functions as func</p><p>graph_user_groups_url = “https://graph.microsoft.com/v1.0/users/{user_id}/transitiveMemberOf/microsoft.graph.group?$count=true&amp;$select=displayName,securityEnabled&quot;</p><p>token_endpoint_url = “https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token&quot;</p><p>tenant_id = “”</p><p>client_id = “”</p><p>client_secret = “”</p><p>def env():</p><p>global tenant_id, client_id, client_secret</p><p>if os.getenv(“TENANT_ID”):</p><p>tenant_id = os.getenv(“TENANT_ID”)</p><p>if os.getenv(“CLIENT_ID”):</p><p>client_id = os.getenv(“CLIENT_ID”)</p><p>if os.getenv(“CLIENT_SECRET”):</p><p>client_secret = os.getenv(“CLIENT_SECRET”)</p><p>def main(req: func.HttpRequest) -&gt; func.HttpResponse:</p><p>logging.info(‘Python HTTP trigger function processed a request.’)</p><p>event_id = “”</p><p>try:</p><p>env()</p><p>req_body = req.get_json()</p><p>event_id = req_body[‘eventId’]</p><p>logging.info(“Processing okta request event id: “ + event_id)</p><p>logging.debug(“OKTA Request “ + json.dumps(req_body))</p><p>claims = req_body[‘data’][‘access’][‘claims’]</p><p>azure_user_email = claims[‘sub’]</p><p>final_groups_list = []</p><p># — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — #</p><p># GET NAME FROM AZURE ENDPOINT</p><p>token_url = token_endpoint_url.format(tenant=tenant_id)</p><p>logging.debug(“Token URL “ + token_url)</p><p>token_response = requests.post(</p><p>url=token_url,</p><p>data={</p><p>“client_id”: client_id,</p><p>“scope”: “https://graph.microsoft.com/.default&quot;,</p><p>“client_secret”: client_secret,</p><p>“grant_type”: “client_credentials”</p><p>})</p><p>if token_response.status_code != 200:</p><p>logging.info(“Unable to retrieve token due to “ + str(token_response.status_code))</p><p>logging.debug(“Response: “ + token_response.text)</p><p>raise ValueError(“Unable to get token”)</p><p>token_response_data = token_response.json()</p><p>logging.debug(“Token Response “ + json.dumps(token_response_data))</p><p>access_tk = token_response_data[‘access_token’]</p><p>logging.info(“Accessing groups for “ + azure_user_email)</p><p>groups_response = requests.get(</p><p>url=graph_user_groups_url.format(user_id=azure_user_email),</p><p>headers={</p><p>“Authorization”: “Bearer {access_token}”.format(access_token=access_tk)</p><p>})</p><p>if groups_response.status_code != 200:</p><p>logging.info(“Unable to retrieve groups due to “ + str(groups_response.status_code))</p><p>logging.debug(“Response: “ + groups_response.text)</p><p>raise ValueError(“Unable to get groups”)</p><p>groups_response_data = groups_response.json()</p><p>logging.debug(“AZ Group Response “ + json.dumps(groups_response_data))</p><p>groups_response_data_values = groups_response_data[‘value’]</p><p>for item in groups_response_data_values:</p><p>if item[‘securityEnabled’]:</p><p>final_groups_list.append(item[‘displayName’])</p><p># — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — #</p><p>opt = [{‘op’: ‘replace’, ‘path’: “/claims/azgroups”, ‘value’: final_groups_list}]</p><p>response = {‘commands’: [{</p><p>‘type’: “com.okta.access.patch”,</p><p>‘value’: opt</p><p>}]}</p><p>logging.debug(“Result: “ + json.dumps(response))</p><p>return func.HttpResponse(json.dumps(response), mimetype=’application/json; charset=utf-8&#39;)</p><p>except ValueError:</p><p>traceback.print_exc()</p><p>return func.HttpResponse(</p><p>json.dumps(</p><p>{</p><p>“error”: “API Exception for event Id: “ + event_id</p><p>}</p><p>), mimetype=’application/json; charset=utf-8&#39;, status_code=500</p><p>)</p><p>&lt;/pre&gt;</p><p><strong>Azure Function Token Example</strong></p><p>Once you create Azure functions, create a secret for Authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a1ixG23DTcXweZpKA8FBEw.png" /><figcaption>API Token for Authentication</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3SywUzZzI0u2206-BkenA.png" /><figcaption>Copy the Keys once Generated.</figcaption></figure><p><strong>Configure OKTA Inline Token:</strong></p><p><strong>Ref: </strong><a href="https://developer.okta.com/docs/reference/token-hook/">https://developer.okta.com/docs/reference/token-hook</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BuHvejgpEuGuZZ3FM-Ebvg.png" /><figcaption>Navigate to Workflow &gt; Inline Hooks &gt; Add Inline Hooks &gt; Token</figcaption></figure><p>Painting more words in pictures :)., Get function URL from Azure Functions App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_WA6MS2kqDc8IarKdsnh6A.png" /><figcaption>Function URL for Next Section.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pGslvexz9Sy6n4CmRKClGg.png" /><figcaption>Copy the URL to OKTA Setup</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7gLnA2saqMiwGieYjTQLg.png" /><figcaption>Set the Name and URL and Save the same.</figcaption></figure><p>Your result</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p08-btgaIep5egD4ez2Y-Q.png" /><figcaption>Overview: Dont copy the Code: Its obfuscated :)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*puqZJbuSP26834TqpQ99zA.png" /><figcaption>Set Authorization Server to Validate your Tokens and Process Inline Hook</figcaption></figure><p>Setting flow for the Authorizations. Refer Inline Hook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e0TDKVzNtsAnmEhP2L4uDg.png" /><figcaption>Navigate to your Authorization Server and Select Access Policies.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umZEuAdMLcC2q301l1Dg0g.png" /><figcaption>Name your Policy</figcaption></figure><p>Click Add rule under the policy</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxrfEF-0OpFDViq_6qbndg.png" /></figure><p>Enter Rule Name, select your type of OAUTH Flows.</p><blockquote>IMPORTANT: Select inline Hook that you just created.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*HiMhhMnWuAxUsbHjHmSJZQ.png" /><figcaption>Rule for Inline Hook.</figcaption></figure><p>Navigate to Security Identity Providers and expand the IDP you added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*669pju0Zc2vaEFSsAEH6zg.png" /><figcaption>Navigate to Security &gt; Identity Providers</figcaption></figure><p>Copy the Redirect URI from your IDP</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cTJ4kJYIfVuk3Rxm_V8gcA.png" /></figure><p>Paste it on Azure App Authentication</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zj6NNWVS1s8L6KPkfbXzTA.png" /></figure><p><strong>ALL SET AND DONE TO TEST YOUR APP TO GET CLAIMS</strong></p><p>I Will provide a video sooner :)</p><p>If you like the article and would like to Buy Me a Coffee ??</p><p><a href="https://www.buymeacoffee.com/grumpyogi">https://www.buymeacoffee.com/grumpyogi</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dee5304b5452" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>