<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>chrisonoracle</title>
	<atom:link href="https://chrisonoracle.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://chrisonoracle.wordpress.com</link>
	<description>A blog about Application Express and Oracle related topics.</description>
	<lastBuildDate>Fri, 27 Jan 2012 16:03:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='chrisonoracle.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s-ssl.wordpress.com/i/buttonw-com.png</url>
		<title>chrisonoracle</title>
		<link>https://chrisonoracle.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://chrisonoracle.wordpress.com/osd.xml" title="chrisonoracle" />
	<atom:link rel='hub' href='https://chrisonoracle.wordpress.com/?pushpress=hub'/>
		<item>
		<title>How to create an APEX 4.1 authorization plugin</title>
		<link>https://chrisonoracle.wordpress.com/2011/05/09/how-to-create-an-apex-4-1-authorization-plugin/</link>
		<comments>https://chrisonoracle.wordpress.com/2011/05/09/how-to-create-an-apex-4-1-authorization-plugin/#comments</comments>
		<pubDate>Mon, 09 May 2011 13:51:59 +0000</pubDate>
		<dc:creator>chrisonoracle</dc:creator>
				<category><![CDATA[APEX]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://chrisonoracle.wordpress.com/?p=5</guid>
		<description><![CDATA[The EA1 for APEX 4.1 is out, so people are trying to use what we built for the last months, hopefully with success. Building Authorization Plugins was one of my tasks. The new plugin architecture allows developers to build authorizations in a declarative way, instead of copying and pasting SQL and PL/SQL code. Here&#8217;s a small walkthrough on how [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrisonoracle.wordpress.com&amp;blog=22937747&amp;post=5&amp;subd=chrisonoracle&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The EA1 for APEX 4.1 is <a href="http://tryapexnow.com/">out</a>, so people are trying to use what we built for the last months, hopefully with success. Building Authorization Plugins was one of my tasks. The new plugin architecture allows developers to build authorizations in a declarative way, instead of copying and pasting SQL and PL/SQL code. Here&#8217;s a small walkthrough on how to make use of it. The example plugin can be used for authorizations using the built-in user and group management of APEX.</p>
<ol>
<li>Go to Shared Components / Plug-ins</li>
<li>Click &#8220;Create &gt;&#8221;</li>
<li>Enter Name: APEX Group Authorization</li>
<li>Enter Internal Name: COM.MY-COMPANY.APEX.GROUP-AUTH</li>
<li>Enter Type: Authorization Scheme Type</li>
<li>Enter PL/SQL Code:
<pre>function is_authorized (
    p_authorization in apex_plugin.t_authorization,
    p_plugin        in apex_plugin.t_plugin )
    return apex_plugin.t_authorization_exec_result
is
    l_group  varchar2(4000) := p_authorization.attribute_01;
    l_count  number;
    l_result apex_plugin.t_authorization_exec_result;
begin
    select count(*)
      into l_count
      from apex_workspace_group_users
     where user_name  = p_authorization.username
       and group_name = l_group;

    l_result.is_authorized := l_count &gt; 0;
    return l_result;
end is_authorized;</pre>
</li>
<li>Enter Execution Function Name: is_authorized</li>
<li>Click &#8220;Create&#8221;</li>
<li>Click &#8220;Add Attribute&#8221;</li>
<li>Enter Label: Group Name</li>
<li>Enter Type: Text</li>
<li>Enter Required: Yes</li>
<li>Click &#8220;Create&#8221;</li>
</ol>
<p>The plugin has been created. Now we define an authorization based on the plugin.</p>
<ol start="14">
<li> Go to Shared Components / Authorization Schemes</li>
<li>Click &#8220;Create &gt;&#8221;</li>
<li>Click &#8220;Next &gt;&#8221;</li>
<li>Enter Name: Is Manager</li>
<li>Enter Scheme Type: APEX Group Authorization [Plug-in]</li>
<li>Enter Group Name: Manager</li>
<li>Enter Error Message: Only Managers can see that<em> (it gets displayed if a page or application authorization fails)</em></li>
<li>Click &#8220;Create&#8221;</li>
</ol>
<p>To test our authorization scheme, we have to create users and assign groups to them, then apply the authorization to some pages, regions or items. But I&#8217;m sure you already know how to do that <img src='https://s-ssl.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>In APEX 4.0, you would have probably built the authorization scheme using an exists SQL query. And copied the query to every other group authorization scheme (Is Sales, Is Accounting, &#8230;), which is harder to maintain. Plugins can help to encapsulate the authorization code in one place and prevent mistakes.</p>
<p>Because EA1 users do not have easy access to APEX package specs, here are the data type declarations for authorization plugins:</p>
<pre>create or replace package wwv_flow_plugin as
...
type t_authorization is record (
    id                   number,          -- internal id of authorization scheme
    name                 varchar2(255),   -- authorization scheme's name (see step 17)
    username             varchar2(255),   -- current user's name
    attribute_01         varchar2(32767), -- plugin attribute values 1 to 15
    attribute_02         varchar2(32767),
    attribute_03         varchar2(32767),
    attribute_04         varchar2(32767),
    attribute_05         varchar2(32767),
    attribute_06         varchar2(32767),
    attribute_07         varchar2(32767),
    attribute_08         varchar2(32767),
    attribute_09         varchar2(32767),
    attribute_10         varchar2(32767),
    attribute_11         varchar2(32767),
    attribute_12         varchar2(32767),
    attribute_13         varchar2(32767),
    attribute_14         varchar2(32767),
    attribute_15         varchar2(32767) );

type t_authorization_exec_result is record (
    is_authorized        boolean );        -- set to true if authorization succeeds
...
end wwv_flow_plugin;</pre>
<p>The 2nd type might seem excessive, but we prefer records, so extensions in later releases will not change function signatures.</p>
<p><strong>EDIT: 2011-08-25</strong><br />
There was an inconsistency in the record types <tt>t_authorization</tt> and <tt>t_authentication </tt>that we could fix before the 4.1 release. Both now contain an attribute <tt>username</tt>, I renamed <tt>t_authorization</tt>&#8216;s <tt>user_name</tt>. Thanks go to <a href="http://spendolini.blogspot.com/">Scott Spendolini</a> for finding that issue.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/chrisonoracle.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/chrisonoracle.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/chrisonoracle.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/chrisonoracle.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/chrisonoracle.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/chrisonoracle.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/chrisonoracle.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/chrisonoracle.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=chrisonoracle.wordpress.com&amp;blog=22937747&amp;post=5&amp;subd=chrisonoracle&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>https://chrisonoracle.wordpress.com/2011/05/09/how-to-create-an-apex-4-1-authorization-plugin/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
	
		<media:content url="https://secure.gravatar.com/avatar/add71fdc0237871665aa681428910423?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">chrisonoracle</media:title>
		</media:content>
	</item>
	</channel>
</rss>
