mirror of
https://github.com/documize/community.git
synced 2025-07-27 09:09:44 +02:00
working on forentend
This commit is contained in:
parent
9d6b6fec23
commit
8c99977fc9
10 changed files with 130 additions and 5 deletions
39
gui/app/authenticators/cas.js
Normal file
39
gui/app/authenticators/cas.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// 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 { reject, resolve } from 'rsvp';
|
||||||
|
import { inject as service } from '@ember/service';
|
||||||
|
|
||||||
|
import Base from 'ember-simple-auth/authenticators/base';
|
||||||
|
|
||||||
|
export default Base.extend({
|
||||||
|
ajax: service(),
|
||||||
|
appMeta: service(),
|
||||||
|
localStorage: service(),
|
||||||
|
|
||||||
|
restore(data) {
|
||||||
|
// TODO: verify authentication data
|
||||||
|
if (data) {
|
||||||
|
return resolve(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return reject();
|
||||||
|
},
|
||||||
|
|
||||||
|
authenticate(){
|
||||||
|
return this.get('ajax').request('public/authenticate/cas' );
|
||||||
|
},
|
||||||
|
|
||||||
|
invalidate() {
|
||||||
|
this.get('localStorage').clearAll();
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
});
|
|
@ -33,6 +33,9 @@ export default Component.extend(ModalMixin, Notifier, {
|
||||||
isLDAPProvider: computed('authProvider', function() {
|
isLDAPProvider: computed('authProvider', function() {
|
||||||
return this.get('authProvider') === this.get('constants').AuthProvider.LDAP;
|
return this.get('authProvider') === this.get('constants').AuthProvider.LDAP;
|
||||||
}),
|
}),
|
||||||
|
isCASProvider: computed('authProvider', function(){
|
||||||
|
return this.get('authProvider') === this.get('constants').AuthProvider.CAS;
|
||||||
|
}),
|
||||||
|
|
||||||
KeycloakUrlError: empty('keycloakConfig.url'),
|
KeycloakUrlError: empty('keycloakConfig.url'),
|
||||||
KeycloakRealmError: empty('keycloakConfig.realm'),
|
KeycloakRealmError: empty('keycloakConfig.realm'),
|
||||||
|
@ -61,6 +64,10 @@ export default Component.extend(ModalMixin, Notifier, {
|
||||||
ldapPreview: null,
|
ldapPreview: null,
|
||||||
ldapConfig: null,
|
ldapConfig: null,
|
||||||
|
|
||||||
|
casErrorUrl: empty('casConfig.url'),
|
||||||
|
casErrorRedirectUrl: empty('casConfig.redirectUrl'),
|
||||||
|
casConfig:null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
@ -122,6 +129,19 @@ export default Component.extend(ModalMixin, Notifier, {
|
||||||
this.set('ldapConfig', ldapConfig);
|
this.set('ldapConfig', ldapConfig);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case constants.AuthProvider.CAS: {
|
||||||
|
let casConfig = this.get('authConfig');
|
||||||
|
if (_.isUndefined(casConfig) || _.isNull(casConfig) || _.isEmpty(casConfig) ) {
|
||||||
|
casConfig = {};
|
||||||
|
} else {
|
||||||
|
casConfig = JSON.parse(casConfig);
|
||||||
|
casConfig.url = casConfig.hasOwnProperty('url') ? casConfig.url : '';
|
||||||
|
casConfig.redirectUrl = casConfig.hasOwnProperty('redirectUrl') ? casConfig.redirectUrl : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.set('casConfig', casConfig);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -140,6 +160,10 @@ export default Component.extend(ModalMixin, Notifier, {
|
||||||
let constants = this.get('constants');
|
let constants = this.get('constants');
|
||||||
this.set('authProvider', constants.AuthProvider.LDAP);
|
this.set('authProvider', constants.AuthProvider.LDAP);
|
||||||
},
|
},
|
||||||
|
onCAS() {
|
||||||
|
let constants = this.get('constants');
|
||||||
|
this.set('authProvider', constants.AuthProvider.CAS);
|
||||||
|
},
|
||||||
|
|
||||||
onLDAPEncryption(e) {
|
onLDAPEncryption(e) {
|
||||||
this.set('ldapConfig.encryptionType', e);
|
this.set('ldapConfig.encryptionType', e);
|
||||||
|
@ -231,6 +255,21 @@ export default Component.extend(ModalMixin, Notifier, {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case constants.AuthProvider.CAS:
|
||||||
|
if (this.get('casErrorUrl')) {
|
||||||
|
$("#cas-url").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.get('casErrorRedirectUrl')) {
|
||||||
|
$("#cas-redirect-url").focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
config = copy(this.get('casConfig'));
|
||||||
|
config.url = config.url.trim();
|
||||||
|
config.redirectUrl = config.redirectUrl.trim();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ let constants = EmberObject.extend({
|
||||||
Documize: 'documize',
|
Documize: 'documize',
|
||||||
Keycloak: 'keycloak',
|
Keycloak: 'keycloak',
|
||||||
LDAP: 'ldap',
|
LDAP: 'ldap',
|
||||||
|
CAS: 'cas',
|
||||||
ServerTypeLDAP: 'ldap',
|
ServerTypeLDAP: 'ldap',
|
||||||
ServerTypeAD: 'ad',
|
ServerTypeAD: 'ad',
|
||||||
EncryptionTypeNone: 'none',
|
EncryptionTypeNone: 'none',
|
||||||
|
|
|
@ -17,6 +17,7 @@ export default Mixin.create({
|
||||||
isAuthProviderDocumize: true,
|
isAuthProviderDocumize: true,
|
||||||
isAuthProviderKeycloak: false,
|
isAuthProviderKeycloak: false,
|
||||||
isAuthProviderLDAP: false,
|
isAuthProviderLDAP: false,
|
||||||
|
isAuthProviderCAS: false,
|
||||||
isDualAuth: false,
|
isDualAuth: false,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
@ -26,7 +27,7 @@ export default Mixin.create({
|
||||||
this.set('isAuthProviderDocumize', this.get('appMeta.authProvider') === constants.AuthProvider.Documize);
|
this.set('isAuthProviderDocumize', this.get('appMeta.authProvider') === constants.AuthProvider.Documize);
|
||||||
this.set('isAuthProviderKeycloak', this.get('appMeta.authProvider') === constants.AuthProvider.Keycloak);
|
this.set('isAuthProviderKeycloak', this.get('appMeta.authProvider') === constants.AuthProvider.Keycloak);
|
||||||
this.set('isAuthProviderLDAP', this.get('appMeta.authProvider') === constants.AuthProvider.LDAP);
|
this.set('isAuthProviderLDAP', this.get('appMeta.authProvider') === constants.AuthProvider.LDAP);
|
||||||
|
this.set('isAuthProviderCAS', this.get('appMeta.authProvider') == constants.AuthProvider.CAS);
|
||||||
if (this.get('appMeta.authProvider') === constants.AuthProvider.LDAP) {
|
if (this.get('appMeta.authProvider') === constants.AuthProvider.LDAP) {
|
||||||
let config = this.get('appMeta.authConfig');
|
let config = this.get('appMeta.authConfig');
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import AuthProvider from '../../../mixins/auth';
|
import AuthProvider from '../../../mixins/auth';
|
||||||
import Controller from '@ember/controller';
|
import Controller from '@ember/controller';
|
||||||
|
import {Promise as EmberPromise} from "rsvp";
|
||||||
|
|
||||||
export default Controller.extend(AuthProvider, {
|
export default Controller.extend(AuthProvider, {
|
||||||
appMeta: service('app-meta'),
|
appMeta: service('app-meta'),
|
||||||
session: service('session'),
|
session: service('session'),
|
||||||
|
|
||||||
invalidCredentials: false,
|
invalidCredentials: false,
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
@ -26,7 +28,7 @@ export default Controller.extend(AuthProvider, {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('isAuthProviderLDAP')) {
|
if (this.get('isAuthProviderLDAP') || this.get('isAuthProviderCAS')) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
username: '',
|
username: '',
|
||||||
password: ''
|
password: ''
|
||||||
|
@ -62,6 +64,24 @@ export default Controller.extend(AuthProvider, {
|
||||||
this.set('invalidCredentials', true);
|
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);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Route from '@ember/routing/route';
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
appMeta: service(),
|
appMeta: service(),
|
||||||
kcAuth: service(),
|
kcAuth: service(),
|
||||||
|
global: service(),
|
||||||
localStorage: service(),
|
localStorage: service(),
|
||||||
showLogin: false,
|
showLogin: false,
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,12 @@
|
||||||
{{input type="password" value=password id="authPassword" class="form-control" autocomplete="current-password"}}
|
{{input type="password" value=password id="authPassword" class="form-control" autocomplete="current-password"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</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")}}
|
{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.SignIn onClick=(action "login")}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
|
||||||
<div class="{{unless invalidCredentials "invisible"}} color-red-600 mt-3">Invalid credentials</div>
|
<div class="{{unless invalidCredentials "invisible"}} color-red-600 mt-3">Invalid credentials</div>
|
||||||
{{#if isAuthProviderDocumize}}
|
{{#if isAuthProviderDocumize}}
|
||||||
|
|
|
@ -42,6 +42,8 @@ export default Route.extend(AuthenticatedRouteMixin, {
|
||||||
case constants.AuthProvider.LDAP:
|
case constants.AuthProvider.LDAP:
|
||||||
data.authConfig = config;
|
data.authConfig = config;
|
||||||
break;
|
break;
|
||||||
|
case constants.AuthProvider.CAS:
|
||||||
|
data.authConfig = config;
|
||||||
case constants.AuthProvider.Documize:
|
case constants.AuthProvider.Documize:
|
||||||
data.authConfig = '';
|
data.authConfig = '';
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{layout/logo-heading
|
{{layout/logo-heading
|
||||||
title="Authentication"
|
title="Authentication"
|
||||||
desc="Choose user authentication provider — Documize, Redhat Keycloak, LDAP/AD"
|
desc="Choose user authentication provider — Documize, Redhat Keycloak, LDAP/AD, CAS"
|
||||||
icon=constants.Icon.Locked}}
|
icon=constants.Icon.Locked}}
|
||||||
|
|
||||||
{{customize/auth-settings
|
{{customize/auth-settings
|
||||||
|
|
|
@ -23,6 +23,13 @@
|
||||||
<i class="dicon {{constants.Icon.Tick}}" />
|
<i class="dicon {{constants.Icon.Tick}}" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
|
<li class="option {{if isCASProvider "selected"}}" {{action "onCAS"}}>
|
||||||
|
<div class="text-header">CAS</div>
|
||||||
|
<div class="text">Via authentication server</div>
|
||||||
|
{{#if isCASProvider}}
|
||||||
|
<i class="dicon {{constants.Icon.Tick}}" />
|
||||||
|
{{/if}}
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -167,7 +174,18 @@
|
||||||
{{ui/ui-button color=constants.Color.Yellow light=true label="Test →" onClick=(action "onLDAPPreview")}}
|
{{ui/ui-button color=constants.Color.Yellow light=true label="Test →" onClick=(action "onLDAPPreview")}}
|
||||||
{{ui/ui-button-gap}}
|
{{ui/ui-button-gap}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if isCASProvider}}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="cas-url">CAS Server URL</label>
|
||||||
|
{{focus-input id="cas-url" type="text" value=casConfig.url class=(if casErrorUrl "form-control is-invalid" "form-control")}}
|
||||||
|
<small class="form-text text-muted">e.g. http://localhost:8888/auth</small>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="cas-redirect-url">Redirect URL</label>
|
||||||
|
{{focus-input id="cas-redirect-url" type="text" value=casConfig.redirectUrl class=(if casErrorRedirectUrl "form-control is-invalid" "form-control")}}
|
||||||
|
<small class="form-text text-muted">e.g. http://localhost:8888/</small>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
{{ui/ui-button color=constants.Color.Green light=true icon=constants.Icon.Locked label=constants.Label.Activate onClick=(action "onSave")}}
|
{{ui/ui-button color=constants.Color.Green light=true icon=constants.Icon.Locked label=constants.Label.Activate onClick=(action "onSave")}}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue