Skip to content
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

Adding some better diagnostics for len(scopes) == 0 #403

Merged
merged 2 commits into from
Apr 12, 2023

Conversation

element-of-surprise
Copy link
Contributor

@element-of-surprise element-of-surprise commented Apr 10, 2023

For issue:

#304

@sonarcloud
Copy link

sonarcloud bot commented Apr 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

Comment on lines +340 to +346
// TODO(someone): we could look deeper at the message to determine if
// it's a scope error, but this is a good start.
/*
{error":"invalid_scope","error_description":"AADSTS1002012: The provided value for scope
openid offline_access profile is not valid. Client credential flows must have a scope value
with /.default suffixed to the resource identifier (application ID URI)...}
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO(someone): we could look deeper at the message to determine if
// it's a scope error, but this is a good start.
/*
{error":"invalid_scope","error_description":"AADSTS1002012: The provided value for scope
openid offline_access profile is not valid. Client credential flows must have a scope value
with /.default suffixed to the resource identifier (application ID URI)...}
*/

with /.default suffixed to the resource identifier (application ID URI)...}
*/
if len(a.Scopes) == 0 {
return fmt.Errorf("token request had an empty authority.AuthParams.Scopes, which is invalid")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AuthParams is internal, the public API is a scopes []string parameter

Suggested change
return fmt.Errorf("token request had an empty authority.AuthParams.Scopes, which is invalid")
return fmt.Errorf("a token request requires at least one scope")

@element-of-surprise element-of-surprise merged commit 565332c into dev Apr 12, 2023
@element-of-surprise element-of-surprise deleted the doakScopes branch April 12, 2023 21:00
chlowell added a commit that referenced this pull request Apr 13, 2023
@chlowell chlowell mentioned this pull request Apr 13, 2023
chlowell added a commit that referenced this pull request Apr 18, 2023
@rayluo rayluo mentioned this pull request Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants