Extending authentication session on Azure container app

Milorad Savcic 61 Reputation points
2023-10-06T07:56:28.21+00:00

Enabling authentication on a container app introduces a cookie to the browser with which the user can proceed through the authentication middleware to the application.

This cookie has a session which is maintained on the authentication middleware, with a lifetime of 8 hours.

Is there a way to extend this session lifetime?

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
282 questions
{count} votes

Accepted answer
  1. TP 78,666 Reputation points
    2023-10-18T03:01:53.6233333+00:00

    Hi Milorad,

    Please see below sample code for 60 days duration that you can try in test environment. I recommend you have all your authentication and identity provider settings backed up in separate file in case you run into a problem and need to re-configure manually.

    In my tests the sample didn't cause any issues with existing auth config, however, I didn't perform extensive testing.

    $containerAppName = "mycontainerapp"
    $resourceGroupName = "myresourcegroup"
    $cookieTTL = "60.00:00:00"
    $authConfig = Get-AzContainerAppAuthConfig -AuthConfigName current -ContainerAppName $containerAppName -ResourceGroupName $resourceGroupName
    $params = @{AuthConfigName="current";ContainerAppName=$containerAppName;ResourceGroupName=$resourceGroupName;CookieExpirationConvention="FixedTime";CookieExpirationTimeToExpiration=$cookieTTL}
    $authProps = @("ForwardProxyConvention","ForwardProxyCustomHostHeaderName","ForwardProxyCustomProtoHeaderName","GlobalValidationExcludedPath","GlobalValidationRedirectToProvider","GlobalValidationUnauthenticatedClientAction","HttpSettingRequireHttps","IdentityProvider","LoginAllowedExternalRedirectUrl","LoginPreserveUrlFragmentsForLogin","NonceExpirationInterval","NonceValidateNonce","PlatformEnabled","PlatformRuntimeVersion","RouteApiPrefix","RouteLogoutEndpoint")
    $authProps|ForEach-Object -Process {if ($authConfig.$_ -ne $null) {$params.Add($_.ToString(),$authConfig.$_)}}
    New-AzContainerAppAuthConfig @params
    
    

    Please click Accept Answer and upvote if above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful