Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Feb 28, 2024
2 parents 3e0d692 + b121162 commit fcd5ef6
Show file tree
Hide file tree
Showing 15 changed files with 522 additions and 521 deletions.
5 changes: 2 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://+:8009"
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
Expand All @@ -47,7 +46,7 @@
"pipeProgram": "ssh",
"pipeArgs": [
"-T",
"root@<docker-host>",
"root@ensyno.iwes.fraunhofer.de",
"-p",
"2222"
], // replace <docker host>
Expand Down
1 change: 0 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"--project",
"${workspaceFolder}/src/Nexus/Nexus.csproj"
],

"problemMatcher": "$msCompile"
},
{
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.0.0-beta.22 - 2024-02-28

### Bugs fixed:
- Fix log out error "Missing parameters: id_token_hint".

## v2.0.0-beta.21 - 2023-09-29

### Features:
Expand Down
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "7.0.400"
}
}
2 changes: 1 addition & 1 deletion src/Nexus.ClientGenerator/Nexus.ClientGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Apollo3zehn.OpenApiClientGenerator" Version="1.0.0-beta.6" />
<PackageReference Include="Apollo3zehn.OpenApiClientGenerator" Version="1.0.0-beta.8" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Nexus.UI/Core/NexusDemoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,12 @@ public Task<string> GetHelpLinkAsync(CancellationToken cancellationToken = defau
return Task.FromResult("https://github.com/malstroem-labs/nexus");
}

public void SetConfiguration(IReadOnlyDictionary<string, JsonElement?>? configuration)
public void SetConfiguration(IReadOnlyDictionary<string, JsonElement>? configuration)
{
throw new NotImplementedException();
}

public Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement?>? configuration, CancellationToken cancellationToken = default)
public Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement>? configuration, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
Expand Down
6 changes: 6 additions & 0 deletions src/Nexus/API/SystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ namespace Nexus.Controllers
[Route("api/v{version:apiVersion}/[controller]")]
internal class SystemController : ControllerBase
{
// [authenticated]
// GET /api/system/configuration
// GET /api/system/file-type
// GET /api/system/help-link

// [privileged]
// PUT /api/system/configuration

#region Fields
Expand Down Expand Up @@ -74,6 +79,7 @@ public SystemController(
/// Sets the system configuration.
/// </summary>
[HttpPut("configuration")]
[Authorize(Policy = NexusPolicies.RequireAdmin)]
public Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement>? configuration)
{
return _appStateManager.PutSystemConfigurationAsync(configuration);
Expand Down
6 changes: 4 additions & 2 deletions src/Nexus/API/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ internal class UsersController : ControllerBase

// [authenticated]
// GET /api/users/me
// GET /api/users/accept-license?catalogId=X
// POST /api/users/tokens/generate
// POST /api/users/accept-license?catalogId=X
// DELETE /api/users/tokens/{tokenId}

// [privileged]
Expand Down Expand Up @@ -146,7 +146,9 @@ public async Task<ActionResult<TokenPair>> RefreshTokenAsync(RefreshTokenRequest
if (token.Token != request.RefreshToken)
{
_logger.LogWarning($"Attempted reuse of revoked token of user {token.Owner.Id} ({token.Owner.Name}).");
await _authService.RevokeTokenAsync(token);

# warning Temporarily disabled
// await _authService.RevokeTokenAsync(token);
}

if (token.IsExpired)
Expand Down
17 changes: 17 additions & 0 deletions src/Nexus/Core/NexusAuthExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,24 @@ public static IServiceCollection AddNexusAuth(
options.ClientSecret = provider.ClientSecret;

options.CallbackPath = $"/signin-oidc/{provider.Scheme}";

/* OIDC spec RECOMMENDS id_token_hint (= id_token) to be added when
* post_logout_redirect_url is specified
* (https://openid.net/specs/openid-connect-rpinitiated-1_0.html)
*
* To be able to provide that parameter the (large) ID token must
* become part of the auth cookie. The /connect/logout endpoint in
* NexusIdentityProviderExtensions.cs is then getting that logout_hint
* query parameter automatically (this has been tested!).
* This parameter then is part of the httpContext.Request.Query dict.
*
* Why do we enable this when this is just recommended? Because newer
* version of Keycloak REQUIRE it, otherwise we get a
* "Missing parameters: id_token_hint" error.
*/
options.SaveTokens = true;
options.SignedOutCallbackPath = $"/signout-oidc/{provider.Scheme}";

options.ResponseType = OpenIdConnectResponseType.Code;

options.TokenValidationParameters.AuthenticationType = provider.Scheme;
Expand Down
8 changes: 4 additions & 4 deletions src/Nexus/Extensions/Writers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This data writer supports the following optional request configuration parameters:

| key | value | data type | default |
|---|---|---|---|
| `row-index-format` | `"index"` &#124; `"unix"` &#124; `"excel"` &#124; `"iso-8601"` | string | `"index"` |
| `significant-figures` | [0, 30] | string | `"4"` |
| key | value | data type | default |
| --------------------- | -------------------------------------------------------------- | --------- | --------- |
| `row-index-format` | `"index"` &#124; `"unix"` &#124; `"excel"` &#124; `"iso-8601"` | string | `"index"` |
| `significant-figures` | [0, 30] | string | `"4"` |
6 changes: 3 additions & 3 deletions src/Nexus/PackageManagement/PackageController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public async Task<string[]> DiscoverAsync(CancellationToken cancellationToken)
"git-tag" => await DiscoverGitTagsAsync(cancellationToken),
"github-releases" => await DiscoverGithubReleasesAsync(cancellationToken),
"gitlab-packages-generic-v4" => await DiscoverGitLabPackagesGenericAsync(cancellationToken),
/* this approach does not work, see rationale below (#region gitlab-releases-v4) *///case "gitlab-releases-v4":
// result = await DiscoverGitLabReleasesAsync(cancellationToken);
// break;
/* this approach does not work, see rationale below (#region gitlab-releases-v4)
* "gitlab-releases-v4" => await DiscoverGitLabReleasesAsync(cancellationToken);
*/
_ => throw new ArgumentException($"The provider {PackageReference.Provider} is not supported."),
};
return result;
Expand Down
8 changes: 4 additions & 4 deletions src/clients/dotnet-client/NexusClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2262,14 +2262,14 @@ public interface ISystemClient
/// Sets the system configuration.
/// </summary>
/// <param name="configuration"></param>
void SetConfiguration(IReadOnlyDictionary<string, JsonElement?>? configuration);
void SetConfiguration(IReadOnlyDictionary<string, JsonElement>? configuration);

/// <summary>
/// Sets the system configuration.
/// </summary>
/// <param name="configuration"></param>
/// <param name="cancellationToken">The token to cancel the current operation.</param>
Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement?>? configuration, CancellationToken cancellationToken = default);
Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement>? configuration, CancellationToken cancellationToken = default);

}

Expand Down Expand Up @@ -2344,7 +2344,7 @@ public Task<string> GetHelpLinkAsync(CancellationToken cancellationToken = defau
}

