YellowNotes
YellowNotes copied to clipboard
Sample ASP.NET Web API project with OAuth authentication and many other extensions.
YellowNotes
Sample ASP.NET Web API project with OAuth authentication and many other extensions.
Table of contents
- The basics of API (CRUD)
- Validation
- Authentication and authorization
- Other
- Samples
- Useful links
1. The basics of API (GoodNotesController)
- Create -> Post
- Read -> Get
- Update -> Put
- Delete -> Delete
2. Validation
- Basic validation (via DataAnnotations attributes)
- ModelState validation (ValidateModelStateAttribute)
- Model empty validation (CheckModelForNullAttribute)
- Action parameters validation (ActionParametersValidationAttribute)
3. Authentication and authorization
- Access Token (OAuth bearer token authentication using OWIN middleware) (SimpleAuthorizationServerProvider)
- Client credentials validation
- Token custom parameter
- Authentication Ticket custom property
- Custom claim
- Refresh Token (SimpleRefreshTokenProvider)
- Custom Authorize attribute (SimpleAuthorizeAttribute)
45. Other
- Dependency Injection with Autofac (DependencyConfig)
- API documentation page with Swagger (SwaggerConfig)
- API exceptions handling (RequestExceptionAttribute)
- Working CORS (Cross-Origin Resource Sharing) implementation (CorsProvider)
- Simple Owin middleware to rewrite header from request to response (CorrelationIdHeaderRewriterMiddleware)
5. Samples
Token generation
Access to resource denied
Access to resource granted
Refresh Token utilise
Model validation
CORS (Cross-Origin Resource Sharing)
API Documentation page
6. Useful links
- HTTP Status Codes: https://www.restapitutorial.com/httpstatuscodes.html
- Choosing an HTTP Status Code: ~~http://racksburg.com/choosing-an-http-status-code~~ https://www.ruilog.com/notebook/view/f21862318f93.html