Tag Archives: OAuth

[RESOLVED]Adding a new field in Register Page.Storing Data in DataBase

Hi, 

 I’m new to this,To start with i downloaded a wingtip web asp.net sample. I want to include a new field ‘EMPLOYEEID" in register page and store the data in AspNetUsers database table. I have created the field in Register page and a new column in database(Aspnetuser.EmployeeID)
.

What are the changes to be done in code to add the user data to database through register page.

//For now I have done something like this: IN register.aspx page I changed this(in BOLD)

protected void CreateUser_Click(object sender, EventArgs e)
{
var manager = Context.GetOwinContext().GetUserManager<ApplicationUserManager>();
var user = new ApplicationUser() { UserName = Name.Text, Email = Email.Text , EmployeeID = EmployeeID};
IdentityResult result = manager.Create(user, Password.Text);

Hi harshilshah,

Thanks for your post.

Based on my understanding ,you want to add extra information in  AspNetUsers database table?

Firstly you need to install these two packages:- Microsoft.Aspnet.Identity.Core

This package contains the core interfaces of ASP.NET Identity.Microsoft.Aspnet.Identity.EntityFramework

This package contains the implementation of ASP.NET Identity System which works with Entity Framework Code First. This means that if we use this package then we can store information in a SQL Server database. Also we can easily plug other databases if we
wanted.and then updated your IDE

Secondly,Enable Entity Framework Code First Database Migrations.Thirdly,Add new properties

Fourthly,Add New Migration

Fifthly,Update RegisterViewModel

and then Update Register View Page and Update Account Controller’s Register action (Post Version)

Details information:

#Customize User’s Profile in ASP.NET Identity System

http://www.itorian.com/2013/11/customize-users-profile-in-aspnet.html

Hope this can be helpful.

Best Regards.

Eileen

[RESOLVED]MVC Tutorials removed from website

Hello ! this week i got started with the Microsoft MVC. I was doing the movie store tutorial under the MVC4 tutorial pages and today when i was gonna continue the tutorial has been removed. All MVC tutorials are gone from the tutorials page of microsoft
MVC. Does anyone have a PDF or something with the tuts ? I woud like to complete the MvcMovie (MVC 4 tutorial),

Regards.

EDIT: I have found a PDF with the tutorial. (I dont know about posting links so if anybody needs it just google "mvc movie tutorial pdf" its the first link), shame on me, i should’ve searched the google before posting here.

Hi,

 My suggestion, use the following site:

http://www.asp.net/mvc/overview/getting-started/introduction/getting-started,

If you need to learn MVC, do not waste your time learn MVC4. Go direct to MVC 5. MVC 6 is coming next year, but MVC 5 still good to learn. Here a free video :

http://pluralsight.com/training/Player?author=scott-allen&name=aspdotnet-mvc5-fundamentals-m1-introduction&mode=live&clip=0&course=aspdotnet-mvc5-fundamentals

Have fun 

Hi,

Going forward, please post the link broken in feedback section of the forums.

http://forums.asp.net/188.aspx/1?Feedback+on+this+website

EDIT:

Notes from Terry:

We have consolidated the "Overview" and "Tutorials" areas into one "Guidance" area for MVC. There will be redirects to the new locations put up within the next day. You can see the old and new URLs here: http://forums.asp.net/t/2014539.aspx?ASP+NET+MVC+Content+Reorganization+10+23+2014

The content can be found under http://www.asp.net/mvc/overview. The tutorial you are looking for is now here: http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

I apologize for any inconvenience.

As the problem is now resolved, please look for any content in the latest urls.

Old and new links table announcement:

http://forums.asp.net/t/2014539.aspx?ASP+NET+MVC+Content+Reorganization+10+23+2014

Regards

Siva

[RESOLVED]PPage Removed from site: MVC 5 OAuth tutorial

This site page seems to be removed

http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on#goog

Hi,

There looks to be few more threads regarding tutorial links broken. Please post the link broken in feedback section of the forums.

http://forums.asp.net/188.aspx/1?Feedback+on+this+website

Regards

Siva

Notes from Terry on Feedback forums section:

We have consolidated the "Overview" and "Tutorials" areas into one "Guidance" area for MVC. There will be redirects to the new locations put up within the next day. You can see the old and new URLs here: http://forums.asp.net/t/2014539.aspx?ASP+NET+MVC+Content+Reorganization+10+23+2014

The content can be found under http://www.asp.net/mvc/overview. The tutorial you are looking for is now here: http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

I apologize for any inconvenience.

So, please look into the latest urls for the content.

Old and new links table announcement:

http://forums.asp.net/t/2014539.aspx?ASP+NET+MVC+Content+Reorganization+10+23+2014

how to customize my MVC project to support oAuth

I have learned oAuth2.0 with Google, Facebook, twitter…

 I want to be able to secure my web API’s that I  build in my MVC 5 project . how do I do that?how do I create the app for the web APi if im following the tutorials as mentioned by let’s say google.is there is something like that.

for example the web API for getting the products on the asp.net tutorial, how can I support the oAuth2.0 for that?

did you looknat tutorials?

http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

ignatandrei

did you looknat tutorials?

http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

ofcourse I did but I really got lost , this tutorials teaches me how to get the id and secret from applications for facebook and stuff like that, what about my APP and where is the ACS in azure playing role.I’m really lost and need help. what does the ACS
have to do?where do I use OAuth in my MVC application?

so many questions and very few documentation.all documents concerning this issue are about the same topic facebook and google

can you help?

lolo512

really got lost , this tutorials teaches me how to get the id and secret from applications for facebook and stuff like that, what about my APP and where is the ACS in azure playing role

I do not understand why you mention ACS in Azure. What’s that?
More, what problems did you have with tutorials? Try to reproduce on your PC and tell the error

securing web API using oAuth 2 and azure ACS

I have read lots of tutorials about securing web API’s using oAuth2. I have also created the ACS in the azure. but still I don’t understand what does the ACS have to do with securing web API’s. I find this tutorial supportive http://www.asp.net/aspnet/overview/owin-and-katana/owin-oauth-20-authorization-server but
don’t know where the ACS role is supposed to be. I need to understand the process step by step what is supposed to happen to secure the web API.

can anyone please support me with information?

ACS has some support for producing tokens, but ACS is being deprecated by Microsoft, so I’d suggest to not develop anything new using it.

I’m obliged to use ACS my task is to secure my web API’s through oAuth2 using ACS. I should generate my own registration server. but i’m missing the flow I don’t know what to do so little documentation about the subject

Hi lolo512,

Please take a look at this article below:

# ACS v2 OAuth 2.0 Delegation Support Explained

http://blogs.msdn.com/b/adventurousidentity/archive/2011/09/18/acs-v2-oauth-2-0-delegation-support-explained.aspx

Best Regards

Starain

[RESOLVED]secure my WEB API with oAuth2 using ACS

I have built my MVC 5 project and the web api project as well, published both on azure and all working fine.now I want to secure my web api with oAuth2 using ACS on azure. I have followed step by step the tutorial for that:

https://github.com/maartenba/WindowsAzure.Acs.Oauth2/blob/master/README.md#windows-azure-access-control-settings

and when running I’m having this error:

the AcsAuthenticationModule could not be registered for your application.Remove the AppStart_OAuth2API.cs file from your project and add the following entry under the system.webServer.httpModules section in the web.config:<add name=…../>

Ineed to know what is going wrong. I have tried the above but still shows an error that the path s missing

Hi,

If you would like to register module dynamically, you can try using
PreApplicationStartMethod
attribute.

For more information, please refer to the document:

#Register your HTTP modules at runtime without config

http://blog.davidebbo.com/2011/02/register-your-http-modules-at-runtime.html

#Three Hidden Extensibility Gems in ASP.NET 4

http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx/

Explicitly token validation

Hi,

I am doing an Asp.net web Api 2 project and  I am using OAuth. Now I am able to generate token and send it to client. Now I am want to send that token to server from client using jQuery ajax call and validated that token
explicitly and get user information. I am not using asp.net identity.

Code

public class UserModel
    {     
        public string UserName { get; set; }
        public string Password { get; set; }        
        public string ConfirmPassword { get; set; }
    }

public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            ConfigureOAuth(app);
            HttpConfiguration config = new HttpConfiguration();
            WebApiConfig.Register(config);            
            app.UseWebApi(config);
        }

        public void ConfigureOAuth(IAppBuilder app)
        {
            OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
            {
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
                Provider = new SimpleAuthorizationServerProvider()
            };

            // Token Generation
            app.UseOAuthAuthorizationServer(OAuthServerOptions);
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

        }
    }

public class SimpleAuthorizationServerProvider : OAuthAuthorizationServerProvider
    {        
        public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            // Resource owner password credentials does not provide a client ID.
            if (context.ClientId == null)
            {
                context.Validated();
            }

            return Task.FromResult<object>(null);
        }

        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            using (AuthRepository _repo = new AuthRepository())
            {
                var user = _repo.FindUser(context.UserName, context.Password);

                if (user == null)
                {
                    context.SetError("invalid_grant", "The user name or password is incorrect.");
                    return;
                }
            }

            var identity = new ClaimsIdentity(context.Options.AuthenticationType);
            identity.AddClaim(new Claim("sub", context.UserName));
            identity.AddClaim(new Claim("role", "user"));

            context.Validated(identity);

        }
    }