Skip to content

Commit 3bc6b0f

Browse files
authored
Merge pull request #498 from canonical/IAM-1225
Revert commit
2 parents a2b87df + 4d3b94d commit 3bc6b0f

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

pkg/authentication/handlers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestHandleLogin(t *testing.T) {
7777
t.Fatalf("response code error, expected %d, got %d", http.StatusFound, mockResponse.Code)
7878
}
7979

80-
expectedLocation := "/api/v0/?client_id=mock-client-id&nonce=mock-nonce&redirect_uri=http%3A%2F%2Flocalhost%2Fredirect&response_type=code&scope=openid+offline_access&state=mock-state"
80+
expectedLocation := "/api/v0/?audience=mock-client-id&client_id=mock-client-id&nonce=mock-nonce&redirect_uri=http%3A%2F%2Flocalhost%2Fredirect&response_type=code&scope=openid+offline_access&state=mock-state"
8181
location := mockResponse.Header().Get("Location")
8282
if !strings.HasPrefix(location, expectedLocation) {
8383
t.Fatalf("location header error, expected %s, got %s", expectedLocation, location)

pkg/authentication/oidc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func (o *OAuth2Context) LoginRedirect(ctx context.Context, nonce, state string)
5050
_, span := o.tracer.Start(ctx, "authentication.OAuth2Context.LoginRedirect")
5151
defer span.End()
5252

53-
return o.client.AuthCodeURL(state, oidc.Nonce(nonce))
53+
// TODO: remove `audience` parameter when https://github.com/canonical/identity-platform-login-ui/issues/244 is addressed
54+
return o.client.AuthCodeURL(state, oidc.Nonce(nonce), oauth2.SetAuthURLParam("audience", o.client.ClientID))
5455
}
5556

5657
func (o *OAuth2Context) RetrieveTokens(ctx context.Context, code string) (*oauth2.Token, error) {

pkg/authentication/oidc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func TestOAuth2Context_LoginRedirect(t *testing.T) {
140140

141141
location := oauth2Context.LoginRedirect(mockRequest.Context(), "mock-nonce", "mock-state")
142142

143-
expectedLocation := "?client_id=mock-client-id&nonce=mock-nonce&redirect_uri=http%3A%2F%2Flocalhost%2Fapi%2Fv0%2Fauth%2Fcallback&response_type=code&scope=openid+offline_access&state=mock-state"
143+
expectedLocation := "?audience=mock-client-id&client_id=mock-client-id&nonce=mock-nonce&redirect_uri=http%3A%2F%2Flocalhost%2Fapi%2Fv0%2Fauth%2Fcallback&response_type=code&scope=openid+offline_access&state=mock-state"
144144

145145
if location != expectedLocation {
146146
t.Fatalf("location header error, expected %s, got %s", expectedLocation, location)

0 commit comments

Comments
 (0)