Webservice REST with authentication [ID, CPF, User, Password]

Asked

Viewed 506 times

0

Hello, I’ve been searching the web for a while but I can’t find clear answers..

I want to implement a webservice Rest, with tokens and etc for security, and the webservice consists of only GET for queries with our SQL Server, but I’m having difficulty generating an authentication that requires 4 parameters, which are id, Cpf, user and password.

Then the way would be the following: The user logs in through the App with the 4 parameters, beats the authentication on the server, generates the token that will be reused so that the login in the app is persistent and thus can make GET requests to get information from your system..

The project has to be in . NET 4.5 and we are creating it by Visual Studio 2015.

Could someone point me to a good place to learn about it, or give me a little of your minutes to write me a good answer?

  • What is your specific doubt? The flow described seems to make a lot of sense and there is nothing unusual in its implementation. Take a look at this article from Baltieri: https://weblogs.asp.net/andrebaltieri/implementando-bearer-autentication-com-webapi-e-owin

  • I’m not able to do a process like this with more than 2 parameters (user, password)

  • But this is in the authorization process... just receive the additional parameters, and check if they match the user obtained in the login and password authentication.

  • I discovered that it is creating an object and receiving with a [Frombody].

  • 1

    Ahhh yes, if you had included the code that would have been noticed instantly.

1 answer

0


To register my solution, I created a "Login" model that contained all the information needed for the call in my Controller with the Frombody parameter.

public HttpResponseMessage Post([FromBody]Login param)
{
    //TODO
}

From then on, all POST requests to the Webapi would be supplemented with the parameters (Json) to the Login model, and can then use all the fields necessary for my methods.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.