Secure Your ASP.NET Web Forms Application with OpenID Connect and Okta

Secure Your ASP.NET Web Forms Application with OpenID Connect and Okta

This tutorial walks you through creating a basic CRUD application with ASP.NET WebAPI and Vue

antony

Shouldn’t the grant type be Authorization Code instead of Implicit? The sample code appears to exchange the auth code for a token.

Umair Khan

How can I have single sign on webform without navigating to okta

Seth

What configuration setting has to be set to allow CodeIdToken? I get the following error: ‘unsupported_response_type’. Error_Description (may be empty): ‘The response type is not supported by the authorization server. Configured response types: [token, code].’

Seth

The answer was this in case anyone else runs into this problem: check that you have Implicit flow with ID token enabled in Okta under Admin >> Application >> OIDC application >> General >> Allowed grant types >> Implicit >> Allow ID Token with implicit grant type

Sadjad Bahmanpour

Is there a such notion as common end point in okta? I need to setup asp.net core auth stack to be used by a multi-tenant application, so we don’t know the organization url at startup time, we know when they login.

Bin Sun

I followed this tutorial. It seems to have one issue - The logout is not working properly. Although the about page shows the user is not authenticated after logout, click login does not prompt user for user name and password. There are some hints suggested to add OpenIdConnectAuthenticationDefaults.AuthenticationType as a parameter to Signout method. Then I get 400 bad request error complaining invalid id token (actually the id_token_hint cannot be found in the signout request to Okta server).

Johan Johansson

I followed this and get this message on login. “Unable to retrieve document from: 'https://xxxx.okta.com/oauth…”. Opening this url gives me {“errorCode”:“E0000015”,“errorSummary”:“You do not have permission to access the feature you are requesting”,“errorLink”:“E0000015”,“errorId”:

But as far as I can see I have assigned the the applcaition to the user I am authenticated as… any ideas please?

Bin Sun

I am also using Okta for a multi-tenant application. I set AuthenticationType to unique string value for each tenant, and it seems to be working. Tenants can be recognized by url, and based on url, the authority url (or uri) can be retrieved from database.

Maicon Martins Felicio

Hi Folks, i’m a begginer in Vuejs and I can’t install npm okata value by command “npm install --save @okta/okta-vue”, i get error message, could anybody help me?

npm WARN rollback Rolling back node-pre-gyp@0.12.0 failed (this is probably harmless): EPERM: operation not permitted, rmdir 'C:\Users\maico\Downloads\vue-material-dashboard-pro-v1.3.1\vue-material-dashboard-pro-v1.3.1\node_modules\fsevents\node_modules’
npm WARN @fullcalendar/timegrid@4.3.0 requires a peer of @fullcalendar/core@~4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN @fullcalendar/daygrid@4.3.0 requires a peer of @fullcalendar/core@~4.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-prettier@3.1.0 requires a peer of eslint@>= 5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-plugin-vue@5.2.2 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN vue-eslint-parser@5.0.0 requires a peer of eslint@^5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

Matt Raible

This looks like a permissions issue on your hard drive, but I’m not sure. Can you please enter this as an issue for the Vue SDK on GitHub?

Andrew

getting this:
Server Error in ‘/’ Application.
A task was canceled.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Threading.Tasks.TaskCanceledException: A task was canceled.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[TaskCanceledException: A task was canceled.]
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +167
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.IdentityModel.Protocols.<getdocumentasync>d__8.MoveNext() +360

[IOException: IDX20804: Unable to retrieve document from: ‘[PII is hidden by default. Set the ‘ShowPII’ flag in IdentityModelEventSource.cs to true to reveal it.]’.]

Nathaniel

Followed the tutorial to a T but am running into this error when clicking the Login button

Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation=“true”/> in configuration or <%@ Page EnableEventValidation=“true” %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Alain Osorio Rodriguez

Hi @disqus_Z2M5ijnkWw , i’m facing exactly your same issue. Did you find out how to fix it?

Tarlok Thakur

Hi,

Above code is working fine on localhost but when I am deploying same code on server getting below error:

Invalid_grant
Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.
Exception Details: System.Exception: invalid_grant

Please help me.

Thanks
Tarlok Singh

Jake Durell

I am getting this error among others: TokenClient does not contain a constructor that takes 3 arguments

Jake Durell

Using IdentityModel.4.1.1

Stuart Smith

Anybody with issues with logout use this in the following:
protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)
{
HttpContext context = HttpContext.Current;
if (context.User.Identity.IsAuthenticated)
{
context.GetOwinContext().Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType, OpenIdConnectAuthenticationDefaults.AuthenticationType);
Response.Redirect(“Default.aspx”);
}
}

Abdul Khan

Is there a way to implement it using visual studio 2008 and .net framework 3.5? How open id along with okta is supported for legacy application ?

leebrandt

Generally, you just need to add the startup.cs file. That’s where OIDC does it’s magic. But I believe it SHOULD work with .NET Fx 3.5. I don’t have access to a machine to test it for sure, but it should work.