Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ian 178 posts 752 karma points
    Dec 18, 2015 @ 23:10
    Ian
    0

    Extend Umbraco AngularJs routes for OAuth2

    Hi, i'm creating a package intended for use on multiple client sites and wanted to know if there is a way of registering custom angular routes in the umbraco backend so that I can use it as a callback URL from an external OAuth2 request.

    The long(ish) and detailed synopsis of what I'm trying to do:

    Part of its function involves taking the value of a property whenever a doctype is saved sending it to an external web api which then processes the value and returns a result, the updated property value is then persisted in the umbraco database. So far I've created my property editor and hooked into the cacheUpdated event to process my value in the backchannel and this all works ok.

    My intension is to develop something of a service and that the external api is a resource accessible only to users with an account on another site I am creating (also using Umbraco). In order to establish authorised access the idea is to provide site owners using my package with an account which is used through OAuth2 to access the API. I have chosen Thinktecture IdentityServer3 as my STS and have been able use this successfully to authenticate with accounts on my 'service' site

    Having protected the web api my intention is for the umbraco package to create a section in any client site which provides the ability to do a one-time login to my external userstore using identityservers hybrid flow. The angular driven section would use this module https://github.com/michaelschnyder/oidc-angular/blob/master/oidc-angular.js to initiate the flow from umbraco.

    Once I've received an authorisation code in the response my intension is to create an angular service to send this code to the back channel so that it can be stored and used (by server side code) to request refresh tokens when ever needed in the future, avoiding the need to prompt for further logins.

    So far I have added this to my section controller to load and configure the module

    app.requires.push('base64');
    app.requires.push('ngStorage');
    app.requires.push('oidc-angular');
    
    app.config(function ($authProvider) {
        $authProvider.configure({
            basePath: "https://localhost:44301/core",
            clientId: "umbracoclient",
            responseType: "code id_token",
            scope : "offline_access openid profile read"
        })
    })
    

    and in my controller (with $auth being injected)

    if(!$auth.isAuthenticated())
        {
            $auth.signIn()
        }
    

    This successfully redirects to IdentityServer and once authenticated the callback comes back into to umbraco backend via http://localhost:51205/umbraco#/auth/callback (+token details). The module linked above contains routes to handle this but these do not appear to get into the umbraco backend pipeline. I'm not very familiar with handling modules within the umbraco angular app and am currently stuck at the point of integrating the routes needed for this to work which are.

    /auth/callback/:result
    

    and

    /auth/clear
    

    Many thanks for reading and hope you are able to help.

Please Sign in or register to post replies

Write your reply to:

Draft