Coder Social home page Coder Social logo

wanzoo1996 / chromeos_saml_apps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from googlechromelabs/chromeos_saml_apps

0.0 0.0 0.0 46 KB

Helper extension for admins to configure SAML SSO for Chrome apps.

Home Page: https://chrome.google.com/webstore/detail/aoggjnmghgmcllfenalipjhmooomfdce/

License: Apache License 2.0

JavaScript 94.58% HTML 5.42%

chromeos_saml_apps's Introduction

SAML SSO for Chrome Apps

SAML SSO for Chrome devices carries only into applications accessed by Chrome browser and not into Chrome Apps. Chrome Apps that need access to these SAML cookies can request them from the SAML SSO for Chrome Apps extension. These apps are granted permission by admins who have to force-install and configure this extension to carry over a filtered set of the user's cookies to the whitelisted participating apps. Documentation for the admin setup can be found on the Chrome for Work support pages.

Communicating with the extension

The SAML SSO for Chrome Apps extension provides an interface over Chrome's cross-extension messaging system. To get all cookies whitelisted for the participating app by the admin, call chrome.runtime.sendMessage with the proper parameters.

chrome.runtime.sendMessage(
              "aoggjnmghgmcllfenalipjhmooomfdce",
              { method: "getAllCookies" },
              function(response) {
                // do something with *response.cookies*
              }
          );

Using acquired cookies

Once the Chrome App has the relevant authentication cookies, it can attach them to outgoing requests on its hosted webview using the various methods available from webview's Web Request interface.

While this is largely dependent on the authentication flow hosted by the app, we provide an example client that receives the cookies and saves them to a hosted webview's cookie store by appending Set-Cookie headers on incoming requests with the values of these SAML cookies.

Whitelisting apps and domains

The SAML SSO for Chrome Apps has to be both force-installed and configured for user accounts. This can be done by navigating directly to the App Management URL corresponding to this extension.

The full schema of possible configurations can be found in schema.json. Note that the primary filter is always the domain. Cookie names, paths, and secure properties are all secondary parameters that will be applied in addition to the domain filtering. An entry with no domain provided will not return any cookies. An example configuration:

{
  "whitelist": {
    "Value": [
      {
        "appId": "aaaaabbbbbbcccccddddd",
        "domain": "domain1",
        "secure": true
      },
      {
        "appId": "aaaaabbbbbbcccccddddd",
        "domain": "domain1",
        "name": "Secondary Cookie Name"
      },
      {
        "appId": "eeeeefffffgggggghhhhhhh",
        "domain": "domain1",
        "path": "secondary.path"
      }
    ]
  }
}

More details can be found on the Chrome for Work support page.

Android Runtime for Chrome

Apps developed with Android Runtime for Chrome can also get access to those cookies. They can communicate with the Chrome SSO extension via a special Android intent.

class ChromeMessageReceiver extends BroadcastReceiver {
    private static String TAG = "ChromeMessageReceiver";

    public List<Intent> receivedMessages = new ArrayList<Intent>();

    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "ARC app received Chrome message: " + intent);
        receivedMessages.add(intent);
        synchronized (this) {
            this.notifyAll();
        }
    }
}

public class ChromeMessagingTestActivity extends Activity {
    private static String TAG = "ChromeMessagingTestActivity";

    private ChromeMessageReceiver mReceiver = new ChromeMessageReceiver();

    @Override
    public void onStart() {
        super.onStart();
        registerReceiver(mReceiver,
                new IntentFilter("org.chromium.arc.CHROME_MESSAGE_RECEIVED"));
    }


    @Override
    public void onStop() {
        super.onStop();
        unregisterReceiver(mReceiver);
    }

    public void sendMessage(String extensionId, String data) {
        Intent i = new Intent("org.chromium.arc.SEND_CHROME_MESSAGE");
        i.setPackage("android");
        i.putExtra("org.chromium.arc.ExtensionId", extensionId);
        i.putExtra("org.chromium.arc.Request", data);
        Log.d(TAG, "ARC app sending Chrome message: " + data);
        sendBroadcast(i);
    }

    public List<Intent> getReceivedMessages() {
        return mReceiver.receivedMessages;
    }

    public boolean waitForMessages(int numberOfMessagesInQueue, int timeout) {
        if (mReceiver.receivedMessages.size() < numberOfMessagesInQueue) {
            try {
                synchronized (mReceiver) {
                    mReceiver.wait(timeout);
                }
            } catch (InterruptedException e) {
            }
        }
        return mReceiver.receivedMessages.size() >= numberOfMessagesInQueue;
    }
}

chromeos_saml_apps's People

Contributors

dskaram avatar alex292 avatar emaxx-google 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.