GithubHelp home page GithubHelp logo

ji-auth-framework's Introduction

JIAuthFramework

A light API to use the JI Auth service.

How to use?

You need to compile and distribute it locally to be able to use it. It's a simple sbt command:

sbt publishLocal

The methods are pretty easy to use.

Use in a play application

CAS Authentication

The CAS bindings are in ch.japanimpact.auch.api.cas.CASService.

You need to add the following section in your configuration:

cas {
    hostname = "auth.japan-impact.ch" // the hostname (and port) of the CAS server
    uri = "/cas/v2" // the base path of CAS on the given hostname
    service = <define here> // the hostname of the current service
    secure = true // set to false to disable use of HTTPS
}

If you wish to use proxy CAS, you also need to define a route for proxy callback.

In routes add:

GET   /pgCallback   ch.japanimpact.auch.api.cas.ProxyController.proxyCallback(pgtId: String, pgtIou: String)

(the pgCallback path is provided as an example, you can use the path you like)

Auth API

AuthAPI provides binding to the Authentication API (to get user info, for example).

First, you'll need a method to provide the authClient in your application module. Similar for other modules.

@Provides
def provideAuthClient(ws: WSClient)(implicit ec: ExecutionContext, config: Configuration): AuthApi = AuthApi(ws)

This version reads values from the config file

jiauth {
  clientId = ""
  clientSecret = ""
  baseUrl = ""
}

You can also provide these values directly

@Provides
def provideAuthClient(ws: WSClient)(implicit ec: ExecutionContext, config: Configuration): AuthApi = {
    new AuthApi(ws, appBaseUrl, clientId, clientSecret)
}

You can then inject the AuthApi in your components or service to use it. Refer to the documentation of the class for more info.

The usage is pretty straightforward and well documented, see AuthApi.scala.

Use in a PHP application

Just require the class and create an instance of it.

require 'JIAuth.class.php';

$baseUrl = "https://auth.japan-impact.ch/";
$clientId = "client_id";
$clientSecret = "client_secret";

$auth = new JIAuth($baseUrl, $clientId, $clientSecret);

ji-auth-framework's People

Contributors

zyuiop avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.