How to authenticate a user in a .NET Core MVC frontend, with a .net core identity framework












0














I have an ASP.NET CORE MVC WebApp with Identity framework. Now that we are also planning to extend our product such that we can provide mobile apps with xamerin, I decided to make an API so that we don't have to code the backend twice. We currently host our App in the Azure Cloud.



For the backend: I would like to use ASP.NET CORE WebApi but I figured that there is no such Identity template nor a native Azure Web API integration. So would it be better to use ASP.NET instead? I already created a basic login AccountController for .net core API.



Since I authenticated the ASP.NET Core MVC Web App via identity framework, I would like to also use that in the backend. So that you log in on the backend and receive a token, once you logged in successfully. I have to code to login the user at the backend and return a token.



How exactly can I authenticate the .NET ASP CORE Frontend? The user will query the login page -> AuthConntroller.Login-> Login method starts a call to Login Backend API -> Backend API queries backend-database -> if successful return true-> backend generates a token->sends it back to frontend-> frontend uses Owin so that I can use the [Authorize] Attribute in the controller classes so that I can authenticate the user?



Anything else that I have to consider when I'm using such an API design?



Thank you so much for any hints/tricks/links/recommendations on my dilemma.



Sincerely, Paul










share|improve this question



























    0














    I have an ASP.NET CORE MVC WebApp with Identity framework. Now that we are also planning to extend our product such that we can provide mobile apps with xamerin, I decided to make an API so that we don't have to code the backend twice. We currently host our App in the Azure Cloud.



    For the backend: I would like to use ASP.NET CORE WebApi but I figured that there is no such Identity template nor a native Azure Web API integration. So would it be better to use ASP.NET instead? I already created a basic login AccountController for .net core API.



    Since I authenticated the ASP.NET Core MVC Web App via identity framework, I would like to also use that in the backend. So that you log in on the backend and receive a token, once you logged in successfully. I have to code to login the user at the backend and return a token.



    How exactly can I authenticate the .NET ASP CORE Frontend? The user will query the login page -> AuthConntroller.Login-> Login method starts a call to Login Backend API -> Backend API queries backend-database -> if successful return true-> backend generates a token->sends it back to frontend-> frontend uses Owin so that I can use the [Authorize] Attribute in the controller classes so that I can authenticate the user?



    Anything else that I have to consider when I'm using such an API design?



    Thank you so much for any hints/tricks/links/recommendations on my dilemma.



    Sincerely, Paul










    share|improve this question

























      0












      0








      0







      I have an ASP.NET CORE MVC WebApp with Identity framework. Now that we are also planning to extend our product such that we can provide mobile apps with xamerin, I decided to make an API so that we don't have to code the backend twice. We currently host our App in the Azure Cloud.



      For the backend: I would like to use ASP.NET CORE WebApi but I figured that there is no such Identity template nor a native Azure Web API integration. So would it be better to use ASP.NET instead? I already created a basic login AccountController for .net core API.



      Since I authenticated the ASP.NET Core MVC Web App via identity framework, I would like to also use that in the backend. So that you log in on the backend and receive a token, once you logged in successfully. I have to code to login the user at the backend and return a token.



      How exactly can I authenticate the .NET ASP CORE Frontend? The user will query the login page -> AuthConntroller.Login-> Login method starts a call to Login Backend API -> Backend API queries backend-database -> if successful return true-> backend generates a token->sends it back to frontend-> frontend uses Owin so that I can use the [Authorize] Attribute in the controller classes so that I can authenticate the user?



      Anything else that I have to consider when I'm using such an API design?



      Thank you so much for any hints/tricks/links/recommendations on my dilemma.



      Sincerely, Paul










      share|improve this question













      I have an ASP.NET CORE MVC WebApp with Identity framework. Now that we are also planning to extend our product such that we can provide mobile apps with xamerin, I decided to make an API so that we don't have to code the backend twice. We currently host our App in the Azure Cloud.



      For the backend: I would like to use ASP.NET CORE WebApi but I figured that there is no such Identity template nor a native Azure Web API integration. So would it be better to use ASP.NET instead? I already created a basic login AccountController for .net core API.



      Since I authenticated the ASP.NET Core MVC Web App via identity framework, I would like to also use that in the backend. So that you log in on the backend and receive a token, once you logged in successfully. I have to code to login the user at the backend and return a token.



      How exactly can I authenticate the .NET ASP CORE Frontend? The user will query the login page -> AuthConntroller.Login-> Login method starts a call to Login Backend API -> Backend API queries backend-database -> if successful return true-> backend generates a token->sends it back to frontend-> frontend uses Owin so that I can use the [Authorize] Attribute in the controller classes so that I can authenticate the user?



      Anything else that I have to consider when I'm using such an API design?



      Thank you so much for any hints/tricks/links/recommendations on my dilemma.



      Sincerely, Paul







      c# asp.net-core asp.net-identity aspnetcoretemplatepack






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 16:56









      PauLyPauLy

      395




      395
























          1 Answer
          1






          active

          oldest

          votes


















          1














          If I understand the problem correctly this sources it might be little help:



          https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1&tabs=visual-studio



          http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
          https://github.com/openiddict/openiddict-core



          In such cases, it may not be enough Asp.Net Identity by itself. You can provide Auth server project these libraries for your client projects.






          share|improve this answer





















          • Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
            – PauLy
            Nov 21 '18 at 19:07











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417070%2fhow-to-authenticate-a-user-in-a-net-core-mvc-frontend-with-a-net-core-identit%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          If I understand the problem correctly this sources it might be little help:



          https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1&tabs=visual-studio



          http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
          https://github.com/openiddict/openiddict-core



          In such cases, it may not be enough Asp.Net Identity by itself. You can provide Auth server project these libraries for your client projects.






          share|improve this answer





















          • Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
            – PauLy
            Nov 21 '18 at 19:07
















          1














          If I understand the problem correctly this sources it might be little help:



          https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1&tabs=visual-studio



          http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
          https://github.com/openiddict/openiddict-core



          In such cases, it may not be enough Asp.Net Identity by itself. You can provide Auth server project these libraries for your client projects.






          share|improve this answer





















          • Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
            – PauLy
            Nov 21 '18 at 19:07














          1












          1








          1






          If I understand the problem correctly this sources it might be little help:



          https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1&tabs=visual-studio



          http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
          https://github.com/openiddict/openiddict-core



          In such cases, it may not be enough Asp.Net Identity by itself. You can provide Auth server project these libraries for your client projects.






          share|improve this answer












          If I understand the problem correctly this sources it might be little help:



          https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1&tabs=visual-studio



          http://docs.identityserver.io/en/release/quickstarts/6_aspnet_identity.html
          https://github.com/openiddict/openiddict-core



          In such cases, it may not be enough Asp.Net Identity by itself. You can provide Auth server project these libraries for your client projects.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 18:48









          mstfcckmstfcck

          3582617




          3582617












          • Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
            – PauLy
            Nov 21 '18 at 19:07


















          • Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
            – PauLy
            Nov 21 '18 at 19:07
















          Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
          – PauLy
          Nov 21 '18 at 19:07




          Thanks, looks I think that's pretty much what I need, I will read into it. Thank you!
          – PauLy
          Nov 21 '18 at 19:07


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417070%2fhow-to-authenticate-a-user-in-a-net-core-mvc-frontend-with-a-net-core-identit%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen