Exploring our example application

First, we will need to download the source code from the GitHub repository at https://github.com/EriksonMurrugarra/AureliaAuth0. Let's open a Terminal window in the folder of your preference and run the following command:

$ cd /some/path
$ git clone https://github.com/EriksonMurrugarra/AureliaAuth0

Once the source code is downloaded, we will need to install the dependencies and run the application. Let's get into the source code folder and execute the following commands:

$ cd AureliaAuth0
$ npm install
...
$ au run --watch

Writing app-bundle.js...
Writing vendor-bundle.js...
Finished 'writeBundles'
Application Available At: http://localhost:9000
BrowserSync Available At: http://localhost:3001

Let's open a new browser and navigate to http://localhost:9000, which will display a simple home page with a Log In option in the Navigation bar:

Cool! We have our application up and running, but we will need to configure it first before we can log in successfully. Go ahead and open the following auth-service.js file located in the src folder. We will need to replace the values for the configuration values that we got when we created our client application on Auth0. In our case, the values are the following:

...  
auth0 = new auth0.WebAuth({
domain: 'eriksonmurrugarra.auth0.com',
clientID: 'LBmldq5O0XHPYz4SAyMr03ThgfMOiHs7',
redirectUri: 'http://localhost:9000/callback',
audience: 'https://eriksonmurrugarra.auth0.com/userinfo',
responseType: 'token id_token',
scope: 'openid'
})
...

It's important to mention that the redirectUri should be registered in Auth0 in the application settings in Allowed Callback URLs.

Cool! Save the changes and click on the LOG IN button to be redirected to the following page:

The previous page is provided by Auth0; you might note that the URL has changed. It means that every time that our users are asked to log in, they will be redirected to Auth0. As you haven't created any user account yet, you will need to sign up first. Once you are done with the registration process, you will be redirected to the home page:

That's it! Now you are logged in to the application using a more secure strategy. Remember that you should never implement authentication and authentication yourself. It is best practice to use a third-party service. The developers who created the services such as Auth0 will definitely have had years of experience creating the most secure authentication and authorization mechanism than you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.0.133