First version of Service
This commit is contained in:
		
							
								
								
									
										25
									
								
								Core.Inventory.External/Helpers/HttpContextTokenProvider.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								Core.Inventory.External/Helpers/HttpContextTokenProvider.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| using Microsoft.AspNetCore.Http; | ||||
|  | ||||
| namespace Core.Inventory.External.Helpers | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Class to return the access token to controllers. | ||||
|     /// </summary> | ||||
|     public class HttpContextTokenProvider : ITokenProvider | ||||
|     { | ||||
|         private readonly IHttpContextAccessor _httpContextAccessor; | ||||
|  | ||||
|         public HttpContextTokenProvider(IHttpContextAccessor httpContextAccessor) | ||||
|         { | ||||
|             _httpContextAccessor = httpContextAccessor; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Get token from headers. | ||||
|         /// </summary> | ||||
|         public string GetToken() | ||||
|         { | ||||
|             return _httpContextAccessor.HttpContext?.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user