Skip to content

feat: add oauth2 codes and tokens to database #11779

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

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format oauth2.sql
  • Loading branch information
code-asher committed Jan 24, 2024
commit 29a9e26a761c6e1c601f36e6e30c760e69ff2c87
15 changes: 10 additions & 5 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions coderd/database/queries/oauth2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ INSERT INTO oauth2_provider_app_tokens (
) RETURNING *;

-- name: GetOAuth2ProviderAppsByUserID :many
SELECT COUNT(DISTINCT oauth2_provider_app_tokens.id) as token_count,
SELECT
COUNT(DISTINCT oauth2_provider_app_tokens.id) as token_count,
sqlc.embed(oauth2_provider_apps)
FROM oauth2_provider_app_tokens
INNER JOIN oauth2_provider_app_secrets
Expand All @@ -120,12 +121,16 @@ FROM oauth2_provider_app_tokens
ON oauth2_provider_apps.id = oauth2_provider_app_secrets.app_id
INNER JOIN api_keys
ON api_keys.id = oauth2_provider_app_tokens.api_key_id
WHERE api_keys.user_id = $1
GROUP BY oauth2_provider_apps.id;
WHERE
api_keys.user_id = $1
GROUP BY
oauth2_provider_apps.id;

-- name: DeleteOAuth2ProviderAppTokensByAppAndUserID :exec
DELETE FROM oauth2_provider_app_tokens
USING oauth2_provider_app_secrets, api_keys
DELETE FROM
oauth2_provider_app_tokens
USING
oauth2_provider_app_secrets, api_keys
WHERE
oauth2_provider_app_secrets.id = oauth2_provider_app_tokens.app_secret_id
AND api_keys.id = oauth2_provider_app_tokens.api_key_id
Expand Down