mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
auth with cas
This commit is contained in:
parent
8c99977fc9
commit
8c2df6178d
150 changed files with 43682 additions and 24175 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({});
|
66
gui/app/pods/auth/cas/route.js
Normal file
66
gui/app/pods/auth/cas/route.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
// 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,
|
||||
replace : true,
|
||||
}
|
||||
},
|
||||
message: '',
|
||||
|
||||
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)) {
|
||||
this.set('message', reject.Error);
|
||||
} else {
|
||||
this.set('message', reject);
|
||||
}
|
||||
this.set('mode', 'reject');
|
||||
resolve();
|
||||
});
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
model(params) {
|
||||
return {
|
||||
mode: this.get('mode'),
|
||||
message: this.get('message'),
|
||||
ticket: params.ticket
|
||||
}
|
||||
}
|
||||
});
|
13
gui/app/pods/auth/cas/template.hbs
Normal file
13
gui/app/pods/auth/cas/template.hbs
Normal file
|
@ -0,0 +1,13 @@
|
|||
{{#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>
|
||||
<p>{{model.message}}</p>
|
||||
</div>
|
||||
{{/if}}
|
|
@ -12,7 +12,6 @@
|
|||
import { inject as service } from '@ember/service';
|
||||
import AuthProvider from '../../../mixins/auth';
|
||||
import Controller from '@ember/controller';
|
||||
import {Promise as EmberPromise} from "rsvp";
|
||||
|
||||
export default Controller.extend(AuthProvider, {
|
||||
appMeta: service('app-meta'),
|
||||
|
@ -73,14 +72,6 @@ export default Controller.extend(AuthProvider, {
|
|||
// this.set('invalidCredentials', true);
|
||||
// });
|
||||
// }
|
||||
},
|
||||
loginWithCAS(){
|
||||
// let config = this.get('config');
|
||||
let url = 'https://sso.bangdao-tech.com/sso/login?service=' + encodeURIComponent('https://duty.bangdao-tech.com/');
|
||||
window.location.replace(url);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,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,11 +27,7 @@
|
|||
{{input type="password" value=password id="authPassword" class="form-control" autocomplete="current-password"}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{#if isAuthProviderCAS}}
|
||||
{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.SignIn onClick=(action "loginWithCAS")}}
|
||||
{{else}}
|
||||
{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.SignIn onClick=(action "login")}}
|
||||
{{/if}}
|
||||
{{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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue