<!-- 
RSS generated by JIRA (8.3.4#803005-sha1:1f96e09b3c60279a408a2ae47be3c745f571388b) at Sat Feb 10 16:51:24 JST 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>PFS-JIRA</title>
    <link>https://pfspipe.ipmu.jp/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.3.4</version>
        <build-number>803005</build-number>
        <build-date>13-09-2019</build-date>
    </build-info>


<item>
            <title>[INFRA-296] Adjust database permissions</title>
                <link>https://pfspipe.ipmu.jp/jira/browse/INFRA-296</link>
                <project id="10001" key="INFRA">Software Development Infrastructure</project>
                    <description>&lt;p&gt;We currently use the &lt;tt&gt;pfs&lt;/tt&gt; role for all connections to the opdb and archiver databases, and that role has infinite power (it has the superuser bit). We should be more careful, if only to avoid doom-typos. How about three roles:&lt;/p&gt;
&lt;div class=&apos;table-wrap&apos;&gt;
&lt;table class=&apos;confluenceTable&apos;&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;th class=&apos;confluenceTh&apos;&gt;Name&lt;/th&gt;
&lt;th class=&apos;confluenceTh&apos;&gt;Permissions&lt;/th&gt;
&lt;th class=&apos;confluenceTh&apos;&gt;Note&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;public&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;select&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;For querying and browsing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;pfs&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;select,insert&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;For the ICS and DRP programs, mainly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;admin&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;all&lt;/td&gt;
&lt;td class=&apos;confluenceTd&apos;&gt;Obvious&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
</description>
                <environment></environment>
        <key id="16937">INFRA-296</key>
            <summary>Adjust database permissions</summary>
                <type id="3" iconUrl="https://pfspipe.ipmu.jp/jira/secure/viewavatar?size=xsmall&amp;avatarId=10518&amp;avatarType=issuetype">Task</type>
                                            <priority id="10000" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/priorities/medium.svg">Normal</priority>
                        <status id="10002" iconUrl="https://pfspipe.ipmu.jp/jira/images/icons/statuses/generic.png" description="The issue is resolved, reviewed, and merged">Done</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="kiyoto.yabe">Kiyoto Yabe</assignee>
                                    <reporter username="cloomis">cloomis</reporter>
                        <labels>
                            <label>EngRun</label>
                    </labels>
                <created>Tue, 13 Jul 2021 19:27:35 +0000</created>
                <updated>Tue, 26 Oct 2021 07:56:04 +0000</updated>
                            <resolved>Tue, 26 Oct 2021 06:40:24 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                <comments>
                            <comment id="22252" author="kiyoto.yabe" created="Tue, 5 Oct 2021 08:19:39 +0000"  >&lt;p&gt;Do we need to fix this before the Nov. run?&lt;/p&gt;</comment>
                            <comment id="22264" author="cloomis" created="Wed, 6 Oct 2021 21:05:50 +0000"  >&lt;p&gt;Depend on how scared you are of anyone running &quot;DROP DATABASE OPDB;&quot;. I am actually more scared of &quot;DROP DATABASE ARCHIVER;&quot;&lt;/p&gt;

&lt;p&gt;We replicate opdb to Hilo and Princeton, but not the archiver. We were planning to have a summit backup machine for replication, but that has not yet happened.&lt;/p&gt;</comment>
                            <comment id="22265" author="hassan" created="Wed, 6 Oct 2021 21:25:20 +0000"  >&lt;p&gt;I think this needs to be done before the next run. If I understand correctly, currently everyone has superuser access. So anyone could inadvertently modify the database contents.&lt;/p&gt;</comment>
                            <comment id="22266" author="kiyoto.yabe" created="Thu, 7 Oct 2021 00:14:40 +0000"  >&lt;p&gt;OK, I will think about a plan to change permissions (consulting with experts). BTW, we replicated the entire database cluster at summit to Hilo, so is `archiver` I guess.&lt;/p&gt;</comment>
                            <comment id="22554" author="kiyoto.yabe" created="Tue, 12 Oct 2021 06:17:33 +0000"  >&lt;p&gt;I&apos;m thinking about the following SQL commands:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;CREATE USER admin WITH PASSWORD &apos;usual password&apos; Superuser Createrole CreateDB Replication;&lt;/li&gt;
	&lt;li&gt;CREATE USER public_user WITH PASSWORD &apos;public user password&apos;;&lt;/li&gt;
	&lt;li&gt;ALTER ROLE pfs WITH NOSUPERUSER NOCREATEDB&#160; NOCREATEROLE NOREPLICATION;&lt;/li&gt;
	&lt;li&gt;admin@opdb (repeat followings for archiver)
	&lt;ul&gt;
		&lt;li&gt;REASSIGN OWNED BY pfs TO admin;&lt;/li&gt;
		&lt;li&gt;REVOKE ALL ON SCHEMA public FROM pfs;&lt;/li&gt;
		&lt;li&gt;REVOKE ALL ON ALL TABLES IN SCHEMA public FROM pfs;&lt;/li&gt;
		&lt;li&gt;GRANT USAGE ON SCHEMA public TO pfs;&lt;/li&gt;
		&lt;li&gt;&lt;br/&gt;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public to pfs;&lt;/li&gt;
		&lt;li&gt;GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA public TO pfs;&lt;/li&gt;
		&lt;li&gt;ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT ON TABLES TO pfs;&lt;/li&gt;
		&lt;li&gt;&lt;br/&gt;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE ON SEQUENCES TO pfs;&lt;/li&gt;
		&lt;li&gt;REVOKE ALL ON SCHEMA public FROM public_user;&lt;/li&gt;
		&lt;li&gt;REVOKE ALL ON ALL TABLES IN SCHEMA public FROM public_user;&lt;/li&gt;
		&lt;li&gt;GRANT USAGE ON SCHEMA public TO public_user;&lt;/li&gt;
		&lt;li&gt;GRANT SELECT ON ALL TABLES IN SCHEMA public TO public_user;&lt;/li&gt;
		&lt;li&gt;ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO public_user;&lt;/li&gt;
		&lt;li&gt;ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE ON SEQUENCES TO public_user;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;These seem to work fine in my test environment, but perhaps not in the real environment. So, any comments are very welcome. Maybe there exists a smarter way...&lt;/p&gt;

&lt;p&gt;Notes:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;`public` is a reserved word so will use `public_user` for a public user&lt;/li&gt;
	&lt;li&gt;Do we need `UPDATE` for `pfs`?&lt;/li&gt;
	&lt;li&gt;Probably we need to change this monitoring `opDB` &amp;amp; `archiver` access. Maybe downtime?&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="23335" author="kiyoto.yabe" created="Wed, 20 Oct 2021 05:39:02 +0000"  >&lt;p&gt;Planned commands are something like this:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
[done] CREATE USER admin WITH PASSWORD &lt;span class=&quot;code-quote&quot;&gt;&apos;usual password&apos;&lt;/span&gt; Superuser Createrole CreateDB Replication;
[done] CREATE USER public_user WITH PASSWORD &lt;span class=&quot;code-quote&quot;&gt;&apos;ask me&apos;&lt;/span&gt;;

(admin@archiver)
ALTER USER pfs WITH NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION;

REASSIGN OWNED BY pfs TO admin;

GRANT USAGE ON SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs; 
GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT SELECT, INSERT ON TABLES TO pfs;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT USAGE ON SEQUENCES TO pfs;

(admin@opdb)
GRANT USAGE ON SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs; 
GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT SELECT, INSERT ON TABLES TO pfs;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT USAGE ON SEQUENCES TO pfs;

GRANT USAGE ON SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO public_user;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO public_user; 
GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO public_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT SELECT ON TABLES TO public_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT USAGE ON SEQUENCES TO public_user;
&#160;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="23336" author="cloomis" created="Wed, 20 Oct 2021 15:06:57 +0000"  >&lt;p&gt;Am happy trying the archiver changes at JHU.&lt;/p&gt;</comment>
                            <comment id="23337" author="cloomis" created="Wed, 20 Oct 2021 16:11:21 +0000"  >&lt;p&gt;Wait, typo?&lt;/p&gt;

&lt;p&gt;We do &lt;b&gt;not&lt;/b&gt; want to grant anything but &lt;tt&gt;SELECT&lt;/tt&gt; to &lt;tt&gt;public_user&lt;/tt&gt;, so not:&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;GRANT SELECT, INSERT ON ALL TABLES IN SCHEMA public TO public_user;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="23343" author="cloomis" created="Wed, 20 Oct 2021 19:57:06 +0000"  >&lt;p&gt;FYI the &lt;tt&gt;REASSIGN OWNED BY pfs TO admin;&lt;/tt&gt; command takes longer than you might guess. Several minutes at JHU. Worked fine in the end. I did swap the order of the &lt;tt&gt;ALTER USER pfs&lt;/tt&gt; and &lt;tt&gt;REASSIGN OWNED BY&lt;/tt&gt; commands since I was slightly worried about cutting my legs off at the knees.&lt;/p&gt;</comment>
                            <comment id="23349" author="kiyoto.yabe" created="Thu, 21 Oct 2021 11:11:32 +0000"  >&lt;p&gt;After removing a blocking process, the following SQL commands to change permissions have been sent. Indeed, I did not use `REASSIGN OWNED` but made SQL commands to change for each table detected by the following command:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
SELECT &#160;&#160; &lt;span class=&quot;code-quote&quot;&gt;&apos;ALTER TABLE &apos;&lt;/span&gt; || schemaname &#160;&#160; || &lt;span class=&quot;code-quote&quot;&gt;&apos;.&apos;&lt;/span&gt; || tablename || &#160;&#160; &lt;span class=&quot;code-quote&quot;&gt;&apos; OWNER TO admin;&apos;&lt;/span&gt;FROM pg_tables WHERE tableowner =&lt;span class=&quot;code-quote&quot;&gt;&apos;pfs&apos;&lt;/span&gt;;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/attachment/14250/14250_change_opdb.sql&quot; title=&quot;change_opdb.sql attached to INFRA-296&quot;&gt;change_opdb.sql&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://pfspipe.ipmu.jp/jira/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;nobr&quot;&gt;&lt;a href=&quot;https://pfspipe.ipmu.jp/jira/secure/attachment/14249/14249_change_archiver.sql&quot; title=&quot;change_archiver.sql attached to INFRA-296&quot;&gt;change_archiver.sql&lt;sup&gt;&lt;img class=&quot;rendericon&quot; src=&quot;https://pfspipe.ipmu.jp/jira/images/icons/link_attachment_7.gif&quot; height=&quot;7&quot; width=&quot;7&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/sup&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="23358" author="kiyoto.yabe" created="Fri, 22 Oct 2021 07:41:39 +0000"  >&lt;p&gt;I just realized that `obslog` needed to delete records of some tables. I just add the following permissions for `obslog_*_note` tables.&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
BEGIN; 
GRANT UPDATE, DELETE ON obslog_visit_note TO pfs; 
GRANT UPDATE, DELETE ON obslog_mcs_exposure_note TO pfs; 
GRANT UPDATE, DELETE ON obslog_visit_set_note TO pfs; 
COMMIT;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                            <comment id="24795" author="kiyoto.yabe" created="Tue, 26 Oct 2021 06:40:08 +0000"  >&lt;p&gt;So far, I don&apos;t see (or hear) any problems caused by the change, so I close this ticket. File a new one, if we get some troubles.&lt;/p&gt;</comment>
                            <comment id="24797" author="kiyoto.yabe" created="Tue, 26 Oct 2021 07:56:04 +0000"  >&lt;p&gt;(Just a record) I also added the followings:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; TO pfs;
ALTER DEFAULT PRIVILEGES IN SCHEMA &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; GRANT SELECT ON SEQUENCES TO pfs; &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="14249" name="change_archiver.sql" size="19233" author="kiyoto.yabe" created="Thu, 21 Oct 2021 11:11:12 +0000"/>
                            <attachment id="14250" name="change_opdb.sql" size="5551" author="kiyoto.yabe" created="Thu, 21 Oct 2021 11:11:12 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10500" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|zzs9uc:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10005" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="124">EngRun3Cleanup</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10002" key="com.atlassian.jira.plugin.system.customfieldtypes:float">
                        <customfieldname>Story Points</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                        </customfields>
    </item>
</channel>
</rss>