Skip to content

Commit

Permalink
Use .NET 8 and add coding standard (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
meziantou authored Sep 5, 2024
1 parent 96d5112 commit 64fb8f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion AzureCliCredentialProxy.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -13,5 +13,9 @@

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Workleap.DotNet.CodingStandards" Version="0.6.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://github.com/Azure/azure-cli/issues/19591
# https://iceburn.medium.com/azure-cli-docker-containers-7059750be1f2
FROM mcr.microsoft.com/dotnet/runtime-deps:7.0-alpine AS base
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS base
ENV DOTNET_CLI_TELEMETRY_OPTOUT=true \
AZ_INSTALLER=DOCKER
RUN apk add --no-cache py3-pip && \
Expand All @@ -13,14 +13,14 @@ ENV ASPNETCORE_URLS=http://+:8080
ENV AZURE_CONFIG_DIR=/app/.azure


FROM mcr.microsoft.com/dotnet/sdk:7.0-alpine AS publish
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
WORKDIR /src
COPY . .
RUN dotnet publish "AzureCliCredentialProxy.csproj" -c Release -r linux-musl-x64 -o /app/publish


FROM base AS final
RUN adduser --disabled-password --home /app --gecos '' app && chown -R app /app
RUN chown -R app /app
USER app
WORKDIR /app
COPY --from=publish /app/publish .
Expand Down
10 changes: 5 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@

app.MapGet("/token", async (HttpContext context, string resource) =>
{
var token = await tokenCredential.GetTokenAsync(new TokenRequestContext(new[] { resource }));
context.Response.Headers.Add("Content-Type", "application/json");
var token = await tokenCredential.GetTokenAsync(new TokenRequestContext([resource]));
context.Response.Headers.ContentType = "application/json";
return new Dictionary<string, string>
{
["access_token"] = token.Token,
["expiresOn"] = token.ExpiresOn.ToString("O", CultureInfo.InvariantCulture),
["expires_on"] = token.ExpiresOn.ToUnixTimeSeconds().ToString(),
["expires_on"] = token.ExpiresOn.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture),
["tokenType"] = "Bearer",
["resource"] = resource
};
Expand All @@ -30,7 +30,7 @@
var form = await request.ReadFormAsync();
var resource = form["resource"].ToString();
var token = await tokenCredential.GetTokenAsync(new TokenRequestContext(new[] { resource }));
context.Response.Headers.Add("Content-Type", "application/json");
context.Response.Headers.ContentType = "application/json";
return new Dictionary<string, string>
{
["access_token"] = token.Token,
Expand All @@ -41,4 +41,4 @@
};
});

app.Run();
app.Run();
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.410",
"version": "8.0.401",
"rollForward": "latestMinor",
"allowPrerelease": false
}
Expand Down

0 comments on commit 64fb8f8

Please sign in to comment.