<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 21 September 2015 at 14:58, Marek Posolda <span dir="ltr">&lt;<a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF"><span class="">
    <div>On 21/09/15 14:25, Stian Thorgersen
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">What you&#39;ve listed there doesn&#39;t sound correct to
        me. Each client that requires consent (consentRequired=true) has
        to prompt the user for all roles including realm roles. So each
        client requiring consent would need to ask user for consent.</div>
    </blockquote></span>
    Indeed you&#39;re right <span><span> :-) </span></span><br><span class="">
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>How I think it would work is:</div>
        <div><br>
        </div>
        <div>* Add a &#39;offline_access&#39; realm role - in the future we can
          move this to a OpenID Connect specific namespace</div>
        <div>* If a client has &#39;full access&#39; on the scope tab it can
          obtain an offline token - no need for a separate offline
          enable toggle for this</div>
        <div>* The user has a role mapping for this (should be added by
          default as you said)</div>
        <div><br>
        </div>
        <div>A client that doesn&#39;t require consent
          (consentRequired=false) will automatically be provided with an
          offline token as long as the client either has full access or
          a scope on the realm offline_access role. For a client that
          requires consent the consent screen will first be shown,
          including all requested roles/scopes which includes the realm
          level &#39;offline_access&#39; role. One given the consent is saved
          for that specific client. When another client that requires
          consent asks for offline token the consent screen is yet again
          shown.</div>
      </div>
    </blockquote></span>
    There is one thing, that if client has scope and requires consent,
    the consent screen with &quot;Has Offline Access&quot; will be displayed even
    if offline token wasn&#39;t requested . The offline_access role will be
    also always available in access token even with &quot;classic&quot; login
    without offline token. Is this acceptable? Or should we add the flag
    on RoleModel that role will be included just if available in scope
    parameter?</div></blockquote><div><br></div><div>I don&#39;t think that&#39;s acceptable - sounds like the flag would be useful in either case at it lets us have roles the client has to actively ask for in the scope param</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"><span class="HOEnZb"><font color="#888888"><br>
    <br>
    Marek</font></span><div><div class="h5"><br>
    <br>
    <blockquote type="cite">
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On 21 September 2015 at 14:06, Marek
          Posolda <span dir="ltr">&lt;<a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div text="#000000" bgcolor="#FFFFFF">
              <div>
                <div>
                  <div>On 21/09/15 12:33, Stian Thorgersen wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr"><br>
                      <div class="gmail_extra"><br>
                        <div class="gmail_quote">On 21 September 2015 at
                          12:06, Marek Posolda <span dir="ltr">&lt;<a href="mailto:mposolda@redhat.com" target="_blank"></a><a href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>&gt;</span>
                          wrote:<br>
                          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I&#39;ve

                            sent the PR . Right now it works like this:<br>
                            <br>
                            - ClientModel has flag
                            &quot;offlineTokensEnabled&quot; . It&#39;s possible to<br>
                            retrieve offline tokens just if flag is
                            enabled<br>
                            <br>
                            - Offline token is classic refresh token
                            with 2 differences. It has type<br>
                            &quot;OFFLINE&quot; when normal refresh token has type
                            &quot;REFRESH&quot; . And for offline<br>
                            token, the expiration value is 0, so it
                            never expires.<br>
                            <br>
                            - Offline token is generated by auth-server
                            when client sends<br>
                            &quot;scope=offline_access&quot; . It&#39;s supported for
                            classic browser flow, but<br>
                            also for Direct Grant flow or Service
                            account flow.<br>
                            <br>
                            - I&#39;ve added OfflineClientSessionModel and
                            OfflineUserSessionModel with<br>
                            CRUD methods on UserModel. So when new
                            offline token is generated by<br>
                            Keycloak, some info about current
                            UserSession and ClientSession is<br>
                            persisted on UserModel. This means that
                            offline token can be used to<br>
                            create new access token even if &quot;normal&quot;
                            UserSession and ClientSession<br>
                            are already invalid or logged out.<br>
                            <br>
                            - When refreshing access token with offline
                            token, the auth-server won&#39;t<br>
                            send back another refresh token. It will
                            send just accessToken +<br>
                            IDToken. This is to avoid writes to user
                            database for each token refresh.<br>
                            <br>
                            - In account management applications tab,
                            there is new table column<br>
                            &quot;Additional grants&quot; where is shown if client
                            has offline token for user.<br>
                            The click on &quot;Revoke&quot; button will remove
                            offline tokens and granted<br>
                            consents as well - no separate actions for
                            revoke consents and offline<br>
                            tokens.<br>
                            <br>
                            <br>
                            Still TODO:<br>
                            - Properly handle consents (see &quot;Questions&quot;
                            below)<br>
                            <br>
                            - More tests, example, export/import , docs<br>
                            <br>
                            - More things/refactoring based on your
                            feedback<br>
                            <br>
                            <br>
                            Questions:<br>
                            - The specs mentions that consent should be
                            displayed when offline token<br>
                            is requested. See<br>
                            <a href="http://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess" rel="noreferrer" target="_blank">http://openid.net/specs/openid-connect-core-1_0.html#OfflineAccess</a>
                            .<br>
                            Right now, I am not doing that. So when
                            Client has &quot;isConsentRequired&quot;<br>
                            as false, the consent screen is not
                            displayed. Now we also don&#39;t have<br>
                            support for &quot;prompt=consent&quot; (not sure if we
                            need this) . Is it ok to<br>
                            keep it like this?<br>
                          </blockquote>
                          <div><br>
                          </div>
                          <div>Wording is &quot;<span style="color:rgb(0,0,0);font-family:verdana,charcoal,helvetica,arial,sans-serif">MUST

                              explicitly receive or have consent&quot; - as
                              the client does not require consent (</span>isConsentRequired=false)<span style="color:rgb(0,0,0);font-family:verdana,charcoal,helvetica,arial,sans-serif"> that

                              implies the client already has been given
                              consent by the admin.</span></div>
                          <div> </div>
                          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
                            - I am thinking about adding new builtin
                            client role &quot;offline_access&quot;,<br>
                            which will be created for client when admin
                            enables &quot;offline tokens&quot;<br>
                            switch. It will be used also as default
                            role. This will allow that just<br>
                            some users are allowed to obtain
                            offline-token (those which have this<br>
                            role). The role will be also displayed on
                            consent screen for the<br>
                            clients, which needs consent.<br>
                            But that raises another question. IMO it
                            will be good if role is<br>
                            requested and displayed on consent screen
                            just if offline token is<br>
                            requested, but not when classic refresh
                            token is requested.</blockquote>
                          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
                            Hence I was thinking about adding the flag
                            &quot;scopeParamMode&quot; to<br>
                            RoleModel. The value true means that role
                            will be requested and used in<br>
                            accessToken/refreshToken just if scope
                            parameter contains it&#39;s value.<br>
                            This will be the setup for &quot;offline_access&quot;
                            role, so it&#39;s used just for<br>
                            the offline token requests. Another thing is
                            format of scope parameter<br>
                            with respect to realm roles and application
                            roles. We can use &quot;//&quot; as<br>
                            delimiter, so realm role will have just
                            &quot;my-role&quot; but client role will<br>
                            have &quot;my-client//my-role&quot; . The disadvantage
                            is that for requesting<br>
                            offline_access you will then need to use
                            scope like:<br>
                            &quot;scope=customer-portal//offline_access&quot; as
                            it&#39;s client role.<br>
                          </blockquote>
                          <div><br>
                          </div>
                          <div>Spec says scope should be
                            &quot;offline_access&quot;, so if we use a different
                            name for it won&#39;t comply with the spec.</div>
                          <div><br>
                          </div>
                          <div>Shouldn&#39;t the offline_access role be a
                            realm role rather than a role per-client?</div>
                        </div>
                      </div>
                    </div>
                  </blockquote>
                </div>
              </div>
              The issue with realm role is, that user needs to confirm
              offline_access consent just once per all clients, which
              doesn&#39;t look correct to me. <br>
              <br>
              For example there would be 2 clients &quot;foo&quot; and &quot;bar&quot;:<br>
              - User john wants offline_access for client &quot;foo&quot;<br>
              - Consent screen is displayed with &quot;offline_access&quot; role
              and he confirms it<br>
              - Then user john wants offline_access for client &quot;bar&quot;<br>
              - There is no &quot;offline_access&quot; anymore on consent screen
              because john already has consent for realm role
              &quot;offline_access&quot; . <br>
              <br>
              <br>
              IMO it should be &quot;offline_access&quot; displayed again as it&#39;s
              different client. Also logically offline_access is granted
              per client, so the text on the grant screen is:<br>
              <br>
              &quot;has Offline Access in foo&quot;<br>
              <br>
              or <br>
              <br>
              &quot;has Offline Access in bar&quot;<br>
              <br>
              which will be with client roles.<span><br>
                <br>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div class="gmail_extra">
                      <div class="gmail_quote">
                        <div><br>
                        </div>
                        <div>Another thing to consider is that we&#39;ll be
                          moving to role namespaces instead of
                          realm/client roles soon. In that case we might
                          want a OpenID Connect namespace that can hold
                          these scopes. So role could be
                          &quot;openid/offline_access&quot;.</div>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </span> Ok. Maybe for now I won&#39;t do anything tricky but
              just limit the scope param support to client roles of
              current client. So scope &quot;offline_access&quot; is
              &quot;offline_access&quot; role of current client. We can improve it
              later once we add role namespaces support. WDYT? <br>
              <span><font color="#888888"> <br>
                  Marek</font></span><span><br>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div class="gmail_extra">
                      <div class="gmail_quote">
                        <div> </div>
                        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
                          WDYT? Any better idea?<br>
                          <br>
                          Marek<br>
_______________________________________________<br>
                          keycloak-dev mailing list<br>
                          <a href="mailto:keycloak-dev@lists.jboss.org" target="_blank">keycloak-dev@lists.jboss.org</a><br>
                          <a href="https://lists.jboss.org/mailman/listinfo/keycloak-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-dev</a><br>
                        </blockquote>
                      </div>
                      <br>
                    </div>
                  </div>
                </blockquote>
                <br>
              </span></div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div></div>