Solution Center Login
Login service to handle authentication in the Zalando Solution Center
Installation
Install via bower or npm
bower install solution-center-login
npm install solution-center-login
Usage
-
There is a dependency on Solution Center Communicator. For Bower, if you are using wiredep, the communicator will be loaded automatically. If not, you must manually include the communicator via a
<script>
tag in your index.html file. This script must be included before the login script:<script src="../bower_components/solution-center-communicator/dist/solutioncenter.communicator.js"></script> <script src="../node_modules/solution-center-communicator/dist/solutioncenter.communicator.js"></script>
-
Include the login script in your
<head>
from Bower or NPM:<script src="../bower_components/solution-center-login/dist/solutioncenter.login.js"></script> <script src="../node_modules/solution-center-login/dist/solutioncenter.login.js"></script>
For Bower, if you are using wiredep, it will be loaded automatically.
-
Add solutioncenter.login as a module dependency.
angular.module('my-module', ['solutioncenter.login'])
-
Configure the application by injecting ScAuthenicationServiceProvider in your config block and setting the environment.
.config(['ScAuthenticationServiceProvider', function(ScAuthenticationServiceProvider) { ScAuthenticationServiceProvider.configEnvironment('STAGE'); }
Environment options:
- 'LOCAL' (see Running locally)
- 'INTEGRATION'
- 'STAGE'
- 'PRODUCTION'
-
Protect a certain view (or your entire application) by attaching a resolve to the route (works with ngRoute and UI Router).
resolve: { auth : function(ScAuthenticationService) { return ScAuthenticationService.requireAuthenticatedUser(); } }
### Running locally
When running locally, you need to connect this service to a real (or mocked) login page to handle authentication. You have two options:
#### Run Solution Center locally alongside your application
1. [Run the Solution Center locally from Docker](https://github.bus.zalan.do/norris/solution-center#run-from-docker). Note the port it is running on.
2. Configure solution-center-login to use your local copy for login.
```javascript
ScAuthenticationServiceProvider.configEnvironment('LOCAL', <PORT>, <TOKEN-SERVICE-URL>);
```
* Set `<PORT>` to the port your docker image is running on from step 1 (default: 3333).
* Set `<TOKEN-SERVICE-URL>` to exactly match the TOKEN_SERVICE_URL you passed in to the docker image in step 1.
#### Mock the Solution Center locally
1. Use any login page you like, as long as it is served locally at `/login`.
2. Call `ScAuthenticationService.silentLogin(email, password)` from the mocked login.
3. Configure solution-center-login to use your local login mock.
```javascript
ScAuthenticationServiceProvider.setInternalCommunication(true);
ScAuthenticationServiceProvider.configEnvironment('LOCAL', <PORT>, 'your.mocked.token.endpoint');
```
* Set `<PORT>` to the port your application is running on.
* Note: to work correctly with this library, your mocked token endpoint should conform to our [token API spec](https://token-management.norris.zalan.do/api/index.html#/Token).
### Develop
1. Clone the repository, then run:
```shell
bower install
npm install
- Install Gulp via npm if you don't have it already:
npm install -g gulp
Available commands
-
gulp build
: build the project and make new files indist
-
gulp test
: run unit tests
License
MIT