Skip to content

Commit 542efee

Browse files
authored
added response body check in okta verification (#4180)
1 parent c3f0e1c commit 542efee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/detectors/okta/okta.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package okta
33
import (
44
"context"
55
"fmt"
6+
"io"
67
"net/http"
8+
"strings"
79

810
regexp "github.com/wasilibs/go-re2"
911

@@ -72,7 +74,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
7274
return
7375
}
7476

75-
func verifyOktaToken(ctx context.Context, client *http.Client, domain string, token string) (bool, error) {
77+
func verifyOktaToken(ctx context.Context, client *http.Client, domain, token string) (bool, error) {
7678
// curl -v -X GET \
7779
// -H "Accept: application/json" \
7880
// -H "Content-Type: application/json" \
@@ -96,8 +98,9 @@ func verifyOktaToken(ctx context.Context, client *http.Client, domain string, to
9698

9799
switch resp.StatusCode {
98100
case http.StatusOK:
99-
return true, nil
100-
case http.StatusUnauthorized, http.StatusForbidden:
101+
body, _ := io.ReadAll(resp.Body)
102+
return strings.Contains(string(body), "\"activated\":"), nil
103+
case http.StatusUnauthorized:
101104
return false, nil
102105
default:
103106
return false, fmt.Errorf("unexpected status code: %d", resp.StatusCode)

0 commit comments

Comments
 (0)