Sitelet https://github.com/sourcejs/Source/tree/master/docs/auth
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

readme.md

Quick Start

Before you start, please make sure that you have referenced GitHub App registered. Please visit this link to get more information.

If you allready have registered app replace existed github api key and secret into your local options file, as mentioned here.

Values, given below, are created as a demo. They are usable for local instance at 127.0.0.1:8080

github: {
    appId: "cf00a9e7ee5d9d6af36f",
    appSecret: "aebe08e0aa66f6911e4f54df81ce64c9d6e0003b"
}

Please take into account, that auth feature is turned off by default and you have to set related option: options.modulesEnabled.auth to true in your config.

After that, auth feature is able to use.

Client-side auth control

GitHub login module should be embedded into your header.inc.html or any other place you want.

Here is the example:

<!-- header.inc.html content-->
      <a class="js-hook source_login"></a>
<!-- header.inc.html content-->

Auth uses js-hook and source_login classes for targeting. This hook is defined into /assets/js/enter-the-source.js file.

Auth configuration

Auth configuration is available from your instance options, as it was mentioned above. Here's few of available options:

// localStorage key for client-side user object
'storageKey': 'sourcejsUser',

// avatar stub URL
'defaultAvatarURL': '/source/assets/i/unknown.gif',

// set of client-side control classes
'classes': {
    'controlsWrapper': 'source_login',
    'loginButton': 'source_login-button',
    'avatar': 'source_login-avatar',
    'anonymous': 'anonymous',
    'hook': 'js-hook'
},

// login/logout button labels
'labels': {
    'login': 'Login',
    'logout': 'Logout'
}

View the full list in /assets/js/modules/auth.js file.

Auth modules usage

Both server-side and client-side auth parts are able to use from other modules.

Server-side part provides The everyauth API whitch it is based on. Also there are methods either to get or to set GitHub user into temporary users storage.

Client-side part allows to login/logout using Github, to check if user is logined and to get user data.