Skip to content

467 feature request add dsts support#482

Merged
bgavrilMS merged 9 commits intomainfrom
467-feature-request-add-dsts-support
Nov 5, 2024
Merged

467 feature request add dsts support#482
bgavrilMS merged 9 commits intomainfrom
467-feature-request-add-dsts-support

Conversation

@handsomejack-42
Copy link
Contributor

No description provided.

@handsomejack-42 handsomejack-42 linked an issue Apr 15, 2024 that may be closed by this pull request
@handsomejack-42 handsomejack-42 force-pushed the 467-feature-request-add-dsts-support branch 3 times, most recently from 5517451 to 83ca36e Compare April 15, 2024 16:02
@handsomejack-42 handsomejack-42 requested a review from bgavrilMS May 2, 2024 07:15
return resp, err
}

func (c Client) DSTSInstanceDiscovery(ctx context.Context, authorityInfo Info) (InstanceDiscoveryResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Very surprised to see this, was under the impression that dSTS doesn't support instance discovery.

CC @victorm-hernandez

Choose a reason for hiding this comment

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

Correct, instance discovery is not supported.

@handsomejack-42 handsomejack-42 removed the request for review from chlowell May 7, 2024 15:16
@handsomejack-42 handsomejack-42 force-pushed the 467-feature-request-add-dsts-support branch from 83ca36e to 35a4182 Compare May 9, 2024 08:33
@handsomejack-42 handsomejack-42 marked this pull request as ready for review May 9, 2024 08:35
@handsomejack-42 handsomejack-42 requested a review from rayluo as a code owner May 9, 2024 08:35
authorizationEndpoint = "https://%v/%v/oauth2/v2.0/authorize"
instanceDiscoveryEndpoint = "https://%v/common/discovery/instance"
aadInstanceDiscoveryEndpoint = "https://%v/common/discovery/instance"
dstsInstanceDiscoveryEndpoint = "https://%v/dstsv2/common/discovery/instance"
Copy link

@victorm-hernandez victorm-hernandez May 22, 2024

Choose a reason for hiding this comment

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

https://%v/dstsv2/common/discovery/instance

We need some changes server side from dSTS before implementing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

authorityType = ADFS
case "dstsv2":
if len(pathParts) != 3 {
return Info{}, errors.New(`dSTS authority must be an https URL such as "https://<authority>/dstsv2/<your tenant>"`)

Choose a reason for hiding this comment

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

dSTS doesnt support tenants, the value for the tenant is hard coded everywhere and should always be the same.

Lets change the error to reflect this. The tenant is

7a433bfc-2514-4697-b467-e0933190487f

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hard-coded tenant + added validation

if authorityInfo.AuthorityType == authority.ADFS {
return fmt.Sprintf("https://%s/adfs/.well-known/openid-configuration", authorityInfo.Host), nil
} else if authorityInfo.AuthorityType == authority.DSTS {
resp, err := m.rest.Authority().DSTSInstanceDiscovery(ctx, authorityInfo)

Choose a reason for hiding this comment

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

DSTSInstanceDiscovery

Similar to ADFS, you can use a hard coded URL for dSTS. An example of this endpoint on dSTS

https://test-instance1-dsts.dsts.core.azure-test.net/dstsv2/7a433bfc-2514-4697-b467-e0933190487f/.well-known/openid-configuration

IMPORTANT! To connect to this endpoint you need to be on our VPN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hard-coded the url

Copy link

@victorm-hernandez victorm-hernandez left a comment

Choose a reason for hiding this comment

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

🕐

@handsomejack-42 handsomejack-42 force-pushed the 467-feature-request-add-dsts-support branch 2 times, most recently from 5ee15d8 to 99f29ff Compare May 29, 2024 09:30
@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

The field isn't used anywhere. Removing it simplifies the work on introducing
authority abstraction. We might re-add it once we need it for anything.
…t readability

Previously, the test results were printed as #0 #1 #2, which made it
hard to navigate the failed test cases. Now, the test cases
are annotated by their respective names. The names also make it
more clear what is being unit-tested.
…ONCall

Parsing the url, then setting qv.Encode() manually to u.RawQuery
feel like an overcomplicated approach of creating url for http request.

Use the native constructor, which enforces ctx to be
passed into the request, and do simple sprintf for url + query.
@handsomejack-42 handsomejack-42 force-pushed the 467-feature-request-add-dsts-support branch from 99f29ff to a19302c Compare November 4, 2024 13:36
@handsomejack-42 handsomejack-42 force-pushed the 467-feature-request-add-dsts-support branch from a19302c to 0d1c5c6 Compare November 4, 2024 13:38
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 4, 2024

@handsomejack-42
Copy link
Contributor Author

ready to be merged, ran against real dSTS instance as instructed, works

@bgavrilMS @victorm-hernandez

@bgavrilMS bgavrilMS merged commit 06d3fb2 into main Nov 5, 2024
@bgavrilMS bgavrilMS deleted the 467-feature-request-add-dsts-support branch November 5, 2024 15:43
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.

[Feature Request] Add dSTS support

3 participants