-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1099 from neicnordic/feature/auth-request-userinfo
[auth] save userinfo to db
- Loading branch information
Showing
17 changed files
with
235 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
DO | ||
$$ | ||
DECLARE | ||
-- The version we know how to do migration from, at the end of a successful migration | ||
-- we will no longer be at this version. | ||
sourcever INTEGER := 13; | ||
changes VARCHAR := 'Add userinfo and create AUTH user'; | ||
BEGIN | ||
IF (select max(version) from sda.dbschema_version) = sourcever then | ||
RAISE NOTICE 'Doing migration from schema version % to %', sourcever, sourcever+1; | ||
RAISE NOTICE 'Changes: %', changes; | ||
INSERT INTO sda.dbschema_version VALUES(sourcever+1, now(), changes); | ||
|
||
-- Temporary function for creating roles if they do not already exist. | ||
CREATE FUNCTION create_role_if_not_exists(role_name NAME) RETURNS void AS $created$ | ||
BEGIN | ||
IF EXISTS ( | ||
SELECT FROM pg_catalog.pg_roles | ||
WHERE rolname = role_name) THEN | ||
RAISE NOTICE 'Role "%" already exists. Skipping.', role_name; | ||
ELSE | ||
BEGIN | ||
EXECUTE format('CREATE ROLE %I', role_name); | ||
EXCEPTION | ||
WHEN duplicate_object THEN | ||
RAISE NOTICE 'Role "%" was just created by a concurrent transaction. Skipping.', role_name; | ||
END; | ||
END IF; | ||
END; | ||
$created$ LANGUAGE plpgsql; | ||
|
||
CREATE TABLE IF NOT EXISTS sda.userinfo ( | ||
id TEXT PRIMARY KEY, | ||
name TEXT, | ||
email TEXT, | ||
groups TEXT[] | ||
); | ||
|
||
PERFORM create_role_if_not_exists('auth'); | ||
GRANT USAGE ON SCHEMA sda TO auth; | ||
GRANT SELECT, INSERT, UPDATE ON sda.userinfo TO auth; | ||
|
||
GRANT base TO auth; | ||
ELSE | ||
RAISE NOTICE 'Schema migration from % to % does not apply now, skipping', sourcever, sourcever+1; | ||
END IF; | ||
END | ||
$$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.