Imagine I have one shared database set up for my class that each student has the potential to access (access to the database is open and only requires kerberos auth). The public space is where I place all my default course material (tables, views, etc), most of which can be accessed by anyone interested.
What I would like is for:
- each student (any authenticated user) to be able to create their own schema and use that as the scope where they can create tables and views
- students to not be able to create tables/views/objects in public
- to apply these settings to all all users; or more specifically, not have to target specific user accounts when assigning permissions
Thought process:
REVOKE ALL ON DATABASE class FROM PUBLIC
GRANT CREATE ON DATABASE class TO PUBLIC -- can it be CREATE SCHEMA ?
-- being able to create on database makes it seem like they can create in public
-- can permissions be revoked from public?
As user:
psql -h <host> class
-- desire: permitted
CREATE SCHEMA <current_user>;
GRANT USAGE ON <current_user> TO teacher;
CREATE TABLE <current_user>.<table name> ...;
SELECT * FROM public.<table name>;
SELECT * FROM <current_user>.<table name>;
-- desire: not permitted
CREATE TABLE public.<table name> ...;
I'm not sure those are the proper permissions. I was also curious if I could create a roll and use the role to administer permissions. The tricky bit is I would like any authenticated user to be part of that role, which I don't think you can add public to a role, so I don't know how that would work.
I haven't thought this through thoroughly, but appreciate any feedback, concerns, and answers offered. Of course, I'm available to answer questions for clarification -- being concise while still offering comprehensive details is a challenge.