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

Changes into SecurityProvider interface and Logout middleware #757

Merged
merged 3 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions dotnet/src/dotnetframework/GxClasses/Middleware/GXHttpServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,28 @@ public GXOAuthLogout()

public override void webExecute()
{
string genexus_agent = localHttpContext.Request.Headers["Genexus-Agent"];
try
{
GxSecurityProvider.Provider.oauthlogout(context);
GxSecurityProvider.Provider.oauthlogout(context, out string URL, out short statusCode);

if (statusCode == 303)
MBarnech marked this conversation as resolved.
Show resolved Hide resolved
localHttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
else
localHttpContext.Response.StatusCode = statusCode;

JObject jObj = new JObject();
if (genexus_agent == "WebFrontend Application" && URL.Length > 0)
{
localHttpContext.Response.AddHeader("GXLocation", URL);
jObj.Put("GXLocation", URL);
}
else
{
jObj.Put("code", statusCode.ToString());
}
localHttpContext.Response.Write(jObj.ToString());
localHttpContext.Response.ContentType = MediaTypesNames.ApplicationJson;
localHttpContext.Response.StatusCode = 200;
localHttpContext.Response.Write(new JObject().ToString());
context.CloseConnections();
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface ISecurityProvider
GxResult oauthauthentication(IGxContext context, String grantType, String userName, String userPassword, String clientId, String clientSecret, String scope, String additionalParameters, out OutData outData, out String URL, out bool flag);
void oauthgetuser(IGxContext context, out String userJson, out bool isOK);
void oauthlogout(IGxContext context);

void oauthlogout(IGxContext context, out String URL, out short statusCode);
MBarnech marked this conversation as resolved.
Show resolved Hide resolved
}
public class GxSecurityProvider
{
Expand Down Expand Up @@ -161,6 +161,12 @@ public void oauthgetuser(IGxContext context, out string userJson, out bool isOK)
public void oauthlogout(IGxContext context)
{
}

public void oauthlogout(IGxContext context, out string URL, out short statusCode)
{
URL = string.Empty;
statusCode = 0;
}
}

}