/// <inheritdoc />
public void SetConfiguration(IReadOnlyDictionary<string, JsonElement?>? configuration)
public void SetConfiguration(IReadOnlyDictionary<string, JsonElement>? configuration)
{
var __urlBuilder = new StringBuilder();
__urlBuilder.Append("/api/v1/system/configuration");
Expand All @@ -2354,7 +2354,7 @@ public void SetConfiguration(IReadOnlyDictionary<string, JsonElement?>? configur
}

/// <inheritdoc />
public Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement?>? configuration, CancellationToken cancellationToken = default)
public Task SetConfigurationAsync(IReadOnlyDictionary<string, JsonElement>? configuration, CancellationToken cancellationToken = default)
{
var __urlBuilder = new StringBuilder();
__urlBuilder.Append("/api/v1/system/configuration");
Expand Down
46 changes: 23 additions & 23 deletions src/clients/python-client/nexus_api/_nexus_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ def decode(type: Type[T], data: Any, options: Optional[JsonEncoderOptions] = Non
def _decode(typeCls: Type[T], data: Any, options: JsonEncoderOptions) -> T:

if data is None:
return typing.cast(T, None)
return cast(T, None)

if typeCls == Any:
return data

origin = typing.cast(Type, typing.get_origin(typeCls))
origin = typing.get_origin(typeCls)
args = typing.get_args(typeCls)

if origin is not None:
Expand All @@ -101,7 +101,7 @@ def _decode(typeCls: Type[T], data: Any, options: JsonEncoderOptions) -> T:
baseType = args[0]
instance3 = JsonEncoder._decode(baseType, data, options)

return typing.cast(T, instance3)
return cast(T, instance3)

# list
elif issubclass(origin, list):
Expand All @@ -112,7 +112,7 @@ def _decode(typeCls: Type[T], data: Any, options: JsonEncoderOptions) -> T:
for value in data:
instance1.append(JsonEncoder._decode(listType, value, options))

return typing.cast(T, instance1)
return cast(T, instance1)

# dict
elif issubclass(origin, dict):
Expand All @@ -125,7 +125,7 @@ def _decode(typeCls: Type[T], data: Any, options: JsonEncoderOptions) -> T:
for key, value in data.items():
instance2[key] = JsonEncoder._decode(valueType, value, options)

return typing.cast(T, instance2)
return cast(T, instance2)

# default
else:
Expand All @@ -140,7 +140,7 @@ def _decode(typeCls: Type[T], data: Any, options: JsonEncoderOptions) -> T:
for key, value in data.items():

key = options.property_name_decoder(key)
parameter_type = typing.cast(Type, type_hints.get(key))
parameter_type = cast(Type, type_hints.get(key))

if (parameter_type is not None):
value = JsonEncoder._decode(parameter_type, value, options)
Expand All @@ -159,7 +159,7 @@ def _decode(typeCls: Type[T], data: Any, options: JsonEncoderOptions) -> T:
else:
parameters[key] = None

instance = typing.cast(T, typeCls(**parameters))
instance = cast(T, typeCls(**parameters))

return instance

Expand Down Expand Up @@ -952,7 +952,7 @@ def get_license(self, catalog_id: str) -> Awaitable[Optional[str]]:
__url = "/api/v1/catalogs/{catalogId}/license"
__url = __url.replace("{catalogId}", quote(str(catalog_id), safe=""))

return self.___client._invoke(Optional[str], "GET", __url, "application/json", None, None)
return self.___client._invoke(str, "GET", __url, "application/json", None, None)

def get_attachments(self, catalog_id: str) -> Awaitable[list[str]]:
"""
Expand Down Expand Up @@ -1344,9 +1344,9 @@ def get_configuration(self) -> Awaitable[Optional[dict[str, object]]]:

__url = "/api/v1/system/configuration"

return self.___client._invoke(Optional[dict[str, object]], "GET", __url, "application/json", None, None)
return self.___client._invoke(dict[str, object], "GET", __url, "application/json", None, None)

def set_configuration(self, configuration: Optional[dict[str, Optional[object]]]) -> Awaitable[None]:
def set_configuration(self, configuration: Optional[dict[str, object]]) -> Awaitable[None]:
"""
Sets the system configuration.
Expand Down Expand Up @@ -1733,7 +1733,7 @@ def get_license(self, catalog_id: str) -> Optional[str]:
__url = "/api/v1/catalogs/{catalogId}/license"
__url = __url.replace("{catalogId}", quote(str(catalog_id), safe=""))

return self.___client._invoke(Optional[str], "GET", __url, "application/json", None, None)
return self.___client._invoke(str, "GET", __url, "application/json", None, None)

def get_attachments(self, catalog_id: str) -> list[str]:
"""
Expand Down Expand Up @@ -2125,9 +2125,9 @@ def get_configuration(self) -> Optional[dict[str, object]]:

__url = "/api/v1/system/configuration"

return self.___client._invoke(Optional[dict[str, object]], "GET", __url, "application/json", None, None)
return self.___client._invoke(dict[str, object], "GET", __url, "application/json", None, None)

def set_configuration(self, configuration: Optional[dict[str, Optional[object]]]) -> None:
def set_configuration(self, configuration: Optional[dict[str, object]]) -> None:
"""
Sets the system configuration.
Expand Down Expand Up @@ -2602,7 +2602,7 @@ def clear_configuration(self) -> None:
if self._configuration_header_key in self._http_client.headers:
del self._http_client.headers[self._configuration_header_key]

async def _invoke(self, typeOfT: Type[T], method: str, relative_url: str, accept_header_value: Optional[str], content_type_value: Optional[str], content: Union[None, str, bytes, Iterable[bytes], AsyncIterable[bytes]]) -> T:
async def _invoke(self, typeOfT: Optional[Type[T]], method: str, relative_url: str, accept_header_value: Optional[str], content_type_value: Optional[str], content: Union[None, str, bytes, Iterable[bytes], AsyncIterable[bytes]]) -> T:

# prepare request
request = self._build_request_message(method, relative_url, content, content_type_value, accept_header_value)
Expand Down Expand Up @@ -2653,18 +2653,18 @@ async def _invoke(self, typeOfT: Type[T], method: str, relative_url: str, accept
try:

if typeOfT is type(None):
return typing.cast(T, type(None))
return cast(T, type(None))

elif typeOfT is Response:
return typing.cast(T, response)
return cast(T, response)

else:

jsonObject = json.loads(response.text)
return_value = JsonEncoder.decode(typeOfT, jsonObject, _json_encoder_options)
return_value = JsonEncoder.decode(cast(Type[T], typeOfT), jsonObject, _json_encoder_options)

if return_value is None:
raise NexusException(f"N01", "Response data could not be deserialized.")
raise NexusException("N01", "Response data could not be deserialized.")

return return_value

Expand Down Expand Up @@ -3078,7 +3078,7 @@ def clear_configuration(self) -> None:
if self._configuration_header_key in self._http_client.headers:
del self._http_client.headers[self._configuration_header_key]

def _invoke(self, typeOfT: Type[T], method: str, relative_url: str, accept_header_value: Optional[str], content_type_value: Optional[str], content: Union[None, str, bytes, Iterable[bytes], AsyncIterable[bytes]]) -> T:
def _invoke(self, typeOfT: Optional[Type[T]], method: str, relative_url: str, accept_header_value: Optional[str], content_type_value: Optional[str], content: Union[None, str, bytes, Iterable[bytes], AsyncIterable[bytes]]) -> T:

# prepare request
request = self._build_request_message(method, relative_url, content, content_type_value, accept_header_value)
Expand Down Expand Up @@ -3129,18 +3129,18 @@ def _invoke(self, typeOfT: Type[T], method: str, relative_url: str, accept_heade
try:

if typeOfT is type(None):
return typing.cast(T, type(None))
return cast(T, type(None))

elif typeOfT is Response:
return typing.cast(T, response)
return cast(T, response)

else:

jsonObject = json.loads(response.text)
return_value = JsonEncoder.decode(typeOfT, jsonObject, _json_encoder_options)
return_value = JsonEncoder.decode(cast(Type[T], typeOfT), jsonObject, _json_encoder_options)

if return_value is None:
raise NexusException(f"N01", "Response data could not be deserialized.")
raise NexusException("N01", "Response data could not be deserialized.")

return return_value

Expand Down
Loading

0 comments on commit fcd5ef6

Please sign in to comment.