Commit fa2164a9 authored by Jörg Richter's avatar Jörg Richter

Add "Authorization Method" menu to login dialog (#168)

parent b98ff580
Pipeline #6536 passed with stages
in 4 minutes and 7 seconds
......@@ -433,6 +433,13 @@ public class AccessControlPlugin extends PluginActivator implements AccessContro
// === Authorization Methods ===
@GET
@Path("/methods")
@Override
public Set<String> getAuthorizationMethods() {
return authorizationMethods.keySet();
}
@Override
public void registerAuthorizationMethod(String name, AuthorizationMethod am) {
if (authorizationMethods.containsKey(name)) {
......@@ -446,13 +453,6 @@ public class AccessControlPlugin extends PluginActivator implements AccessContro
authorizationMethods.remove(name);
}
@GET
@Path("/methods")
@Override
public Set<String> getAuthorizationMethods() {
return authorizationMethods.keySet();
}
// *************
......
......@@ -207,9 +207,9 @@ public interface AccessControlService {
// === Authorization Methods ===
Set<String> getAuthorizationMethods();
void registerAuthorizationMethod(String name, AuthorizationMethod am);
void unregisterAuthorizationMethod(String name);
Set<String> getAuthorizationMethods();
}
......@@ -4,10 +4,9 @@ import SHA256 from './lib/sha256'
const ENCODED_PASSWORD_PREFIX = '-SHA256-'
const state = {
username: undefined, // the logged in user (string); falsish if no user is logged in
visible: false // Login dialog visibility
username: undefined, // the logged in user (string); falsish if no user is logged in
authMethods: ['Basic'], // names of installed auth methods (array of string), may be empty
visible: false // Login dialog visibility
}
const actions = {
......@@ -55,6 +54,10 @@ const actions = {
dm5.restClient.getUsername().then(username => {
state.username = username
})
dm5.restClient.getAuthorizationMethods().then(authMethods => {
console.log('[DMX] Installed auth methods', authMethods)
state.authMethods = state.authMethods.concat(authMethods)
})
// helper
......
<template>
<el-dialog custom-class="dm5-login-dialog" :visible="visible" width="20em" title="Login" @open="open" @close="close">
<div>
<div class="field">
<div class="field-label">Authorization Method</div>
<el-select v-model="authMethod">
<el-option v-for="authMethod in authMethods" :value="authMethod" :key="authMethod"></el-option>
</el-select>
</div>
<div class="field">
<div class="field-label">Username</div>
<el-input v-model="credentials.username" ref="username" @keyup.native.enter="advance"></el-input>
</div>
<div class="password-field">
<div class="field">
<div class="field-label">Password</div>
<el-input v-model="credentials.password" ref="password" @keyup.native.enter="login" type="password"></el-input>
</div>
<div class="message">{{message}}</div>
<div class="field">
{{message}}
</div>
<div slot="footer">
<el-button type="primary" @click="login">OK</el-button>
</div>
......@@ -18,8 +26,18 @@
<script>
export default {
created () {
// console.log('dm5-login-dialog created', this.authMethods)
this.authMethod = this.authMethods[0]
},
mounted () {
// console.log('dm5-login-dialog mounted')
},
data () {
return {
authMethod: undefined,
credentials: {
username: '',
password: ''
......@@ -29,6 +47,11 @@ export default {
},
computed: {
authMethods () {
return this.$store.state.accesscontrol.authMethods
},
visible () {
return this.$store.state.accesscontrol.visible
}
......@@ -67,11 +90,7 @@ export default {
</script>
<style>
.dm5-login-dialog .password-field {
margin-top: 1em;
}
.dm5-login-dialog .message {
margin-top: 1em;
.dm5-login-dialog .field + .field {
margin-top: var(--field-spacing);
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment