<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">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><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><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">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>