Example #1
0
        public void EditAuthentication(int id, ApplicationAuthenticationDetails model, LoggedInUserDetails user)
        {
            // Check whether organisation is active
            if (!user.Organization.IsActive)
            {
                throw new BaseException(
                          "Your organization is inactive. Please check if your organization has approved Legal Officer. For more details contact DataLinker administrator.");
            }
            // Check whether user has access to application
            var application = _security.CheckAccessToApplication(user, id);

            // Get auth details
            var appAuth = _authentications.FirstOrDefault(i => i.ApplicationID == application.ID);

            // Setup update details
            appAuth.UpdatedAt             = GetDate;
            appAuth.UpdatedBy             = user.ID;
            appAuth.WellKnownUrl          = string.IsNullOrEmpty(model.WellKnownUrl) ? string.Empty : model.WellKnownUrl;
            appAuth.Issuer                = string.IsNullOrEmpty(model.Issuer) ? string.Empty : model.Issuer;
            appAuth.JwksUri               = string.IsNullOrEmpty(model.JwksUri) ? string.Empty : model.JwksUri;
            appAuth.AuthorizationEndpoint = model.AuthorizationEndpoint;
            appAuth.TokenEndpoint         = model.TokenEndpoint;
            appAuth.RegistrationEndpoint  = model.RegistrationEndpoint;
            appAuth.UserInfoEndpoint      = string.Empty;
            appAuth.EndSessionEndpoint    = string.Empty;
            appAuth.CheckSessionIFrame    = string.Empty;
            appAuth.RevocationEndpoint    = string.Empty;

            // Save changes
            _authentications.Update(appAuth);
        }
Example #2
0
        public ApplicationAuthenticationDetails SetupEditAppAuthModel(int id, LoggedInUserDetails user)
        {
            // Check whether organisation is not active
            if (!user.Organization.IsActive)
            {
                throw new BaseException(
                          "Your organization is inactive. Please check if your organization has approved Legal Officer. For more details contact DataLinker administrator.");
            }

            // Get applciation
            var app = _security.CheckAccessToApplication(user, id);

            // Setup result model
            var result = new ApplicationAuthenticationDetails();

            // Get auth details
            var appAuth = _authentications.FirstOrDefault(i => i.ApplicationID == app.ID);

            // Check whether
            if (appAuth == null)
            {
                throw new BaseException("Auth not found");
            }

            // Setup result
            result = appAuth.ToModel();
            return(result);
        }
Example #3
0
        public ActionResult EditApplicationAuthentication(int id, ApplicationAuthenticationDetails model)
        {
            // Update authentication for user
            _applications.EditAuthentication(id, model, LoggedInUser);

            // Return result
            return(RedirectToAction("Details", new { id }));
        }
Example #4
0
        public void ShouldFailEditApplicationAuthenticationForNotOrganizationMember()
        {
            controller.LoggedInUser = new LoggedInUserDetails(user)
            {
                Organization = new LoggedInOrganization(otherOrganization)
            };

            var model = new ApplicationAuthenticationDetails();

            controller.EditApplicationAuthentication(activeService.ID, model);
        }
Example #5
0
        public void ShouldFailEditApplicationAuthenticationForNotExistingApplication()
        {
            controller.LoggedInUser = new LoggedInUserDetails(user)
            {
                Organization = new LoggedInOrganization(organization)
            };

            var model  = new ApplicationAuthenticationDetails();
            var result = (HttpStatusCodeResult)controller.EditApplicationAuthentication(0, model);

            appService.Verify(i => i.Get(0));
            Assert.IsTrue(result.StatusCode == (int)HttpStatusCode.NotFound);
        }
Example #6
0
        public void ShouldEditApplicationAuthentication()
        {
            controller.LoggedInUser = new LoggedInUserDetails(user)
            {
                Organization = new LoggedInOrganization(organization)
            };

            var model = new ApplicationAuthenticationDetails();

            controller.EditApplicationAuthentication(activeService.ID, model);
            appService.Verify(i => i.Get(activeService.ID));
            applicationAuthenticationService.Verify(i => i.Update(It.IsAny <ApplicationAuthentication>()));
        }
        public static ApplicationAuthenticationDetails ToModel(this ApplicationAuthentication appAuth)
        {
            var result = new ApplicationAuthenticationDetails();

            result.ID                    = appAuth.ID;
            result.ApplicationID         = appAuth.ApplicationID;
            result.WellKnownUrl          = appAuth.WellKnownUrl;
            result.Issuer                = appAuth.Issuer;
            result.JwksUri               = appAuth.JwksUri;
            result.AuthorizationEndpoint = appAuth.AuthorizationEndpoint;
            result.TokenEndpoint         = appAuth.TokenEndpoint;
            result.RegistrationEndpoint  = appAuth.RegistrationEndpoint;
            result.RevocationEndpoint    = appAuth.RevocationEndpoint;

            return(result);
        }