4.2.1 • Published 7 years ago

solution-center-login v4.2.1

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

Solution Center Login

Login service to handle authentication in the Zalando Solution Center

Build Status

Changelog

Installation

Install via bower or npm

bower install solution-center-login
npm install solution-center-login

Usage

  1. 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>
  2. 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.

  3. Add solutioncenter.login as a module dependency.

    angular.module('my-module', ['solutioncenter.login'])
  4. Configure the application by injecting ScAuthenicationServiceProvider in your config block and setting the environment.

    .config(['ScAuthenticationServiceProvider', function(ScAuthenticationServiceProvider) {
        ScAuthenticationServiceProvider.configEnvironment('STAGE');
    }

    Environment options:

  1. 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:

  ```bash
  bower install
  npm install
  1. 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 in dist
  • gulp test: run unit tests

License

MIT

4.2.1

7 years ago

4.2.0

7 years ago

4.1.1

7 years ago

4.1.0

7 years ago

4.0.0

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.1.1

7 years ago

2.1.0

8 years ago

2.0.0

8 years ago

1.3.0

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago