mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
Merge pull request #306 from dereknex/auth-with-cas
Authentication with Central Authentication Service (CAS) such as https://www.apereo.org/projects/cas
This commit is contained in:
commit
29d7307537
156 changed files with 43417 additions and 23003 deletions
14
gui/app/pods/auth/cas/controller.js
Normal file
14
gui/app/pods/auth/cas/controller.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import Controller from '@ember/controller';
|
||||
|
||||
export default Controller.extend({});
|
65
gui/app/pods/auth/cas/route.js
Normal file
65
gui/app/pods/auth/cas/route.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
import { Promise as EmberPromise } from 'rsvp';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Route.extend({
|
||||
ajax: service(),
|
||||
session: service(),
|
||||
appMeta: service(),
|
||||
localStorage: service(),
|
||||
queryParams: {
|
||||
mode: {
|
||||
refreshModel: true
|
||||
},
|
||||
ticket : {
|
||||
refreshModel: true
|
||||
}
|
||||
},
|
||||
message: '',
|
||||
mode: 'login',
|
||||
afterModel(model) {
|
||||
return new EmberPromise((resolve) => {
|
||||
let constants = this.get('constants');
|
||||
|
||||
if (this.get('appMeta.authProvider') !== constants.AuthProvider.CAS) {
|
||||
resolve();
|
||||
}
|
||||
let ticket = model.ticket;
|
||||
if (ticket === '') {
|
||||
resolve();
|
||||
}
|
||||
let data = {ticket: ticket};
|
||||
this.get("session").authenticate('authenticator:cas', data).then(() => {
|
||||
this.transitionTo('folders');
|
||||
}, (reject) => {
|
||||
if (!_.isUndefined(reject.Error)) {
|
||||
model.message = reject.Error;
|
||||
} else {
|
||||
model.message = reject.Error;
|
||||
}
|
||||
model.mode = 'reject';
|
||||
resolve();
|
||||
});
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
model(params) {
|
||||
return {
|
||||
mode: this.get('mode'),
|
||||
message: this.get('message'),
|
||||
ticket: params.ticket
|
||||
}
|
||||
}
|
||||
});
|
12
gui/app/pods/auth/cas/template.hbs
Normal file
12
gui/app/pods/auth/cas/template.hbs
Normal file
|
@ -0,0 +1,12 @@
|
|||
{{#if (is-equal model.mode "login")}}
|
||||
<div class="sso-box">
|
||||
<p>Authenticating with CAS...</p>
|
||||
<img src="/assets/img/busy-gray.gif">
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if (is-equal model.mode "reject")}}
|
||||
<div class="sso-box">
|
||||
<p>CAS authentication failure</p>
|
||||
</div>
|
||||
{{/if}}
|
|
@ -16,6 +16,7 @@ import Controller from '@ember/controller';
|
|||
export default Controller.extend(AuthProvider, {
|
||||
appMeta: service('app-meta'),
|
||||
session: service('session'),
|
||||
|
||||
invalidCredentials: false,
|
||||
|
||||
reset() {
|
||||
|
@ -26,7 +27,7 @@ export default Controller.extend(AuthProvider, {
|
|||
});
|
||||
}
|
||||
|
||||
if (this.get('isAuthProviderLDAP')) {
|
||||
if (this.get('isAuthProviderLDAP') || this.get('isAuthProviderCAS')) {
|
||||
this.setProperties({
|
||||
username: '',
|
||||
password: ''
|
||||
|
@ -62,6 +63,16 @@ export default Controller.extend(AuthProvider, {
|
|||
this.set('invalidCredentials', true);
|
||||
});
|
||||
}
|
||||
// if (this.get('isAuthProviderCAS')) {
|
||||
//
|
||||
// this.get('session').authenticate('authenticator:cas').then((response) => {
|
||||
// this.transitionToRoute('folders');
|
||||
// return response;
|
||||
// }).catch(() => {
|
||||
// this.set('invalidCredentials', true);
|
||||
// });
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -17,6 +17,7 @@ import Route from '@ember/routing/route';
|
|||
export default Route.extend({
|
||||
appMeta: service(),
|
||||
kcAuth: service(),
|
||||
global: service(),
|
||||
localStorage: service(),
|
||||
showLogin: false,
|
||||
|
||||
|
@ -40,6 +41,13 @@ export default Route.extend({
|
|||
});
|
||||
|
||||
break;
|
||||
case constants.AuthProvider.CAS: {
|
||||
let config = JSON.parse(this.get('appMeta.authConfig'));
|
||||
let url = config.url + '/login?service=' + encodeURIComponent(config.redirectUrl);
|
||||
window.location.replace(url);
|
||||
resolve();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
this.set('showLogin', true);
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
{{input type="password" value=password id="authPassword" class="form-control" autocomplete="current-password"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.SignIn onClick=(action "login")}}
|
||||
|
||||
{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.SignIn onClick=(action "login")}}
|
||||
|
||||
<div class="{{unless invalidCredentials "invisible"}} color-red-600 mt-3">Invalid credentials</div>
|
||||
{{#if isAuthProviderDocumize}}
|
||||
|
|
|
@ -42,6 +42,9 @@ export default Route.extend(AuthenticatedRouteMixin, {
|
|||
case constants.AuthProvider.LDAP:
|
||||
data.authConfig = config;
|
||||
break;
|
||||
case constants.AuthProvider.CAS:
|
||||
data.authConfig = config;
|
||||
break;
|
||||
case constants.AuthProvider.Documize:
|
||||
data.authConfig = '';
|
||||
break;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{{layout/logo-heading
|
||||
title="Authentication"
|
||||
desc="Choose user authentication provider — Documize, Redhat Keycloak, LDAP/AD"
|
||||
desc="Choose user authentication provider — Documize, Redhat Keycloak, LDAP/AD, Central Authentication Server"
|
||||
icon=constants.Icon.Locked}}
|
||||
|
||||
{{customize/auth-settings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue