-
Notifications
You must be signed in to change notification settings - Fork 73
Add OAuth2 login #512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Minei3oat
wants to merge
6
commits into
TFNS:main
Choose a base branch
from
Minei3oat:oauth2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add OAuth2 login #512
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a8413c1
Add OAuth2 login
Minei3oat ccc5f4b
Explain environment variables for OAuth 2.0 login in .env.example
Minei3oat f2142c8
Mind role updates
Minei3oat adf3604
yarn run codegen
Minei3oat 529f0b4
Drop useless code
Minei3oat 7db875a
Allow setting local passwords for externally managed accounts
Minei3oat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or 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 hidden or 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,29 @@ | ||
| -- Allow null passwords for externally managed users | ||
| ALTER TABLE ctfnote_private.user | ||
| ALTER COLUMN password DROP NOT NULL; | ||
|
|
||
| -- Login with external identity and register user if not present | ||
| CREATE FUNCTION ctfnote_private.login_with_extern("name" text, "role" ctfnote.role) | ||
| RETURNS ctfnote.jwt | ||
| AS $$ | ||
| DECLARE | ||
| log_user ctfnote_private.user; | ||
| BEGIN | ||
| INSERT INTO ctfnote_private.user ("login", "password", "role") | ||
| VALUES (login_with_extern.name, NULL, login_with_extern.role) | ||
| ON CONFLICT ("login") DO UPDATE | ||
| SET role = login_with_extern.role | ||
| RETURNING | ||
| * INTO log_user; | ||
| INSERT INTO ctfnote.profile ("id", "username") | ||
| VALUES (log_user.id, login_with_extern.name) | ||
| ON CONFLICT (id) DO UPDATE | ||
| SET username = login_with_extern.name; | ||
| RETURN (ctfnote_private.new_token (log_user.id))::ctfnote.jwt; | ||
| END; | ||
| $$ | ||
| LANGUAGE plpgsql | ||
| STRICT | ||
| SECURITY DEFINER; | ||
|
|
||
| GRANT EXECUTE ON FUNCTION ctfnote_private.login_with_extern TO user_anonymous; | ||
This file contains hidden or 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,5 @@ | ||
| ALTER TABLE ctfnote.settings | ||
| ADD COLUMN "oauth2_enabled" boolean NOT NULL DEFAULT FALSE; | ||
|
|
||
| GRANT SELECT ("oauth2_enabled") ON ctfnote.settings TO user_anonymous; | ||
| GRANT UPDATE ("oauth2_enabled") ON ctfnote.settings TO user_postgraphile; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.