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

[Admin UI] http call "PUT /api/clients/<clientId>/urls" receives 405 Method Not Allowed! #236

Open
ChristosAsvestopoulos opened this issue May 31, 2023 · 0 comments

Comments

@ChristosAsvestopoulos
Copy link
Contributor

ChristosAsvestopoulos commented May 31, 2023

Dear Indice Development Team,

The http call "PUT /api/clients/{clientId}/urls" from AdminUI receives 405 Method Not Allowed! (Please note, that we are not using the minimal API version of Identity Server)

Code from identity-api.service.ts:

    /**
     * Renews the list of client urls (redirect cors etc).
     * @return No Content
     */
    updateClientUrls(clientId: string, body: UpdateClientUrls): Observable<void> {
        let url_ = this.baseUrl + "/api/clients/{clientId}/urls";
        if (clientId === undefined || clientId === null)
            throw new Error("The parameter 'clientId' must be defined.");
        url_ = url_.replace("{clientId}", encodeURIComponent("" + clientId));
        url_ = url_.replace(/[?&]$/, "");

        const content_ = JSON.stringify(body);

        let options_ : any = {
            body: content_,
            observe: "response",
            responseType: "blob",
            headers: new HttpHeaders({
                "Content-Type": "application/json",
            })
        };

        return this.http.request("put", url_, options_).pipe(_observableMergeMap((response_ : any) => {
            return this.processUpdateClientUrls(response_);
        })).pipe(_observableCatch((response_: any) => {
            if (response_ instanceof HttpResponseBase) {
                try {
                    return this.processUpdateClientUrls(response_ as any);
                } catch (e) {
                    return _observableThrow(e) as any as Observable<void>;
                }
            } else
                return _observableThrow(response_) as any as Observable<void>;
        }));
    }

But, notice that, the aforementioned endpoint only accepts POST http calls (ClientsController.cs in Indice.AspNetCore.Identity):

    /// <summary>Renews the list of </summary>
    /// <param name="clientId">The id of the client.</param>
    /// <param name="request"></param>
    /// <response code="204">No Content</response>
    /// <response code="404">Not Found</response>
    [Authorize(AuthenticationSchemes = IdentityServerApi.AuthenticationScheme, Policy = IdentityServerApi.Policies.BeClientsWriter)]
    [CacheResourceFilter(DependentPaths = new string[] { "{clientId}" })]
    [Consumes(MediaTypeNames.Application.Json)]
    [HttpPost("{clientId}/urls")]
    [Produces(MediaTypeNames.Application.Json)]
    [ProducesResponseType(statusCode: StatusCodes.Status204NoContent, type: typeof(void))]
    [ProducesResponseType(statusCode: StatusCodes.Status404NotFound, type: typeof(ProblemDetails))]
    public async Task<IActionResult> UpdateClientUrls([FromRoute] string clientId, [FromBody] UpdateClientUrls request) {

In minimal API, it all seems OK:

    group.MapPut("{clientId}/urls", ClientHandlers.UpdateClientUrls)
         .WithName(nameof(ClientHandlers.UpdateClientUrls))
         .WithSummary("Renews the list of client urls (redirect cors etc).")
         .RequireAuthorization(IdentityEndpoints.Policies.BeClientsWriter)
         .InvalidateCache(nameof(ClientHandlers.GetClient))
         .WithParameterValidation<UpdateClientUrls>();
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

No branches or pull requests

1 participant