-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as querystring from 'querystring'; | ||
import * as dotenv from 'dotenv'; | ||
import axios from 'axios'; | ||
|
||
import clients from '../config/clients-configuration.json'; | ||
import type { Client } from '../types'; | ||
|
||
describe('Base path', () => { | ||
let client: Client; | ||
|
||
beforeAll(() => { | ||
dotenv.config(); | ||
client = clients.find(c => c.ClientId === 'client-credentials-flow-client-id'); | ||
expect(client).toBeDefined(); | ||
}); | ||
|
||
test('Discovery Endpoint', async () => { | ||
const response = await axios.get(process.env.OIDC_DISCOVERY_ENDPOINT_WITH_BASE_PATH); | ||
expect(response.data.token_endpoint).toEqual(process.env.OIDC_TOKEN_URL_WITH_BASE_PATH); | ||
}); | ||
|
||
test('Token Endpoint', async () => { | ||
const parameters = { | ||
client_id: client.ClientId, | ||
client_secret: client.ClientSecrets?.[0], | ||
grant_type: 'client_credentials', | ||
scope: client.AllowedScopes.join(' '), | ||
}; | ||
|
||
const response = await axios.post(process.env.OIDC_TOKEN_URL_WITH_BASE_PATH, querystring.stringify(parameters)); | ||
expect(response).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using IdentityServer4.Extensions; | ||
using Microsoft.AspNetCore.Http; | ||
using System.Threading.Tasks; | ||
using IdentityServer4.Configuration; | ||
|
||
#pragma warning disable 1591 | ||
|
||
namespace OpenIdConnectServer.Middlewares | ||
{ | ||
public class BasePathMiddleware | ||
{ | ||
private readonly RequestDelegate _next; | ||
private readonly IdentityServerOptions _options; | ||
|
||
public BasePathMiddleware(RequestDelegate next, IdentityServerOptions options) | ||
{ | ||
_next = next; | ||
_options = options; | ||
} | ||
|
||
public async Task Invoke(HttpContext context) | ||
{ | ||
var basePath = Config.GetAspNetServicesOptions().BasePath; | ||
var request = context.Request; | ||
if(request.Path.Value.Length > basePath.Length) | ||
{ | ||
request.Path = request.Path.Value.Substring(basePath.Length); | ||
context.SetIdentityServerBasePath(basePath); | ||
} | ||
await _next(context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters