27 lines
809 B
C#
27 lines
809 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace TIAMWebApp.Server.Services
|
|
{
|
|
public class AuthService
|
|
{
|
|
public string GetAuthTokenFromRequest(HttpRequest request)
|
|
{
|
|
// Check if the Authorization header is present
|
|
if (request.Headers.ContainsKey("Authorization"))
|
|
{
|
|
// Extract the token from the Authorization header
|
|
var authHeader = request.Headers["Authorization"].ToString();
|
|
if (authHeader.StartsWith("Bearer ", System.StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
return authHeader.Substring("Bearer ".Length).Trim();
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
}
|
|
}
|