mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
authConfig persistence bug, session vars bug
This commit is contained in:
parent
585c4468c1
commit
6f98db5c29
8 changed files with 693 additions and 660 deletions
|
@ -30,16 +30,20 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||||
authConfig: null,
|
authConfig: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (data.authProvider) {
|
return new Ember.RSVP.Promise((resolve) => {
|
||||||
case constants.AuthProvider.Keycloak:
|
this.get('global').getAuthConfig().then((config) => {
|
||||||
data.authConfig = this.get('appMeta.authConfig');
|
switch (data.authProvider) {
|
||||||
break;
|
case constants.AuthProvider.Keycloak:
|
||||||
case constants.AuthProvider.Documize:
|
data.authConfig = config;
|
||||||
data.authConfig = '';
|
break;
|
||||||
break;
|
case constants.AuthProvider.Documize:
|
||||||
}
|
data.authConfig = '';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return data;
|
resolve(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
|
|
|
@ -65,6 +65,17 @@ export default Ember.Service.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Returns auth config for Documize instance.
|
||||||
|
getAuthConfig() {
|
||||||
|
if(this.get('sessionService.isGlobalAdmin')) {
|
||||||
|
return this.get('ajax').request(`global/auth`, {
|
||||||
|
method: 'GET'
|
||||||
|
}).then((response) => {
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// Saves auth config for Documize instance.
|
// Saves auth config for Documize instance.
|
||||||
saveAuthConfig(config) {
|
saveAuthConfig(config) {
|
||||||
if(this.get('sessionService.isGlobalAdmin')) {
|
if(this.get('sessionService.isGlobalAdmin')) {
|
||||||
|
|
|
@ -26,20 +26,25 @@ export default SimpleAuthSession.extend({
|
||||||
currentFolder: null,
|
currentFolder: null,
|
||||||
isMac: false,
|
isMac: false,
|
||||||
isMobile: false,
|
isMobile: false,
|
||||||
authenticated: computed('user.id', function () {
|
|
||||||
return this.get('user.id') !== '0';
|
user: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
||||||
|
if (this.get('isAuthenticated')) {
|
||||||
|
let user = this.get('session.content.authenticated.user') || { id: '' };
|
||||||
|
let data = this.get('store').normalize('user', user);
|
||||||
|
return this.get('store').push(data);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
isAdmin: computed('user', function () {
|
authenticated: computed('session.content.authenticated.user', function () {
|
||||||
let data = this.get('user');
|
return this.get('session.content.authenticated.user.id') !== '0';
|
||||||
return data.get('admin');
|
|
||||||
}),
|
}),
|
||||||
isEditor: computed('user', function () {
|
isAdmin: computed('session.content.authenticated.user', function () {
|
||||||
let data = this.get('user');
|
return this.get('session.content.authenticated.user.admin') === true;
|
||||||
return data.get('editor');
|
|
||||||
}),
|
}),
|
||||||
isGlobalAdmin: computed('user', function () {
|
isEditor: computed('session.content.authenticated.user', function () {
|
||||||
let data = this.get('user');
|
return this.get('session.content.authenticated.user.editor') === true;
|
||||||
return data.get('global');
|
}),
|
||||||
|
isGlobalAdmin: computed('session.content.authenticated.user', function () {
|
||||||
|
return this.get('session.content.authenticated.user.global') === true;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
@ -49,14 +54,6 @@ export default SimpleAuthSession.extend({
|
||||||
this.set('isMobile', is.mobile());
|
this.set('isMobile', is.mobile());
|
||||||
},
|
},
|
||||||
|
|
||||||
user: computed('isAuthenticated', 'session.content.authenticated.user', function () {
|
|
||||||
if (this.get('isAuthenticated')) {
|
|
||||||
let user = this.get('session.content.authenticated.user') || { id: '' };
|
|
||||||
let data = this.get('store').normalize('user', user);
|
|
||||||
return this.get('store').push(data);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
this.get('localStorage').clearAll();
|
this.get('localStorage').clearAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
"ember-export-application-global": "^1.0.5",
|
"ember-export-application-global": "^1.0.5",
|
||||||
"ember-load-initializers": "^0.6.0",
|
"ember-load-initializers": "^0.6.0",
|
||||||
"ember-resolver": "^2.0.3",
|
"ember-resolver": "^2.0.3",
|
||||||
"ember-simple-auth": "1.2.0",
|
"ember-simple-auth": "1.2.2",
|
||||||
"ember-source": "~2.12.0",
|
"ember-source": "~2.12.0",
|
||||||
"loader.js": "^4.2.3"
|
"loader.js": "^4.2.3"
|
||||||
},
|
},
|
||||||
|
|
|
@ -233,3 +233,21 @@ type authData struct {
|
||||||
AuthProvider string `json:"authProvider"`
|
AuthProvider string `json:"authProvider"`
|
||||||
AuthConfig string `json:"authConfig"`
|
AuthConfig string `json:"authConfig"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetAuthConfig returns installation-wide auth configuration
|
||||||
|
func GetAuthConfig(w http.ResponseWriter, r *http.Request) {
|
||||||
|
p := request.GetPersister(r)
|
||||||
|
|
||||||
|
if !p.Context.Global {
|
||||||
|
writeForbiddenError(w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
org, err := p.GetOrganization(p.Context.OrgID)
|
||||||
|
if err != nil {
|
||||||
|
writeForbiddenError(w)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
util.WriteJSON(w, org.AuthConfig)
|
||||||
|
}
|
||||||
|
|
|
@ -236,6 +236,7 @@ func init() {
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "global/smtp", []string{"PUT", "OPTIONS"}, nil, SaveSMTPConfig))
|
log.IfErr(Add(RoutePrefixPrivate, "global/smtp", []string{"PUT", "OPTIONS"}, nil, SaveSMTPConfig))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "global/license", []string{"GET", "OPTIONS"}, nil, GetLicense))
|
log.IfErr(Add(RoutePrefixPrivate, "global/license", []string{"GET", "OPTIONS"}, nil, GetLicense))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "global/license", []string{"PUT", "OPTIONS"}, nil, SaveLicense))
|
log.IfErr(Add(RoutePrefixPrivate, "global/license", []string{"PUT", "OPTIONS"}, nil, SaveLicense))
|
||||||
|
log.IfErr(Add(RoutePrefixPrivate, "global/auth", []string{"GET", "OPTIONS"}, nil, GetAuthConfig))
|
||||||
log.IfErr(Add(RoutePrefixPrivate, "global/auth", []string{"PUT", "OPTIONS"}, nil, SaveAuthConfig))
|
log.IfErr(Add(RoutePrefixPrivate, "global/auth", []string{"PUT", "OPTIONS"}, nil, SaveAuthConfig))
|
||||||
|
|
||||||
// Pinned items
|
// Pinned items
|
||||||
|
|
|
@ -165,6 +165,9 @@ func cors(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
w.Header().Set("Access-Control-Expose-Headers", "x-documize-version")
|
w.Header().Set("Access-Control-Expose-Headers", "x-documize-version")
|
||||||
|
|
||||||
if r.Method == "OPTIONS" {
|
if r.Method == "OPTIONS" {
|
||||||
|
w.Header().Add("X-Documize-Version", Product.Version)
|
||||||
|
w.Header().Add("Cache-Control", "no-cache")
|
||||||
|
|
||||||
if _, err := w.Write([]byte("")); err != nil {
|
if _, err := w.Write([]byte("")); err != nil {
|
||||||
log.Error("cors", err)
|
log.Error("cors", err)
|
||||||
}
|
}
|
||||||
|
@ -177,7 +180,6 @@ func cors(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
func metrics(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
func metrics(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
|
||||||
w.Header().Add("X-Documize-Version", Product.Version)
|
w.Header().Add("X-Documize-Version", Product.Version)
|
||||||
w.Header().Add("Cache-Control", "no-cache")
|
w.Header().Add("Cache-Control", "no-cache")
|
||||||
|
|
||||||
// Prevent page from being displayed in an iframe
|
// Prevent page from being displayed in an iframe
|
||||||
w.Header().Add("X-Frame-Options", "DENY")
|
w.Header().Add("X-Frame-Options", "DENY")
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue