<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tokeninfo &#8211; privacyID3A</title>
	<atom:link href="https://www.privacyidea.org/tag/tokeninfo/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.privacyidea.org</link>
	<description>flexible, Open Source Multi Factor Authentication (2FA)</description>
	<lastBuildDate>Thu, 09 Nov 2017 21:43:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.privacyidea.org/wp-content/uploads/2016/06/cropped-only-logo-white-background-32x32.png</url>
	<title>Tokeninfo &#8211; privacyID3A</title>
	<link>https://www.privacyidea.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Highest flexibility with the tokeninfo fields</title>
		<link>https://www.privacyidea.org/highest-flexibility-tokeninfo-fields/</link>
		
		<dc:creator><![CDATA[Cornelius Kölbel]]></dc:creator>
		<pubDate>Thu, 09 Nov 2017 21:43:06 +0000</pubDate>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Event Handler]]></category>
		<category><![CDATA[Tokeninfo]]></category>
		<guid isPermaLink="false">https://www.privacyidea.org/?p=1273</guid>

					<description><![CDATA[On a wish list for another OTP solutions I saw the requirement to have an &#8220;enrollment date&#8221; or a &#8220;last use date&#8221; of a token. Well, you might know, that privacyIDEA can do all this. Then you are welcome to skip this blog post and visit the privacyIDEA community to help answering questions there. Thanks [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>On a wish list for another OTP solutions I saw the requirement to have an &#8220;enrollment date&#8221; or a &#8220;last use date&#8221; of a token.</p>
<p>Well, you might know, that privacyIDEA can do all this. Then you are welcome to skip this blog post and visit the <a href="https://community.privacyidea.org" target="_blank" rel="noopener">privacyIDEA community</a> to help answering questions there. Thanks a lot! If not &#8211; go on reading!</p>
<h2>The tokeninfo table</h2>
<p>Every token has its own Tokeninfo table, that can hold any additional arbitrary information. In the UI it looks like this:</p>
<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/Bildschirmfoto-vom-2017-11-09-21-50-29.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-1274 size-full" src="https://www.privacyidea.org/wp-content/uploads/2017/11/Bildschirmfoto-vom-2017-11-09-21-50-29.png" alt="" width="565" height="75" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/Bildschirmfoto-vom-2017-11-09-21-50-29.png 565w, https://www.privacyidea.org/wp-content/uploads/2017/11/Bildschirmfoto-vom-2017-11-09-21-50-29-300x40.png 300w" sizes="auto, (max-width: 565px) 100vw, 565px" /></a></p>
<p>It tells us that the used hashlib is &#8220;sha1&#8221; and the token was used 3 times for authentication.</p>
<p>On the database level the tokeninfo is a table on its own, which means that every token can hold as many token information as it needs to:</p>
<figure id="attachment_1275" aria-describedby="caption-attachment-1275" style="width: 724px" class="wp-caption aligncenter"><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/tokeninfo-table.png"><img loading="lazy" decoding="async" class="wp-image-1275 size-full" src="https://www.privacyidea.org/wp-content/uploads/2017/11/tokeninfo-table.png" alt="" width="724" height="215" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/tokeninfo-table.png 724w, https://www.privacyidea.org/wp-content/uploads/2017/11/tokeninfo-table-300x89.png 300w" sizes="auto, (max-width: 724px) 100vw, 724px" /></a><figcaption id="caption-attachment-1275" class="wp-caption-text">A view on the tokeninfo database table</figcaption></figure>
<p>It does not matter where and how you add tokeninfos to this table. privacyIDEA will use them.</p>
<p>privacyIDEA knows some default or preserve keywords, for which it is using the tokeninfo table. This is the <a href="http://privacyidea.readthedocs.io/en/latest/modules/lib/tokenclass.html#privacyidea.lib.tokenclass.TokenClass.get_validity_period_end" target="_blank" rel="noopener">validity period</a> of a token, that is denoted with &#8220;validity_period_start&#8221; and &#8220;validity_period_end&#8221;, the &#8220;count_auth&#8221; or &#8220;count_auth_success&#8221; and also markes that define for how many authentications a token can be used.</p>
<p>But you can also set any other value.</p>
<h2>Event Handler and tokeninfo</h2>
<p>There are probably many ways to set tokeninfo fields, but obviously the most interesting way is the event handler. If you do not know the event handler yet, you can either read about it in <a href="https://www.privacyidea.org/most-flexible-two-factor-authentication-handling-your-events/">our blog</a> or in the <a href="http://privacyidea.readthedocs.io/en/latest/eventhandler/index.html" target="_blank" rel="noopener">online documentation</a>.</p>
<p>Using the <strong>Token Handler</strong> you can set a tokeninfo field during any REST API call. You could e.g. set a tokeninfo field &#8220;enrollment_date&#8221; and hook it to the event <strong>/token/init</strong>.</p>
<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/event-enrollment-date.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1278" src="https://www.privacyidea.org/wp-content/uploads/2017/11/event-enrollment-date.png" alt="" width="840" height="663" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/event-enrollment-date.png 840w, https://www.privacyidea.org/wp-content/uploads/2017/11/event-enrollment-date-300x237.png 300w, https://www.privacyidea.org/wp-content/uploads/2017/11/event-enrollment-date-768x606.png 768w" sizes="auto, (max-width: 840px) 100vw, 840px" /></a></p>
<p>As mentioned, you can set any arbitrary tokeninfo field. In this case we set the &#8220;enrollment_date&#8221; to the current time. The timestamp of the current time will be saved in the token info.</p>
<p>Well, why not immediately and automatically set the validity period? No problem: The value can not only use tags, but also <a href="http://privacyidea.readthedocs.io/en/latest/eventhandler/tokenhandler.html#set-tokeninfo" target="_blank" rel="noopener">some other magic</a>:</p>
<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/set-validity.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1279" src="https://www.privacyidea.org/wp-content/uploads/2017/11/set-validity.png" alt="" width="847" height="674" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/set-validity.png 847w, https://www.privacyidea.org/wp-content/uploads/2017/11/set-validity-300x239.png 300w, https://www.privacyidea.org/wp-content/uploads/2017/11/set-validity-768x611.png 768w" sizes="auto, (max-width: 847px) 100vw, 847px" /></a></p>
<p>Setting the value of &#8220;validity_period_end&#8221; to &#8220;{current_time}+12&#8221; will result in a timestamp, that is 12 days in the future. Combining this with the reserved key &#8220;validity_period_end&#8221; we can automatically enroll tokens, that are only valid for 12 days!</p>
<h2>How to use tokeninfo fields</h2>
<p>privacyIDEA knows how to use the preserved tokeninfo fields. These actions are hard wired into the code.<br />
Of course you can use any arbitrary field simply to pass information to a help desk employee or to store some notes. But there are again at lease two interesting way how to automatically use the tokeinfo field.</p>
<h3>Again the event handler</h3>
<p>Again &#8211; you can use the tokeninfo field with the event handler. <a href="http://privacyidea.readthedocs.io/en/latest/eventhandler/index.html#basic-conditions" target="_blank" rel="noopener">But this time as a condition</a>. For any REST API call you can check the tokeninfo field of the token involved. And if any arbitrary (I like this word!) tokeninfo field matches your condition, you can trigger a new action.</p>
<p>A condition could be anything or a fixed timestamp but also &#8211; again &#8211; &#8220;{now}&#8221;:</p>
<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/condition-now.png"><br />
<img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1284" src="https://www.privacyidea.org/wp-content/uploads/2017/11/condition-now.png" alt="" width="947" height="339" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/condition-now.png 947w, https://www.privacyidea.org/wp-content/uploads/2017/11/condition-now-300x107.png 300w, https://www.privacyidea.org/wp-content/uploads/2017/11/condition-now-768x275.png 768w" sizes="auto, (max-width: 947px) 100vw, 947px" /></a></p>
<p>This way we can check if the tokeninfo field &#8220;validity_period_end&#8221; has a youger timestamp than the current moment. Only if the condition applies the defined action will be triggered.</p>
<p>But often &#8220;now&#8221; is not the right moment!</p>
<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/tokenenrolled-lastweek.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1285" src="https://www.privacyidea.org/wp-content/uploads/2017/11/tokenenrolled-lastweek.png" alt="" width="921" height="273" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/tokenenrolled-lastweek.png 921w, https://www.privacyidea.org/wp-content/uploads/2017/11/tokenenrolled-lastweek-300x89.png 300w, https://www.privacyidea.org/wp-content/uploads/2017/11/tokenenrolled-lastweek-768x228.png 768w" sizes="auto, (max-width: 921px) 100vw, 921px" /></a></p>
<p>In this example the action will only trigger, if the &#8220;enrollment_date&#8221; is older than one week. You can use the tag &#8220;{now}-7d&#8221; which will result in a timestamp of last week!</p>
<p>Combined with the event handlers for <strong>notification, scripting, token handling or federation</strong> the administrator can probably define anything and automate a lot of processes!</p>
<h3>Clean it! The token janitor</h3>
<p>There is also another way of using the tokeninfo fields. It is the tokenjanitor script.</p>
<p>The privacyidea-token-janitor runs as a script from the command line and find specific tokens and perform actions on these tokens. It was first used to <a href="http://privacyidea.readthedocs.io/en/latest/modules/lib/tokenclass.html#privacyidea.lib.tokenclass.TokenClass.is_orphaned" target="_blank" rel="noopener">find orphaned tokens</a> and possibly delete these orphaned tokens.</p>
<p>But of course the token-janitor can find tokens based on may conditions &#8211; also based on the tokeninfo field.</p>
<p><a href="https://www.privacyidea.org/wp-content/uploads/2017/11/privacyidea-token-janitor.png"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1289" src="https://www.privacyidea.org/wp-content/uploads/2017/11/privacyidea-token-janitor.png" alt="" width="928" height="400" srcset="https://www.privacyidea.org/wp-content/uploads/2017/11/privacyidea-token-janitor.png 928w, https://www.privacyidea.org/wp-content/uploads/2017/11/privacyidea-token-janitor-300x129.png 300w, https://www.privacyidea.org/wp-content/uploads/2017/11/privacyidea-token-janitor-768x331.png 768w" sizes="auto, (max-width: 928px) 100vw, 928px" /></a></p>
<p>This way the administrator can use the tokeninfo field to mark tokens and e.g. delete all marked tokens. The condition can also be a timestamp in the tokeninfo field. Actions can also be to disable or enable a token or only to mark this token (in the tokeninfo field).</p>
<p>&nbsp;</p>
<p>If you thought privacyIDEA is cool &#8211; you may realize you were wrong.</p>
<p>privacyIDEA is extremely cool!</p>
<p>So use it! &#8211; share your ideas at the <a href="https://community.privacyidea.org" target="_blank" rel="noopener">community</a> or enlighten use with your <a href="https://github.com/privacyidea/privacyidea" target="_blank" rel="noopener">pull request at github</a>!</p>
<p>If you also want to be cool &#8211; you may also <a href="https://netknights.it/en/unternehmen/job-offers/" target="_blank" rel="noopener">apply for a job at the cool guys!</a> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
