-
Notifications
You must be signed in to change notification settings - Fork 257
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
refactor(auth, gateway): use user_id over account_name #1674
Merged
Merged
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
76273d3
feat(auth): user_id not null, remove migration insertions
jonaro00 28e82d4
fix(auth): insert user_id on command inserts
jonaro00 877930f
feat: rename account_name to user_id in most places
jonaro00 e1c20ba
nits
jonaro00 a816e73
nit2
jonaro00 5445696
fix: auth tests almost working
jonaro00 bcde733
yeet: auth/refresh
jonaro00 3e205d1
fix: span
jonaro00 00c3162
fix: auth tests
jonaro00 8caf01b
feat: set old account name header for tracing in old deployers
jonaro00 617d9c6
nit: clarify start_last_deploy
jonaro00 c8fe94b
fix: sql comment
jonaro00 2900c3d
fix: userid comment
jonaro00 1edf407
feat(deployer): use claim instead of user id header for tracing
jonaro00 0be50c3
nit: remove request.path tracing field
jonaro00 0931bf3
Revert "nit: remove request.path tracing field"
jonaro00 3c27279
less clone
jonaro00 30a966d
feat(auth): keep get account by name endpoint
jonaro00 9f0be65
fmt
jonaro00 f33f9da
ci: unstable
jonaro00 443cdc8
clippy
jonaro00 fa81d18
fix: migration drift fixes
jonaro00 d702495
fix: migration drift fixes 2
jonaro00 0e8e6ef
revert: migration drift fixes
jonaro00 51b1c0c
fix: endpoint ordering
jonaro00 bc82a89
test: set empty field on endpoint
jonaro00 b312146
Revert "test: set empty field on endpoint"
jonaro00 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 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
chesedo marked this conversation as resolved.
Show resolved
Hide resolved
|
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,27 @@ | ||
-- All rows should have user_ids at this point (added in the application logic before this migration was introduced) | ||
ALTER TABLE users | ||
ALTER COLUMN user_id SET NOT NULL; | ||
|
||
|
||
-- Switch the foreign key(fk) on subscriptions and remove the old fk | ||
ALTER TABLE subscriptions | ||
ADD COLUMN user_id TEXT; | ||
|
||
UPDATE subscriptions | ||
SET user_id = users.user_id | ||
FROM users | ||
WHERE subscriptions.account_name = users.account_name; | ||
|
||
ALTER TABLE subscriptions | ||
DROP CONSTRAINT subscriptions_account_name_fkey, | ||
ADD FOREIGN KEY (user_id) REFERENCES users (user_id), | ||
ALTER COLUMN user_id SET NOT NULL, | ||
DROP COLUMN account_name, | ||
-- Add back the unique pair constraint | ||
ADD CONSTRAINT user_id_type UNIQUE (user_id, type); | ||
|
||
|
||
-- Switch the primary key on users | ||
ALTER TABLE users | ||
DROP CONSTRAINT users_pkey, | ||
ADD PRIMARY KEY (user_id); |
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 |
---|---|---|
|
@@ -19,8 +19,8 @@ use crate::{ | |
}; | ||
|
||
use super::handlers::{ | ||
convert_key, delete_subscription, get_public_key, get_user, health_check, post_subscription, | ||
post_user, put_user_reset_key, refresh_token, | ||
convert_key, delete_subscription, get_public_key, get_user, get_user_by_name, | ||
post_subscription, post_user, put_user_reset_key, | ||
}; | ||
|
||
pub type UserManagerState = Arc<Box<dyn UserManagement>>; | ||
|
@@ -62,24 +62,27 @@ impl Default for ApiBuilder { | |
impl ApiBuilder { | ||
pub fn new() -> Self { | ||
let router = Router::new() | ||
.route("/", get(health_check)) | ||
// health check: 200 OK | ||
.route("/", get(|| async move {})) | ||
.route("/auth/key", get(convert_key)) | ||
.route("/auth/refresh", post(refresh_token)) | ||
.route("/public-key", get(get_public_key)) | ||
.route("/users/:account_name", get(get_user)) | ||
// users are created based on auth0 name by console | ||
.route("/users/:account_name/:account_tier", post(post_user)) | ||
// used by console to get user based on auth0 name | ||
.route("/users/name/:account_name", get(get_user_by_name)) | ||
.route("/users/:user_id", get(get_user)) | ||
.route("/users/reset-api-key", put(put_user_reset_key)) | ||
.route("/users/:account_name/subscribe", post(post_subscription)) | ||
.route("/users/:user_id/subscribe", post(post_subscription)) | ||
.route( | ||
"/users/:account_name/subscribe/:subscription_id", | ||
"/users/:user_id/subscribe/:subscription_id", | ||
delete(delete_subscription), | ||
) | ||
.route_layer(from_extractor::<Metrics>()) | ||
.layer( | ||
TraceLayer::new(|request| { | ||
request_span!( | ||
request, | ||
request.params.account_name = field::Empty, | ||
request.params.user_id = field::Empty, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: this will affect metrics |
||
request.params.account_tier = field::Empty, | ||
) | ||
}) | ||
|
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder