npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ptpn4-adonis-sso

v0.1.3

Published

PTPN IV SSO Adonis Client Auth

Downloads

9

Readme

N4 SSO Client

Adonis Auth Extended for Private PTPN IV SSO Server

Installation

adonis install ptpn4-adonis-sso

or

npm i ptpn4-adonis-sso

Configuration

  • Register SsoAuthProvider and IhcsProvider in start/app.js:
const providers = [
  //...
  'ptpn4-adonis-sso/providers/SsoAuthProvider',
  'ptpn4-adonis-sso/ihcs/providers/IhcsProvider',
  //...
]
  • Add the SSO specific setting for SSO Server to .env file
SSO_APP_CODE=MYAPPCODE
SSO_CHECKPOINT_URL=https://my.sso_server.url/login?redirect=/sso/checkpoint/${SSO_APP_CODE}
SSO_LOGOUT_REDIRECT=https://my.sso_server.url
SSO_API_URL=https://myapi.sso_server.url:port/sso/

How To Use

  • This route is mandatory. This route is related to SSO authentication start/routes.js
Route.get('/', 'LoginController.index').middleware(['auth'])
Route.get('/sso', 'LoginController.redirect')
Route.get('/sso/checkpoint/', 'LoginController.checkpoint')
Route.get('/sso/logout', 'LoginController.logout')
Route.get('/logout', 'LoginController.logout')

Next Step

Create services.js File in \config directory

'use strict'

/*
|--------------------------------------------------------------------------
| Services Configuration
|--------------------------------------------------------------------------
|
| This is general purpose file to define configuration for multiple services.
| The below config is for the ally provider. Make sure to save it inside
| config/services.js file.
|
| Happy Coding :)
|
*/

const Env = use('Env')

module.exports = {

  ihcs: {
    sso: {
      appCode: Env.get('SSO_APP_CODE'),
      checkpointUrl: Env.get('SSO_CHECKPOINT_URL'),
      logoutRedirect: Env.get('SSO_LOGOUT_REDIRECT'),
      apiUrl: Env.get('SSO_API_URL')
    },
  }
}

Next Step

  • Create LoginController.js file in app/Controllers/Http
'use strict'

class LoginController {

  async index ({ view, auth }) {
      let data = {
        user: auth.user
      }
      
      // console.log(auth.user)
      
      try {
        auth.getUser()
        .then((value) => {
          console.log(value)
        })
      } catch (error) {
        return error.message
      }

      return view.render('welcome', data)
  }

	async redirect ({ ihcs, auth, response }) {
    try {
      if(await auth.check()) {
        response.redirect('back')
      } else {        
		    await ihcs.driver('sso').redirect()
      }
    } catch (error) {
      return error.message
    }
	}

	async checkpoint ({ ihcs, auth, response }) {
    try {
      if(await auth.check()) {
        response.redirect('/')
      } else {        
        await auth._removeSession()
        const ssoUser = await ihcs.driver('sso').getUser()
        await auth.login(ssoUser)
        response.redirect('back')
      }
    } catch (error) {
      return error.message
    }
  }

  async logout({ auth, response }) {
    const Env = use('Env')
    await auth.logout()
    return response.redirect(Env.get('SSO_LOGOUT_REDIRECT'))
  }
}

module.exports = LoginController
  • Please note : this package is for private SSO Server with own standard. This might be different from SSO with international standards.
  • we don't have a github repository for this package because we use it for our internal needs. Harefa : [email protected]