Skip to content

Commit

Permalink
Fix redirect_uri because the use of localhost is NOT RECOMMENDED in R…
Browse files Browse the repository at this point in the history
  • Loading branch information
wadahiro committed Oct 13, 2018
1 parent 640d8d2 commit 1470923
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/get_cred.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func getCred(cmd *cobra.Command, args []string) {
}

Writeln("Login successful!")
Traceln("ID token: %s", tokenResponse.IDToken)

awsFedType := client.config.GetString(AWS_FEDERATION_TYPE)

Expand Down Expand Up @@ -232,15 +233,14 @@ func createSAMLResponse(client *OIDCClient, samlAssertion string) (string, error
}

func doLogin(client *OIDCClient) (*TokenResponse, error) {
listener, err := net.Listen("tcp", "localhost:")
listener, err := net.Listen("tcp", "127.0.0.1:")
if err != nil {
return nil, errors.Wrap(err, "Cannot start local http server to handle login redirect")
}
port := listener.Addr().(*net.TCPAddr).Port

// TODO: support PKCE
clientId := client.config.GetString(CLIENT_ID)
redirect := fmt.Sprintf("http://localhost:%d", port)
redirect := fmt.Sprintf("http://127.0.0.1:%d", port)
v, err := pkce.CreateCodeVerifierWithLength(pkce.MaxLength)
if err != nil {
return nil, errors.Wrap(err, "Cannot generate OAuth2 PKCE code_challenge")
Expand Down Expand Up @@ -333,7 +333,7 @@ func launch(client *OIDCClient, url string, listener net.Listener) string {
}

func GetFreePort() (int, error) {
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
addr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0")
if err != nil {
return 0, err
}
Expand Down

0 comments on commit 1470923

Please sign in to comment.