-
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/add auth module #2
base: feature/add-db-migrations
Are you sure you want to change the base?
Conversation
Value: session.ID.String(), | ||
Path: "/", | ||
Expires: session.ExpiredAt, | ||
HttpOnly: true, |
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.
少なくとも本番環境では Secure をつけるようにしてほしいです。
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.
環境変数から指定できるように修正します。
api/oauth2/handler.go
Outdated
queryState := r.URL.Query().Get("state") | ||
|
||
if cookieState == "" || queryState == "" || cookieState != queryState { | ||
http.Error(w, err.Error(), http.StatusInternalServerError) |
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.
これ err が nil で panic するような気がします。
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.
panicしますね。修正します。
api/oauth2/handler.go
Outdated
case "google": | ||
provider = authentity.ProviderGoogle | ||
default: | ||
http.Error(w, "invalid provider", http.StatusInternalServerError) |
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.
Internal Server Error ではなさそう。
ここ以外も同じように見直したほうが良いように思います。
api/interceptor/auth.go
Outdated
if err == nil { | ||
return next(ctx, req) | ||
} | ||
|
||
sessionID, err := idtype.NewSessionIDFromString(cookie.Value) | ||
if err == nil { |
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.
逆じゃないですか?
if err == nil { | |
return next(ctx, req) | |
} | |
sessionID, err := idtype.NewSessionIDFromString(cookie.Value) | |
if err == nil { | |
if err != nil { | |
return next(ctx, req) | |
} | |
sessionID, err := idtype.NewSessionIDFromString(cookie.Value) | |
if err != nil { |
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.
逆ですね。修正します。
module/auth/gateway/google.go
Outdated
"google.golang.org/api/option" | ||
) | ||
|
||
//go:embed google_client_credentials.json |
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.
これビルド時に差し込む形になっちゃうのでやめてください。
client_id と client_secret を環境変数でもらうような形にしてください。
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.
了解です。
} | ||
|
||
func (h *Handler) HandleLogout(w http.ResponseWriter, r *http.Request) { | ||
user, err := h.authUseCase.AuthorizeAuthenticatedUser(r.Context()) |
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.
ここでこれって動くんですか? Connect でしか処理してない気がする。
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.
動かないですね。別途middlewareを定義しようと思います。
お二人ともレビューありがとうございます! TODO
|
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.
お疲れ様です!ありがとうございます!
auth moduleを追加しました。
このモジュールでは主に下記のことを行なっています。