1- using System . Diagnostics . CodeAnalysis ;
21using Microsoft . AspNetCore . Authentication . Cookies ;
32using Microsoft . AspNetCore . Authentication . OpenIdConnect ;
4- using Microsoft . AspNetCore . Authorization ;
53using Microsoft . IdentityModel . Protocols . OpenIdConnect ;
64using SchoolAccount . SharedKernel ;
75using SchoolAccount . Web . Mvc . Authentication . Models ;
6+ using static SchoolAccount . Web . Mvc . Authentication . ClaimConstants ;
87
98namespace SchoolAccount . Web . Mvc . Authentication . Extensions ;
109
@@ -40,8 +39,8 @@ IConfigurationManager configuration
4039 options . SignInScheme = CookieAuthenticationDefaults . AuthenticationScheme ;
4140 options . ResponseType = OpenIdConnectResponseType . IdToken ;
4241
43- options . Scope . Add ( "organisation" ) ;
44- options . Scope . Add ( "email" ) ;
42+ options . Scope . Add ( Organisation ) ;
43+ options . Scope . Add ( Email ) ;
4544 options . SaveTokens = true ;
4645 options . GetClaimsFromUserInfoEndpoint = true ;
4746
@@ -54,6 +53,17 @@ IConfigurationManager configuration
5453 context . HttpContext . Session . Clear ( ) ;
5554 await Task . CompletedTask ;
5655 } ,
56+ // within ACA a container runs on http, though available as https publicly
57+ // this causes the OIDC redirect_url to have the http protocol, rather than https
58+ // DSI does not allow http redirect URLS. The following corrects the URL
59+ OnRedirectToIdentityProvider = async n =>
60+ {
61+ n . ProtocolMessage . RedirectUri = n . ProtocolMessage . RedirectUri . Replace (
62+ "http://" ,
63+ "https://"
64+ ) ;
65+ await Task . CompletedTask ;
66+ } ,
5767 } ;
5868 } ) ;
5969
0 commit comments