ocket8888 commented on code in PR #6802:
URL: https://github.com/apache/trafficcontrol/pull/6802#discussion_r876275681


##########
traffic_ops/app/db/migrations/2021110210085600_add_permissions.up.sql:
##########
@@ -1,164 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership.  The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
- * License for the specific language governing permissions and limitations 
under
- * the License.
- */
-
--- add built-in roles
-INSERT INTO public.role (name, description, priv_level) VALUES ('operations', 
'Has all reads and most write capabilities', 20) ON CONFLICT (name) DO NOTHING;
-INSERT INTO public.role (name, description, priv_level) VALUES ('read-only', 
'Has access to all read capabilities', 10) ON CONFLICT (name) DO NOTHING;
-INSERT INTO public.role (name, description, priv_level) values ('disallowed', 
'Block all access', 0) ON CONFLICT (name) DO NOTHING;
-INSERT INTO public.role (name, description, priv_level) VALUES 
('portal','Portal User', 2) ON CONFLICT DO NOTHING;
-INSERT INTO public.role (name, description, priv_level) VALUES 
('steering','Steering User', 15) ON CONFLICT DO NOTHING;
-INSERT INTO public.role (name, description, priv_level) VALUES 
('federation','Role for Secondary CZF', 15) ON CONFLICT DO NOTHING;

Review Comment:
   I just eliminated the `ON CONFLICT DO NOTHING` and re-ran `admin ... reset`, 
`admin ... upgrade`, and it completed successfully. No conflicts, and I 
restarted the database from scratch so the data that was successfully entered 
isn't left-over from a previous run.
   
   The only time it should conflict is on upgrade, in which case silently not 
overwriting existing data is not a failure, it's behavior as intended. If 
someone has changed the description, or privilege level of a user named 
`operations`, we should not potentially cause security problems for them by 
changing it, and we shouldn't hold their upgrade hostage because of it. ATC has 
no assumption about the existence or details of any of these Roles save 
`admin`, which can only be altered via direct database manipulation as the API 
will refuse any such operation. If anything, it MUST do nothing on conflict 
because of that. Since seeds are run on upgrade, and any existing, valid TO 
database will contain the `admin` Role, we expect that it will **always** 
conflict on upgrades. Changing that behavior renders users unable to upgrade 
their installation. But the line must exist, because seeds.sql is *also* run on 
new installs. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to