mirror of
https://github.com/documize/community.git
synced 2025-08-02 20:15:26 +02:00
wip
This commit is contained in:
parent
0b51608383
commit
9d1af37f6e
22 changed files with 2215 additions and 647 deletions
70
app/app/components/auth-settings.js
Normal file
70
app/app/components/auth-settings.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
// 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 Ember from 'ember';
|
||||
import constants from '../utils/constants';
|
||||
|
||||
const {
|
||||
computed
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend({
|
||||
isDocumizeProvider: computed.equal('authProvider', constants.AuthProvider.Documize),
|
||||
isKeycloakProvider: computed.equal('authProvider', constants.AuthProvider.Keycloak),
|
||||
KeycloakConfigError: computed.empty('keycloakConfig'),
|
||||
keycloakConfig: '',
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
let provider = this.get('authProvider');
|
||||
|
||||
switch (provider) {
|
||||
case constants.AuthProvider.Documize:
|
||||
break;
|
||||
case constants.AuthProvider.Keycloak:
|
||||
this.set('keycloakConfig', this.get('authConfig'));
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
onDocumize() {
|
||||
this.set('authProvider', constants.AuthProvider.Documize);
|
||||
},
|
||||
|
||||
onKeycloak() {
|
||||
this.set('authProvider', constants.AuthProvider.Keycloak);
|
||||
},
|
||||
|
||||
onSave() {
|
||||
if (this.get('KeycloakConfigError')) {
|
||||
this.$("#keycloak-id").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
let provider = this.get('authProvider');
|
||||
let config = this.get('authConfig');
|
||||
|
||||
switch (provider) {
|
||||
case constants.AuthProvider.Documize:
|
||||
config = {};
|
||||
break;
|
||||
case constants.AuthProvider.Keycloak:
|
||||
config = this.get('keycloakConfig');
|
||||
break;
|
||||
}
|
||||
|
||||
this.get('onSave')(provider, config).then(() => {
|
||||
});
|
||||
},
|
||||
}
|
||||
});
|
32
app/app/pods/customize/auth/controller.js
Normal file
32
app/app/pods/customize/auth/controller.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
// 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 Ember from 'ember';
|
||||
import NotifierMixin from "../../../mixins/notifier";
|
||||
|
||||
export default Ember.Controller.extend(NotifierMixin, {
|
||||
global: Ember.inject.service(),
|
||||
|
||||
actions: {
|
||||
onSave(provider, config) {
|
||||
if(this.get('session.isGlobalAdmin')) {
|
||||
let data = { authProvider: provider, authConfig: config };
|
||||
|
||||
return this.get('global').saveAuthConfig(data).then(() => {
|
||||
this.showNotification('Saved');
|
||||
if (this.get('authProvider') !== provider) {
|
||||
// window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
48
app/app/pods/customize/auth/route.js
Normal file
48
app/app/pods/customize/auth/route.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
// 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 Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
||||
import constants from '../../../utils/constants';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
appMeta: Ember.inject.service(),
|
||||
session: Ember.inject.service(),
|
||||
global: Ember.inject.service(),
|
||||
|
||||
beforeModel() {
|
||||
if (!this.get("session.isGlobalAdmin")) {
|
||||
this.transitionTo('auth.login');
|
||||
}
|
||||
},
|
||||
|
||||
model() {
|
||||
let data = {
|
||||
authProvider: this.get('appMeta.authProvider'),
|
||||
authConfig: null,
|
||||
};
|
||||
|
||||
switch (data.authProvider) {
|
||||
case constants.AuthProvider.Keycloak:
|
||||
data.authConfig = this.get('appMeta.authConfig');
|
||||
break;
|
||||
case constants.AuthProvider.Documize:
|
||||
data.authConfig = '';
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
activate() {
|
||||
document.title = "Authentication | Documize";
|
||||
}
|
||||
});
|
1
app/app/pods/customize/auth/template.hbs
Normal file
1
app/app/pods/customize/auth/template.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
{{auth-settings authProvider=model.authProvider authConfig=model.authConfig onSave=(action 'onSave')}}
|
|
@ -9,6 +9,7 @@
|
|||
{{#link-to 'customize.users' activeClass='selected' class="option" tagName="li"}}Users{{/link-to}}
|
||||
{{#if session.isGlobalAdmin}}
|
||||
{{#link-to 'customize.global' activeClass='selected' class="option" tagName="li"}}Global{{/link-to}}
|
||||
{{#link-to 'customize.auth' activeClass='selected' class="option" tagName="li"}}Authentication{{/link-to}}
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -58,6 +58,9 @@ export default Router.map(function () {
|
|||
this.route('global', {
|
||||
path: 'global'
|
||||
});
|
||||
this.route('auth', {
|
||||
path: 'auth'
|
||||
});
|
||||
});
|
||||
|
||||
this.route('setup', {
|
||||
|
|
|
@ -30,6 +30,8 @@ export default Ember.Service.extend({
|
|||
edition: 'Community',
|
||||
valid: true,
|
||||
allowAnonymousAccess: false,
|
||||
authProvider: 'documize',
|
||||
authConfig: null,
|
||||
setupMode: false,
|
||||
|
||||
invalidLicense() {
|
||||
|
|
|
@ -63,5 +63,15 @@ export default Ember.Service.extend({
|
|||
data: license
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Saves auth config for Documize instance.
|
||||
saveAuthConfig(config) {
|
||||
if(this.get('sessionService.isGlobalAdmin')) {
|
||||
return this.get('ajax').request(`global/auth`, {
|
||||
method: 'PUT',
|
||||
data: JSON.stringify(config)
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
22
app/app/templates/components/auth-settings.hbs
Normal file
22
app/app/templates/components/auth-settings.hbs
Normal file
|
@ -0,0 +1,22 @@
|
|||
<form class="form-bordered">
|
||||
<div class="form-header">
|
||||
<div class="title">Authentication</div>
|
||||
<div class="tip">Determine the method for user authentication</div>
|
||||
</div>
|
||||
<div class="input-control">
|
||||
<label>Provider</label>
|
||||
<div class="tip">External authentication servers, services must be accessible from the server running this Documize instance</div>
|
||||
{{#ui/ui-radio selected=isDocumizeProvider onClick=(action 'onDocumize')}}Documize — email/password{{/ui/ui-radio}}
|
||||
{{#ui/ui-radio selected=isKeycloakProvider onClick=(action 'onKeycloak')}}Keycloak — bring your own authenticaiton server{{/ui/ui-radio}}
|
||||
</div>
|
||||
|
||||
{{#if isKeycloakProvider}}
|
||||
<div class="input-control">
|
||||
<label>Keycloak OIDC JSON</label>
|
||||
<div class="tip">Realm Client JSON configuration from Keycloak admin console</div>
|
||||
{{textarea id="keycloak-config" type="text" rows=7 value=keycloakConfig class=(if KeycloakUrlError 'error')}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="regular-button button-blue" {{action 'onSave'}}>save</div>
|
||||
</form>
|
|
@ -15,4 +15,9 @@ export default {
|
|||
Private: 2,
|
||||
Protected: 3
|
||||
},
|
||||
|
||||
AuthProvider: {
|
||||
Documize: 'documize',
|
||||
Keycloak: 'keycloak'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -60,6 +60,7 @@ module.exports = function (defaults) {
|
|||
app.import('vendor/waypoints.js');
|
||||
app.import('vendor/velocity.js');
|
||||
app.import('vendor/velocity.ui.js');
|
||||
app.import('vendor/keycloak.js');
|
||||
|
||||
return app.toTree();
|
||||
};
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"author": "",
|
||||
"author": "Documize Inc.",
|
||||
"license": "AGPL",
|
||||
"devDependencies": {
|
||||
"broccoli-asset-rev": "^2.4.5",
|
||||
|
@ -41,7 +41,7 @@
|
|||
"ember-export-application-global": "^1.0.5",
|
||||
"ember-load-initializers": "^0.6.0",
|
||||
"ember-resolver": "^2.0.3",
|
||||
"ember-simple-auth": "git+https://github.com/documize/ember-simple-auth.git#21e638f9e33267d8944835002ee96884d34d568a",
|
||||
"ember-simple-auth": "1.2.0",
|
||||
"ember-source": "~2.11.0",
|
||||
"loader.js": "^4.0.10"
|
||||
},
|
||||
|
|
1257
app/vendor/keycloak.js
vendored
Normal file
1257
app/vendor/keycloak.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue