From b2e610ad68b78cf5e2253d9d3f658ed015da27ac Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Sat, 25 Jan 2025 15:54:47 +0100
Subject: [PATCH] Fixed the signup

Signed-off-by: Martin Weise <martin.weise@tuwien.ac.at>
---
 dbrepo-auth-service/dbrepo-realm.json |  36 +++---
 dbrepo-ui/layouts/default.vue         |  10 +-
 dbrepo-ui/nuxt.config.ts              |  26 ++--
 dbrepo-ui/pages/signup.vue            | 167 --------------------------
 4 files changed, 36 insertions(+), 203 deletions(-)
 delete mode 100644 dbrepo-ui/pages/signup.vue

diff --git a/dbrepo-auth-service/dbrepo-realm.json b/dbrepo-auth-service/dbrepo-realm.json
index b48be9a6bd..cf3fcadb2f 100644
--- a/dbrepo-auth-service/dbrepo-realm.json
+++ b/dbrepo-auth-service/dbrepo-realm.json
@@ -27,7 +27,7 @@
   "oauth2DevicePollingInterval" : 5,
   "enabled" : true,
   "sslRequired" : "none",
-  "registrationAllowed" : false,
+  "registrationAllowed" : true,
   "registrationEmailAsUsername" : false,
   "rememberMe" : false,
   "verifyEmail" : true,
@@ -2132,11 +2132,15 @@
       "protocolMapper" : "oidc-usermodel-realm-role-mapper",
       "consentRequired" : false,
       "config" : {
+        "introspection.token.claim" : "true",
+        "userinfo.token.claim" : "false",
+        "multivalued" : "true",
         "user.attribute" : "foo",
+        "id.token.claim" : "true",
+        "lightweight.claim" : "false",
         "access.token.claim" : "true",
         "claim.name" : "realm_access.roles",
-        "jsonType.label" : "String",
-        "multivalued" : "true"
+        "jsonType.label" : "String"
       }
     }, {
       "id" : "a7bd6723-e58e-47f7-95c0-2925ce99283d",
@@ -2166,6 +2170,10 @@
     "strictTransportSecurity" : "max-age=31536000; includeSubDomains"
   },
   "smtpServer" : { },
+  "loginTheme" : "keycloak",
+  "accountTheme" : "",
+  "adminTheme" : "",
+  "emailTheme" : "",
   "eventsEnabled" : false,
   "eventsListeners" : [ "jboss-logging" ],
   "enabledEventTypes" : [ "SEND_RESET_PASSWORD", "UPDATE_CONSENT_ERROR", "GRANT_CONSENT", "VERIFY_PROFILE_ERROR", "REMOVE_TOTP", "REVOKE_GRANT", "UPDATE_TOTP", "LOGIN_ERROR", "CLIENT_LOGIN", "RESET_PASSWORD_ERROR", "IMPERSONATE_ERROR", "CODE_TO_TOKEN_ERROR", "CUSTOM_REQUIRED_ACTION", "OAUTH2_DEVICE_CODE_TO_TOKEN_ERROR", "RESTART_AUTHENTICATION", "IMPERSONATE", "UPDATE_PROFILE_ERROR", "LOGIN", "OAUTH2_DEVICE_VERIFY_USER_CODE", "UPDATE_PASSWORD_ERROR", "CLIENT_INITIATED_ACCOUNT_LINKING", "TOKEN_EXCHANGE", "AUTHREQID_TO_TOKEN", "LOGOUT", "REGISTER", "DELETE_ACCOUNT_ERROR", "CLIENT_REGISTER", "IDENTITY_PROVIDER_LINK_ACCOUNT", "DELETE_ACCOUNT", "UPDATE_PASSWORD", "CLIENT_DELETE", "FEDERATED_IDENTITY_LINK_ERROR", "IDENTITY_PROVIDER_FIRST_LOGIN", "CLIENT_DELETE_ERROR", "VERIFY_EMAIL", "CLIENT_LOGIN_ERROR", "RESTART_AUTHENTICATION_ERROR", "EXECUTE_ACTIONS", "REMOVE_FEDERATED_IDENTITY_ERROR", "TOKEN_EXCHANGE_ERROR", "PERMISSION_TOKEN", "SEND_IDENTITY_PROVIDER_LINK_ERROR", "EXECUTE_ACTION_TOKEN_ERROR", "SEND_VERIFY_EMAIL", "OAUTH2_DEVICE_AUTH", "EXECUTE_ACTIONS_ERROR", "REMOVE_FEDERATED_IDENTITY", "OAUTH2_DEVICE_CODE_TO_TOKEN", "IDENTITY_PROVIDER_POST_LOGIN", "IDENTITY_PROVIDER_LINK_ACCOUNT_ERROR", "OAUTH2_DEVICE_VERIFY_USER_CODE_ERROR", "UPDATE_EMAIL", "REGISTER_ERROR", "REVOKE_GRANT_ERROR", "EXECUTE_ACTION_TOKEN", "LOGOUT_ERROR", "UPDATE_EMAIL_ERROR", "CLIENT_UPDATE_ERROR", "AUTHREQID_TO_TOKEN_ERROR", "UPDATE_PROFILE", "CLIENT_REGISTER_ERROR", "FEDERATED_IDENTITY_LINK", "SEND_IDENTITY_PROVIDER_LINK", "SEND_VERIFY_EMAIL_ERROR", "RESET_PASSWORD", "CLIENT_INITIATED_ACCOUNT_LINKING_ERROR", "OAUTH2_DEVICE_AUTH_ERROR", "UPDATE_CONSENT", "REMOVE_TOTP_ERROR", "VERIFY_EMAIL_ERROR", "SEND_RESET_PASSWORD_ERROR", "CLIENT_UPDATE", "CUSTOM_REQUIRED_ACTION_ERROR", "IDENTITY_PROVIDER_POST_LOGIN_ERROR", "UPDATE_TOTP_ERROR", "CODE_TO_TOKEN", "VERIFY_PROFILE", "GRANT_CONSENT_ERROR", "IDENTITY_PROVIDER_FIRST_LOGIN_ERROR" ],
@@ -2215,7 +2223,7 @@
       "subType" : "anonymous",
       "subComponents" : { },
       "config" : {
-        "allowed-protocol-mapper-types" : [ "oidc-address-mapper", "oidc-usermodel-attribute-mapper", "saml-user-property-mapper", "oidc-sha256-pairwise-sub-mapper", "oidc-usermodel-property-mapper", "saml-user-attribute-mapper", "oidc-full-name-mapper", "saml-role-list-mapper" ]
+        "allowed-protocol-mapper-types" : [ "oidc-address-mapper", "saml-user-attribute-mapper", "oidc-full-name-mapper", "oidc-usermodel-attribute-mapper", "oidc-sha256-pairwise-sub-mapper", "oidc-usermodel-property-mapper", "saml-user-property-mapper", "saml-role-list-mapper" ]
       }
     }, {
       "id" : "1849e52a-b8c9-44a8-af3d-ee19376a1ed1",
@@ -2241,7 +2249,7 @@
       "subType" : "authenticated",
       "subComponents" : { },
       "config" : {
-        "allowed-protocol-mapper-types" : [ "oidc-full-name-mapper", "oidc-address-mapper", "saml-user-property-mapper", "saml-user-attribute-mapper", "saml-role-list-mapper", "oidc-usermodel-property-mapper", "oidc-usermodel-attribute-mapper", "oidc-sha256-pairwise-sub-mapper" ]
+        "allowed-protocol-mapper-types" : [ "oidc-address-mapper", "saml-role-list-mapper", "oidc-full-name-mapper", "oidc-usermodel-attribute-mapper", "oidc-sha256-pairwise-sub-mapper", "saml-user-attribute-mapper", "saml-user-property-mapper", "oidc-usermodel-property-mapper" ]
       }
     } ],
     "org.keycloak.storage.UserStorageProvider" : [ {
@@ -2257,8 +2265,8 @@
           "config" : {
             "ldap.attribute" : [ "createTimestamp" ],
             "is.mandatory.in.ldap" : [ "false" ],
-            "read.only" : [ "true" ],
             "always.read.value.from.ldap" : [ "true" ],
+            "read.only" : [ "true" ],
             "user.model.attribute" : [ "createTimestamp" ]
           }
         }, {
@@ -2269,8 +2277,8 @@
           "config" : {
             "ldap.attribute" : [ "sn" ],
             "is.mandatory.in.ldap" : [ "true" ],
-            "always.read.value.from.ldap" : [ "true" ],
             "read.only" : [ "false" ],
+            "always.read.value.from.ldap" : [ "true" ],
             "user.model.attribute" : [ "lastName" ]
           }
         }, {
@@ -2305,13 +2313,13 @@
           "config" : {
             "membership.attribute.type" : [ "DN" ],
             "group.name.ldap.attribute" : [ "cn" ],
-            "preserve.group.inheritance" : [ "false" ],
             "membership.user.ldap.attribute" : [ "uid" ],
+            "preserve.group.inheritance" : [ "false" ],
             "groups.dn" : [ "ou=users,dc=dbrepo,dc=at" ],
             "mode" : [ "LDAP_ONLY" ],
             "user.roles.retrieve.strategy" : [ "LOAD_GROUPS_BY_MEMBER_ATTRIBUTE" ],
-            "membership.ldap.attribute" : [ "member" ],
             "ignore.missing.groups" : [ "false" ],
+            "membership.ldap.attribute" : [ "member" ],
             "memberof.ldap.attribute" : [ "memberOf" ],
             "group.object.classes" : [ "groupOfNames" ],
             "drop.non.existing.groups.during.sync" : [ "false" ],
@@ -2336,18 +2344,18 @@
           "subComponents" : { },
           "config" : {
             "ldap.attribute" : [ "uid" ],
-            "is.mandatory.in.ldap" : [ "true" ],
             "attribute.force.default" : [ "false" ],
+            "is.mandatory.in.ldap" : [ "true" ],
             "is.binary.attribute" : [ "false" ],
-            "read.only" : [ "false" ],
             "always.read.value.from.ldap" : [ "false" ],
+            "read.only" : [ "false" ],
             "user.model.attribute" : [ "username" ]
           }
         } ]
       },
       "config" : {
-        "pagination" : [ "false" ],
         "fullSyncPeriod" : [ "-1" ],
+        "pagination" : [ "false" ],
         "startTls" : [ "false" ],
         "connectionPooling" : [ "true" ],
         "usersDn" : [ "ou=users,dc=dbrepo,dc=at" ],
@@ -2356,14 +2364,14 @@
         "importEnabled" : [ "true" ],
         "enabled" : [ "true" ],
         "changedSyncPeriod" : [ "-1" ],
+        "bindCredential" : [ "admin" ],
         "bindDn" : [ "cn=admin,dc=dbrepo,dc=at" ],
         "usernameLDAPAttribute" : [ "uid" ],
-        "bindCredential" : [ "admin" ],
         "lastSync" : [ "1719252666" ],
         "vendor" : [ "other" ],
         "uuidLDAPAttribute" : [ "entryUUID" ],
-        "connectionUrl" : [ "ldap://identity-service:1389" ],
         "allowKerberosAuthentication" : [ "false" ],
+        "connectionUrl" : [ "ldap://identity-service:1389" ],
         "syncRegistrations" : [ "true" ],
         "authType" : [ "simple" ],
         "useTruststoreSpi" : [ "always" ],
diff --git a/dbrepo-ui/layouts/default.vue b/dbrepo-ui/layouts/default.vue
index e65a256906..a08f6f70f5 100644
--- a/dbrepo-ui/layouts/default.vue
+++ b/dbrepo-ui/layouts/default.vue
@@ -104,14 +104,6 @@
           @click="login()">
           {{ $t('navigation.login') }}
         </v-btn>
-        <v-btn
-          v-if="!loggedIn"
-          color="primary"
-          variant="flat"
-          :prepend-icon="$vuetify.display.mdAndUp ? 'mdi-account-plus' : null"
-          to="/signup">
-          {{ $t('navigation.signup') }}
-        </v-btn>
         <v-btn
           v-if="loggedIn"
           to="/user"
@@ -288,7 +280,7 @@ export default {
     searchVariant () {
       const runtimeConfig = useRuntimeConfig()
       return this.$vuetify.theme.global.name.toLowerCase().endsWith('contrast') ? runtimeConfig.public.variant.input.contrast : 'solo-filled'
-    },
+    }
   },
   watch: {
     '$route.params': {
diff --git a/dbrepo-ui/nuxt.config.ts b/dbrepo-ui/nuxt.config.ts
index 1804b3a3fd..305a753d9e 100644
--- a/dbrepo-ui/nuxt.config.ts
+++ b/dbrepo-ui/nuxt.config.ts
@@ -3,19 +3,19 @@ import vuetify from 'vite-plugin-vuetify'
 
 const proxy: any = {}
 
-// /* proxies the backend calls, >>NOT<< the frontend calls (clicking) */
-// if (process.env.NODE_ENV === 'development') {
-//   const api = 'http://localhost'
-//   proxy['/api'] = api
-//   proxy['/pid'] = {
-//     target: api + '/api',
-//     changeOrigin: true,
-//     pathRewrite: {
-//       '^/pid': '/pid'
-//     }
-//   }
-//   process.env.NUXT_PUBLIC_API_SERVER = api
-// }
+/* proxies the backend calls, >>NOT<< the frontend calls (clicking) */
+if (process.env.NODE_ENV === 'development') {
+  const api = 'http://localhost'
+  proxy['/api'] = api
+  proxy['/pid'] = {
+    target: api + '/api',
+    changeOrigin: true,
+    pathRewrite: {
+      '^/pid': '/pid'
+    }
+  }
+  process.env.NUXT_PUBLIC_API_SERVER = api
+}
 
 /**
  * https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering
diff --git a/dbrepo-ui/pages/signup.vue b/dbrepo-ui/pages/signup.vue
deleted file mode 100644
index 19f781572a..0000000000
--- a/dbrepo-ui/pages/signup.vue
+++ /dev/null
@@ -1,167 +0,0 @@
-<template>
-  <div
-    v-if="!loggedIn">
-    <v-toolbar
-      :title="$t('pages.signup.name')"
-      flat />
-    <v-form
-      ref="form"
-      v-model="valid"
-      @submit.prevent="submit">
-      <v-card
-        variant="flat"
-        rounded="0">
-        <v-card-text>
-          <v-row dense>
-            <v-col sm="6">
-              <v-text-field
-                v-model="createAccount.email"
-                type="email"
-                autocomplete="off"
-                autofocus
-                required
-                name="email"
-                :rules="[v => !!v || $t('validation.required')]"
-                :hint="$t('pages.signup.email.hint')"
-                :label="$t('pages.signup.email.label')" />
-            </v-col>
-          </v-row>
-          <v-row dense>
-            <v-col sm="6">
-              <v-text-field
-                v-model="createAccount.username"
-                autocomplete="off"
-                required
-                name="username"
-                :rules="[v => !!v || $t('validation.required'),
-                         v => /^[a-z0-9]{3,}$/.test(v) || $t('validation.user.pattern'),
-                         v => !usernames.includes(v) || $t('validation.user.exists')]"
-                persistent-hint
-                :hint="$t('pages.signup.username.hint')"
-                :label="$t('pages.signup.username.label')" />
-            </v-col>
-          </v-row>
-          <v-row dense>
-            <v-col sm="6">
-              <v-text-field
-                v-model="createAccount.password"
-                autocomplete="off"
-                required
-                name="password"
-                :rules="[
-                  v => !!v || $t('validation.required')
-                ]"
-                type="password"
-                persistent-hint
-                :label="$t('pages.signup.password.label')"
-                :hint="$t('pages.signup.password.hint')" />
-            </v-col>
-          </v-row>
-          <v-row dense>
-            <v-col sm="6">
-              <v-text-field
-                v-model="password2"
-                autocomplete="off"
-                required
-                name="password-confirm"
-                :rules="[
-                  v => !!v || $t('validation.required')
-                ]"
-                :error-messages="password2 && password2 !== this.createAccount.password ? [this.$t('validation.matching')] : []"
-                type="password"
-                persistent-hint
-                :label="$t('pages.signup.confirm.label')"
-                :hint="$t('pages.signup.confirm.hint')" />
-            </v-col>
-          </v-row>
-        </v-card-text>
-        <v-card-text>
-          <v-btn
-            id="login"
-            variant="flat"
-            :disabled="!valid"
-            color="primary"
-            type="submit"
-            name="submit"
-            :text="$t('pages.signup.submit.label')"
-            :loading="loading"
-            @click="register" />
-        </v-card-text>
-      </v-card>
-    </v-form>
-  </div>
-</template>
-
-<script setup>
-const { loggedIn, user, login, logout } = useOidcAuth()
-</script>
-<script>
-export default {
-  data () {
-    return {
-      loading: false,
-      loadingUsers: false,
-      usernames: [],
-      error: false, // XXX: `error` is never changed
-      valid: false,
-      password2: null,
-      privacy: false,
-      consent: false,
-      createAccount: {
-        username: null,
-        email: null,
-        password: null
-      }
-    }
-  },
-  mounted () {
-    this.loadUsers()
-  },
-  methods: {
-    submit () {
-      this.$refs.form.validate()
-    },
-    register () {
-      this.loading = true
-      const userService = useUserService()
-      userService.create(this.createAccount)
-        .then(() => {
-          const toast = useToastInstance()
-          toast.success(this.$t('success.signup'))
-          this.$router.push('/login')
-          this.loading = false
-        })
-        .catch(({code}) => {
-          this.loading = false
-          const toast = useToastInstance()
-          if (typeof code !== 'string') {
-            return
-          }
-          toast.error(this.$t(code))
-        })
-        .finally(() => {
-          this.loading = false
-        })
-    },
-    loadUsers () {
-      this.loadingUsers = true
-      const userService = useUserService()
-      userService.findAll()
-        .then((users) => {
-          this.usernames = users.map(u => u.username)
-        })
-        .catch(({code}) => {
-          this.loadingUsers = false
-          const toast = useToastInstance()
-          if (typeof code !== 'string') {
-            return
-          }
-          toast.error(this.$t(code))
-        })
-        .finally(() => {
-          this.loadingUsers = false
-        })
-    }
-  }
-}
-</script>
-- 
GitLab