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

Fix password flow #3196

Merged
merged 14 commits into from
Apr 23, 2024
8 changes: 8 additions & 0 deletions .chronus/changes/fix-password-flow-2024-3-19-16-22-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/http"
---

Fix password flow defining `authorizationUrl` instead of `tokenUrl`
12 changes: 6 additions & 6 deletions docs/libraries/http/reference/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,12 @@ model TypeSpec.Http.PasswordFlow

#### Properties

| Name | Type | Description |
| ---------------- | --------------------------------------- | --------------------------------- |
| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow |
| authorizationUrl | `string` | the authorization URL |
| refreshUrl? | `string` | the refresh URL |
| scopes? | `string[]` | list of scopes for the credential |
| Name | Type | Description |
| ----------- | --------------------------------------- | --------------------------------- |
| type | `TypeSpec.Http.OAuth2FlowType.password` | password flow |
| tokenUrl | `string` | the token URL |
| refreshUrl? | `string` | the refresh URL |
| scopes? | `string[]` | list of scopes for the credential |

### `PlainData` {#TypeSpec.Http.PlainData}

Expand Down
12 changes: 9 additions & 3 deletions eng/common/pipelines/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
trigger: none
trigger:
branches:
include:
- gh-readonly-queue/*

pr:
branches:
include:
- main
- gh-readonly-queue/*

extends:
template: /eng/common/pipelines/templates/1es-redirect.yml
Expand All @@ -19,14 +22,17 @@ extends:
- job: InitJob
displayName: Initialize
steps:
- script: node $(Build.SourcesDirectory)/eng/common/scripts/resolve-target-branch.js
displayName: Resolve target branch

- task: PowerShell@2
displayName: "Analyze PR changes"
name: InitStep
inputs:
pwsh: true
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Analyze-Changes.ps1
arguments: >
-TargetBranch $(System.PullRequest.TargetBranch)
-TargetBranch $TARGET_BRANCH
workingDirectory: $(Build.SourcesDirectory)

# Run csharp stages if RunCSharp == true
Expand Down
25 changes: 25 additions & 0 deletions eng/common/scripts/resolve-target-branch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// @ts-check
console.log("Process", process.env);
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

const prTargetBranch = process.env["SYSTEM_PULLREQUEST_TARGETBRANCHNAME"];
const currentBranch = process.env["BUILD_SOURCEBRANCH"];

console.log("Branches:", {
prTargetBranch,
currentBranch,
});

if (prTargetBranch !== undefined) {
console.log("Target branch is", prTargetBranch);
console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${prTargetBranch}`);
} else if (currentBranch) {
const segments = currentBranch.split("/");
if (segments[0] === "github-readonly-queue") {
const targetBranch = segments.slice(1, segments.length - 2).join("/");
console.log("Target branch is", targetBranch);
console.log(`##vso[task.setvariable variable=TARGET_BRANCH]${targetBranch}`);
}
} else {
console.log("Failed to resolve target branch.");
process.exit(1);
}
4 changes: 2 additions & 2 deletions packages/http/lib/auth.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ model PasswordFlow {
@doc("password flow")
type: OAuth2FlowType.password;

@doc("the authorization URL")
authorizationUrl: string;
@doc("the token URL")
tokenUrl: string;

@doc("the refresh URL")
refreshUrl?: string;
Expand Down
Loading