Skip to content

Commit 3f62a6d

Browse files
committed
Fix buf authenticate in docker
1 parent 07d2616 commit 3f62a6d

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/AasxCsharpLibrary/SecureAccess/ISecurityAccessHandler.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
33
Author: Michael Hoffmeister
44
@@ -32,7 +32,16 @@ public interface ISecurityAccessHandler
3232
/// to access restricted information from an AAS server.
3333
/// Note: This function is async and may require the GUI thread!
3434
/// </summary>
35-
Task<HttpHeaderDataItem> InteractiveDetermineAuthenticateHeader(string location, bool askForUnknown);
35+
/// <param name="preferInteractiveWhenNone">
36+
/// When <c>true</c> (user enabled Authenticate on Connect) and a matching known endpoint
37+
/// prescribes security method <c>None</c>, still show the interactive method/credentials flow
38+
/// (<c>Ask</c>). Otherwise <c>None</c> skips all prompts — which breaks Docker when release
39+
/// options list a URL with method 0 (None).
40+
/// </param>
41+
Task<HttpHeaderDataItem> InteractiveDetermineAuthenticateHeader(
42+
string location,
43+
bool askForUnknown,
44+
bool preferInteractiveWhenNone = false);
3645

3746
void ClearAllCredentials();
3847
}

src/AasxPackageLogic/PackageCentral/PackageContainerFactory.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
Copyright (c) 2018-2023 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
33
Author: Michael Hoffmeister
44
@@ -195,7 +195,9 @@ public static async Task<PackageContainerBase> GuessAndCreateForAsync(
195195
&& runtimeOptions?.SecurityAccessHandler != null)
196196
{
197197
var extraHeader = await runtimeOptions.SecurityAccessHandler.InteractiveDetermineAuthenticateHeader(
198-
location, Options.Curr.AutoAuthenticateAsk);
198+
location,
199+
Options.Curr.AutoAuthenticateAsk,
200+
preferInteractiveWhenNone: true);
199201
if (extraHeader != null)
200202
{
201203
runtimeOptions.HttpHeaderData = runtimeOptions.HttpHeaderData ?? new HttpHeaderData();

src/AasxPackageLogic/PackageCentral/SecurityAccessHandlerLogicBase.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
Copyright (c) 2019 Festo SE & Co. KG <https://www.festo.com/net/de_de/Forms/web/contact_international>
33
Author: Michael Hoffmeister
44
@@ -126,7 +126,10 @@ public virtual HttpHeaderDataItem LookupAuthenticateHeader(string location)
126126
/// to access restricted information from an AAS server.
127127
/// Note: This function is async and may require the GUI thread!
128128
/// </summary>
129-
public virtual async Task<HttpHeaderDataItem> InteractiveDetermineAuthenticateHeader(string location, bool askForUnknown)
129+
public virtual async Task<HttpHeaderDataItem> InteractiveDetermineAuthenticateHeader(
130+
string location,
131+
bool askForUnknown,
132+
bool preferInteractiveWhenNone = false)
130133
{
131134
// nead a certain distinction!
132135
if (location?.HasContent() != true)
@@ -170,6 +173,10 @@ public virtual async Task<HttpHeaderDataItem> InteractiveDetermineAuthenticateHe
170173
if (me?.Endpoint?.AccessInfo != null)
171174
methodToUse = me.Endpoint.AccessInfo.Method;
172175

176+
// User checked "Authenticate" on Connect, but options preset this URL as "None" (e.g. Docker release JSON).
177+
if (preferInteractiveWhenNone && methodToUse == SecurityAccessMethod.None)
178+
methodToUse = SecurityAccessMethod.Ask;
179+
173180
// if still ask?
174181
if (methodToUse == SecurityAccessMethod.Ask)
175182
{

0 commit comments

Comments
 (0)