"ASP. NET Web API" authentication with OWIN

Source: Internet
Author: User

Overview

This article explains how to use OWIN to implement the validation capabilities of the ASP. NET Web API, and the mechanism to avoid repeating the user name and password during client-server interaction.

Clients can be divided into two categories:

    • JavaScript: Can be understood as Web pages
    • Native: Including mobile app, Windows client, etc.

Steps

    1. For access tokens via username and password, please refer to:
      http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/
    2. To implement the refresh token mechanism, please refer to:
      http://bitoftech.net/2014/07/16/enable-oauth-refresh-tokens-angularjs-app-using-asp-net-web-api-2-owin/

Sample code

Please refer to: https://github.com/attilah/AngularJSAuthentication

Verification process

    1. The user accesses the API for the first time, submitting the user name, password, and client ID (that is, the application ID that describes which application is coming from).
    2. The server returns access tokens (short-term, such as half-hour) and refresh token (valid for a longer period, such as six months).
    3. Within half an hour, users can interact with the server using Access tokens, without having to submit a user name and password.
    4. After half an hour, access token expires and the user submits a refresh token and client ID to obtain a new access token.
    5. Each time the access token is refreshed, the original refresh token is deleted, and a new refresh token is generated and the validity period is postponed.
    6. If the user does not have access to the server during the refresh token validity period, the refresh token expires and the user name and password will be submitted on the next visit.

Understanding the principle is far more important than reading the sample code, and according to the above procedure, you can customize the code to achieve more detailed control.

Ext.: http://www.cnblogs.com/csharpstyle/articles/4928019.html

(GO) "ASP. Authentication with OWIN"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.