Esempio n. 1
0
        public IActionResult CreateSession(string zone)
        {
            var zoneModel = _zones.Single(s => s.LocalPath.Equals(zone, StringComparison.CurrentCultureIgnoreCase));

            if (zoneModel == null)
            {
                return(RedirectToAction(nameof(Error), new { message = $"Could not find Zone for \"zone\"" }));
            }

            var model = new SNWLExternalAuthenticationRedirectModel
            {
                SessionId         = Guid.NewGuid().ToString(),
                MAC               = FakeDataGenerator.GenerateMACAddress(),
                IP                = FakeDataGenerator.GenerateRandomIp(),
                Ufi               = "0006010203",
                SSID              = "",
                req               = "http://www.github.com",
                ClientRedirectUrl = zoneModel.SNWLRedirectEndpointURL,
                MgmtBaseUrl       = _appSettings.ManagementBaseUrl
            };

            // keep track of generated models for session sync
            _stateProvider.AddGeneratedSession(model.Map(zoneModel));

            var fullUrl = string.Concat(_settings.GetLoginPage(zoneModel.LocalPath), buildQueryString(model));

            _logger.LogInformation($"Redirect user to: {fullUrl}");

            return(Redirect(fullUrl));
        }
 public static FakeSNWLSession Map(this SNWLExternalAuthenticationRedirectModel requestModel, StaticZone zone)
 {
     return(new FakeSNWLSession(zone)
     {
         ID = requestModel.SessionId,
         IP = requestModel.IP,
         MAC = requestModel.MAC,
         BaseMgmtUrl = requestModel.MgmtBaseUrl,
         Ssid = requestModel.SSID
     });
 }
Esempio n. 3
0
 private string buildQueryString(SNWLExternalAuthenticationRedirectModel model)
 {
     return($"/?" +
            $"SessionId={model.SessionId}&" +
            $"MAC={model.MAC}&" +
            $"IP={model.IP}&" +
            $"Ufi={model.Ufi}&" +
            $"SSID={model.SSID}&" +
            $"req={Uri.EscapeUriString(model.req)}&" +
            $"ClientRedirectUrl={Uri.EscapeUriString(model.ClientRedirectUrl)}&" +
            $"MgmtBaseUrl={Uri.EscapeUriString(model.MgmtBaseUrl)}");
 }