diff --git a/angularjs-portal-home/src/main/webapp/js/login-config.js b/angularjs-portal-home/src/main/webapp/js/login-config.js new file mode 100644 index 000000000..9b8b41801 --- /dev/null +++ b/angularjs-portal-home/src/main/webapp/js/login-config.js @@ -0,0 +1,7 @@ +'use strict'; +define([], function() { + return { + "loginURL" : null //null for localhost so we don't break things + //"loginURL" : "/portal/Login?silent=true&profile=bucky" //overlay will have something like this + } +}); diff --git a/angularjs-portal-home/src/main/webapp/js/override.js b/angularjs-portal-home/src/main/webapp/js/override.js index 5f72b457c..174102488 100644 --- a/angularjs-portal-home/src/main/webapp/js/override.js +++ b/angularjs-portal-home/src/main/webapp/js/override.js @@ -36,7 +36,7 @@ define(['angular'], function(angular) { 'notificationsURL' : '/web/staticFeeds/notifications.json', 'groupURL' : '/portal/api/groups', 'kvURL' : '/storage', - 'loginSilentURL' : '/portal/Login?silent=true' + 'loginSilentURL' : '/portal/Login?silent=true&profile=bucky' }, 'NAMES' : { 'title' : 'MyUW', diff --git a/angularjs-portal-home/src/main/webapp/main.js b/angularjs-portal-home/src/main/webapp/main.js index 1865f6ea1..1b3e6c88d 100644 --- a/angularjs-portal-home/src/main/webapp/main.js +++ b/angularjs-portal-home/src/main/webapp/main.js @@ -1,10 +1,10 @@ 'use strict'; -require(['./config'], function(config) { +require(['./config', './js/login-config'], function(config, loginConfig) { require.config(config); require(['angular', 'jquery', 'my-app'], function(angular, $) { - //attempting to replicate what they did in + //Idea taken from //https://blog.mariusschulz.com/2014/10/22/asynchronously-bootstrapping-angularjs-applications-with-server-side-data doLogin().then(bootstrapApplication) .catch(function(){ @@ -37,10 +37,10 @@ require(['./config'], function(config) { var $rootScope = initInjector.get('$rootScope'); //login stuff - if(!lastLoginValid($sessionStorage)) { + if(loginConfig.loginURL && !lastLoginValid($sessionStorage)) { //assume not valid, go get a username and bootstrap the user var $http = initInjector.get("$http"); - return $http.get("/portal/Login?silent=true&profile=bucky").then(function(response){ + return $http.get(loginConfig.loginURL).then(function(response){ if("success" === response.data.status) { //store some meta data for caching reason if(!$sessionStorage.portal){ @@ -57,7 +57,9 @@ require(['./config'], function(config) { } else { //the cache is still valid with a valid session, carry on var $q = initInjector.get('$q'); - return $q.resolve("Login cache still valid from previous login"); + return $q.resolve(loginConfig.loginURL + ? "Login cache still valid from previous login" + : "Silent login not configured."); } } }); diff --git a/docs/markdown/home.md b/docs/markdown/home.md index 5b659d6ec..ff8e3c0da 100644 --- a/docs/markdown/home.md +++ b/docs/markdown/home.md @@ -43,6 +43,7 @@ Search over: ## Integration with uPortal + Overview + Customizations/Setup ++ [Silent Login Configuration](#/md/silent-login) - Configure angularjs-portal to do a login before bootstrapping angular. [MyUW Developers Google Group]: https://groups.google.com/forum/#!forum/myuw-developers [uportal-dev@]: https://groups.google.com/a/apereo.org/forum/#!forum/uportal-dev diff --git a/docs/markdown/silent-login.md b/docs/markdown/silent-login.md new file mode 100644 index 000000000..575c3df1e --- /dev/null +++ b/docs/markdown/silent-login.md @@ -0,0 +1,5 @@ +We needed a way to bootstrap a session in portal before fetching things from `/portal/api/*` so we came up with this silent login prestep. + +If you want to configure this, override the `js/login-config.js` file and plug in your login URL that will return JSON saying "success". This works really well with shib since the login should have already happened, this just calls the standard uPortal login code, but since we are saying `silent=true` it'll just return JSON with the username instead of try to redirect the browser to the uPortal home screen. + +If you want to learn more look at `main.js` in `src/main/webapp`.