<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">No, check-sso is used to check if user
is already logged into Keycloak server and in that case, he will
be automatically logged into your javascript application. In case
of anonymous access, user is not forced to login.<br>
<br>
Marek<br>
<br>
On 24.6.2015 16:49, Juan Diego wrote:<br>
</div>
<blockquote
cite="mid:CAJGEj6ezRQyj25e55YLo75QR3L_6gq9pqXfXPD0GJk4JxWo6vQ@mail.gmail.com"
type="cite">
<div dir="ltr">I am allowing anonymous users, would the check-sso
force my users to log?<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Jun 24, 2015 at 2:35 AM, Marek
Posolda <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:mposolda@redhat.com" target="_blank">mposolda@redhat.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>You have option to pass the tokens from local storage
to the 'init' method of keycloak object. For example you
can use something like:<br>
<br>
keycloak.init({ <br>
token: 'yourAccessToken', <br>
refreshToken: 'yourRefreshToken',<br>
idToken: 'yourIdToken'<br>
});<br>
<br>
Another option is to not store anything in localStorage,
but instead after refresh the page re-authenticate the
user again. User won't need to login again and provide
username/password, because he should be logged
automatically due to SSO (unless session is expired).
This is what our admin console and examples are doing.
Feel free to check them, especially angular example:
<a moz-do-not-send="true"
href="https://github.com/keycloak/keycloak/tree/master/examples/demo-template/angular-product-app"
target="_blank">https://github.com/keycloak/keycloak/tree/master/examples/demo-template/angular-product-app</a><br>
<br>
Marek
<div>
<div class="h5"><br>
<br>
On 23.6.2015 20:06, Juan Diego wrote:<br>
</div>
</div>
</div>
<blockquote type="cite">
<div>
<div class="h5">
<div dir="ltr">
<div>
<div>Hi,<br>
<br>
</div>
After my user logs I am saving the token to a
localstorage. I am using angularjs by the way.
<br>
<br>
</div>
<div>So if my user refreshes the page they still
have the session. As far as I can tell when you
refresh the page, most of the info of the object
keycloak is null, except for the realm and all
the stuff you get form keycloak.json. Like if
you have never logged.<br>
<br>
</div>
<div>So I stored the token in my localStorage.<br>
<br>
</div>
<div>I am thinking 3 options basically.<br>
<br>
1)<br>
</div>
<div>Setting keycloak.token =
localStorage.get("token"), and I was trying to
look for a function in that object to retrieve
all the other data, but I couldnt find any on
the documentation and looking at my
console.log(keycloak)<br>
<br>
2)<br>
</div>
<div>Storing the whole object keycloak in
localstorage, the problem with this is that it
will only store the properties and obviously not
the functions, so I was thinking that I should
manually set all the properties like this<br>
<br>
<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt"><span style="color:rgb(102,14,122);font-weight:bold">clientId </span>= localStorageService.<span style="color:rgb(102,14,122);font-weight:bold">get</span>(<span style="color:rgb(0,128,0);font-weight:bold">'keycloak'</span>).<span style="color:rgb(102,14,122);font-weight:bold">clientId</span>;
<span style="color:rgb(102,14,122);font-weight:bold">idToken </span>= localStorageService.<span style="color:rgb(102,14,122);font-weight:bold">get</span>(<span style="color:rgb(0,128,0);font-weight:bold">'keycloak'</span>).<span style="color:rgb(102,14,122);font-weight:bold">idToken</span>;
<span style="color:rgb(102,14,122);font-weight:bold">idTokenParsed </span>= localStorageService.<span style="color:rgb(102,14,122);font-weight:bold">get</span>(<span style="color:rgb(0,128,0);font-weight:bold">'keycloak'</span>).<span style="color:rgb(102,14,122);font-weight:bold">idTokenParsed</span>;
<span style="color:rgb(102,14,122);font-weight:bold">realmAccess </span>= localStorageService.<span style="color:rgb(102,14,122);font-weight:bold">get</span>(<span style="color:rgb(0,128,0);font-weight:bold">'keycloak'</span>).<span style="color:rgb(102,14,122);font-weight:bold">realmAccess</span>;
</pre>
<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">3) Just check everything against the localstorage instead.
</pre>
<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">But I wont be able to use the functions from the object keyclaok, like updateToken.
</pre>
<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">I am kind of new to angular, as you can see too.
</pre>
<pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9pt">Thanks,
</pre>
<br>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</div>
</div>
<pre>_______________________________________________
keycloak-user mailing list
<a moz-do-not-send="true" href="mailto:keycloak-user@lists.jboss.org" target="_blank">keycloak-user@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/keycloak-user" target="_blank">https://lists.jboss.org/mailman/listinfo/keycloak-user</a></pre>
</blockquote>
<br>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>