From ee46863f7449a657deaf03737e8d55965e84120e Mon Sep 17 00:00:00 2001 From: pirosiki197 Date: Mon, 23 Dec 2024 14:21:24 +0900 Subject: [PATCH] =?UTF-8?q?random=20package=E3=81=AE=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=82=92=E4=BD=BF=E3=81=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/handler/handler_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/server/handler/handler_test.go b/server/handler/handler_test.go index feab8aa..b01be65 100644 --- a/server/handler/handler_test.go +++ b/server/handler/handler_test.go @@ -23,6 +23,7 @@ import ( "github.com/traPtitech/piscon-portal-v2/server/handler" "github.com/traPtitech/piscon-portal-v2/server/repository" "github.com/traPtitech/piscon-portal-v2/server/services/oauth2" + "github.com/traPtitech/piscon-portal-v2/server/utils/random" ) const Oauth2ServerURL = "http://localhost:9000" @@ -159,7 +160,7 @@ func (s *oauth2Server) handleAuthorize(w http.ResponseWriter, r *http.Request) { codeChallenge := q.Get("code_challenge") state := q.Get("state") - code := randomString() + code := random.String(32) s.codeChallengeMap.Set(code, codeChallenge, 15*time.Minute) // use user params as username for testing @@ -257,9 +258,3 @@ func (s *oauth2Server) handleJWKS(w http.ResponseWriter, _ *http.Request) { }, }) } - -func randomString() string { - b := make([]byte, 32) - rand.Read(b) - return base64.RawURLEncoding.EncodeToString(b) -}