-
Notifications
You must be signed in to change notification settings - Fork 0
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
ユーザー認証のmiddleware作成 #28
Conversation
b8ce4b7
to
123762b
Compare
@AtsukiTak |
|
それ忘れていた!追加します🙇♀️ |
24ba8f2
to
fdb631e
Compare
以下に認証を追加
|
let secret_key = "secret_key".to_string(); | ||
let test_user_id = "test_user".to_string(); | ||
let now = Utc::now(); | ||
let iat = now.timestamp(); | ||
let exp = (now + Duration::hours(8)).timestamp(); | ||
let valid_session_token = create_jwt(&test_user_id, iat, &exp, &secret_key); |
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.
特にuser_id
を使用するわけではないのに、user_id
をトークン化してミドルウェアで認証する設計になっているのが個人的に違和感があるのだがそういうもん?
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.
user_id
いろんなとこで使ってるくない?
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.
各handlerで使ってるけどそういうことではない?
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.
例えば/users/:id
でもauth_middleware
を使ってuser_id
を取り出しているんだけど、user_id
自体はPathで渡してるからミドルウェアでuser_id
を取り出してるのは意味ないなぁと思った(ちゃんと)
/quests/:id/participate
とかもuser_id
はリクエストボディで渡してるからミドルウェアでuser_id
を取り出している意味がなさそうだけど、それはリクエストボディでuser_id
を渡すんじゃなくて認証で取り出せば良いように設計し直すことはできそう
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.
ミドルウェアで取り出したuser_id
がPathのuser_id
とかリクエストボディのuser_id
と一致するかどうかをチェックするってことか(?)
@AtsukiTak |
ユーザー情報の取得とか削除時に、user_idのチェック行ってないっぽい? |
めっちゃ勘違いしてたw |
@AtsukiTak |
了解!一旦このPRはMergeしてIssue立てます! |
#21