-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Polestar: fix resume path and adjust regex #28466
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
base: master
Are you sure you want to change the base?
Changes from all commits
aa340bc
6b7eb43
3ef936c
6326d8b
4135a1d
c897f5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,14 +69,15 @@ func (v *Identity) login() (*oauth2.Token, error) { | |
| "client_id": {ClientID}, | ||
| "redirect_uri": {RedirectURI}, | ||
| "response_type": {"code"}, | ||
| "scope": {"openid profile email"}, | ||
| "state": {lo.RandomString(16, lo.AlphanumericCharset)}, | ||
| "scope": {"openid", "profile", "email"}, | ||
| "code_challenge": {oauth2.S256ChallengeFromVerifier(cv)}, | ||
| "code_challenge_method": {"S256"}, | ||
| } | ||
|
|
||
| // Request authorization URL with browser-like headers | ||
| uri := fmt.Sprintf("%s/as/authorization.oauth2?%s", OAuthURI, data.Encode()) | ||
|
|
||
| req, _ := request.New(http.MethodGet, uri, nil, map[string]string{ | ||
| "Accept": "text/html,application/xhtml+xml,application/xml;", | ||
| }) | ||
|
|
@@ -93,7 +94,7 @@ func (v *Identity) login() (*oauth2.Token, error) { | |
| return nil, err | ||
| } | ||
|
|
||
| matches := regexp.MustCompile(`(?:url|action):\s*"/as/(.+?)/resume/as/authorization\.ping"`).FindStringSubmatch(string(body)) | ||
| matches := regexp.MustCompile(`(?:url|action):\s*"(.+)"`).FindStringSubmatch(string(body)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): The updated regex is too broad and greedy, which may capture unintended URLs or paths. The new pattern now matches any |
||
|
|
||
| if len(matches) < 2 { | ||
| return nil, errors.New("could not find resume path") | ||
|
|
@@ -106,7 +107,8 @@ func (v *Identity) login() (*oauth2.Token, error) { | |
| "client_id": {ClientID}, | ||
| } | ||
|
|
||
| uri = fmt.Sprintf("%s/as/%s/resume/as/authorization.ping", OAuthURI, matches[1]) | ||
| uri = OAuthURI + "/" + strings.TrimLeft(matches[1], "/") // Remove leading / | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (bug_risk): Blindly prefixing If |
||
|
|
||
| req, _ = request.New(http.MethodPost, uri, strings.NewReader(data.Encode()), map[string]string{ | ||
| "Content-Type": "application/x-www-form-urlencoded", | ||
| "Accept": "application/json", | ||
|
|
@@ -118,7 +120,6 @@ func (v *Identity) login() (*oauth2.Token, error) { | |
| } | ||
| defer resp.Body.Close() | ||
|
|
||
| // Extract authorization code from response | ||
| code := resp.Request.URL.Query().Get("code") | ||
| if code == "" { | ||
| return nil, errors.New("missing authorization code") | ||
|
|
||
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.
Unrelated?
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.
Correct, some changes I thought were relevant and forgot to undo. Changed back with 3ef936c