<div dir="ltr"><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">Hi,<br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)"><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">regarding multi-tenancy in keycloak, where each tenant maps to a realm, I wanted to ask for help on clarifying some key concepts in keycloak for aid in implementing a simple REST based identity management POC.<br><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">Imagine there is a requirement for a multi-tenant environment where user registration (=creation) , user login, user logout and knowing whether a user is still logged in or not must be done over some wrapper REST service which exposes the mentioned functionality to outside world.<br><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">With KeyCloak being deployed in a private network, I have written some wrapper  REST service which does create users for a desired tenant (=realm), and this wrapper service itself calls KeyCloak&#39;s &quot;<b>Direct Grant API</b>&quot; from an <b>OAuth</b> Client with <b>Super-User</b> Credentials both defined in the &quot;<b>master</b>&quot; realm having sufficient privileges over all realms (as defined by the documentation in<font size="4"><span style="font-weight:normal"> &quot;Chapter 17. Admin REST API&quot;</span></font>).<br><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">Now I want to be able to wrap the logging-in and logging-out process of a user into a tenant in the same way as user creation, which I don&#39;t know how to work around this scenario exactly<br><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">there are some different questions in my head, regarding the situation explained in my head which I wanted to ask :<br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)"><ul><li>to be able to log a user in/out, <u>through  a wrapper rest service</u> , <i>which has been passed the user credential to and wants to use KeyCloak REST APIs</i>, should I create an OAuth client per each realm and login/log out the user, using the related OAuth client in each realm ?</li><li>Which REST API provides information on whether a specific user is already logged in or not on a specific realm?</li><li>How &quot;Application&quot; concept in keycloak differs from &quot;OAuth Client&quot; and does it make sense to log a user to an application (over REST API), if yes how this is  different  from logging a user into a realm with OAuth Client ?<br></li></ul></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">Thanks Alot,<br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)">I really appreciate your help.<br><br><br></div><div class="gmail_default" style="font-family:garamond,serif;font-size:large;color:rgb(12,52,61)"><br></div></div>