Sign up without first and last name

Hi all

On the registration page, it requires first and last name but I have deleted the html tag from the page and the it shows the following error messages after the sign up was pressed:

Screenshot from 2020-03-22 17-05-47

The question is, how to make the fields first and last name not as mandatory.

Thanks

As far as I know you can’t disable them.
I solved this by setting a default value in the html of the theme on those input values.

value="${(register.formData.lastName!'x')}"

@zonaut thanks for your response. Seriously? That is not good.
@keycloak_team Please confirm, if it is correct.

Thanks

You could also take another approach by disabling the profile validation in the flows. But this also disables the email check, so, yes …
I’ve read somewhere that you can implement your own validation checks but to be honest I couldn’t be bothered.
It shouldn’t be this hard just to disable some fields on a registration page.

BTW If you want to create a custom form action than take a look at org.keycloak.authentication.forms.RegistrationProfile which is the Profile validation of those 3 fields.
You can copy it and adapt it to the things you want. Just make sure that the PROVIDER_ID is not longer than 36 chars.
You can than copy the registration flow and add it as an execution step and delete the original one.
This is something I wanted to do between other things :stuck_out_tongue: but didn’t have time yet to fully implement and test it.

1 Like

Once you’ve finished it, could you please publish the example? Would would be awesome.

Thanks a lot

I’ve bookmarked this page and will keep you updated of the progress. I don’t know when I’ll have the time though as this is not my main priority at the moment.

Awesome. Thanks a lot.

Ok, now that’s in my mind I couldn’t let it stay there unfinished :stuck_out_tongue:

I’ve made a repo and over time it will contain other examples on events and mail. You can find the repo on

Have fun and if you have any problems let me know or if the readme isn’t clear on some things.

3 Likes

Thanks so much. I will try out, you are the best man… :+1: :+1: :+1: :+1:
I will give you my feedback.

I do not have any experience with JBOSS. What is a standalone-ha.xml file? Is it not enough to compile it and put the jar file into the folder /opt/jboss/keycloak/standalone/deployments/?

Thanks

It will be enough if you have implemented an alternative for those validate methods and also Message ones because they use parts of the services module from Keycloak.
I can’t guarantee that it will work without changing the standalone-ha.xml file as I used that method

import org.keycloak.services.messages.Messages;
import org.keycloak.services.validation.Validation;

The standalone-ha.xml file can be found under /opt/jboss/keycloak/standalone/configuration/
Sooner or later you will probably touch this file so it’s good to get to know it.
Also look which your deployment uses, because the Docker image uses the -ha.xml high availability one. It could be that your’s uses the standalone.xml one but I doubt it.

Hi @zonaut thanks for your answer.
I am running Keycloak in docker container.
I will do as you suggested and will let you know, if it is working or not.
Another question, how do you know, which dependencies to import in maven file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.keycloak</groupId>
        <artifactId>keycloak-parent</artifactId>
        <version>9.0.2</version> <!-- https://mvnrepository.com/artifact/org.keycloak/keycloak-parent -->
    </parent>

    <name>Placeholder Keycloak extensions</name>
    <description/>

    <artifactId>placeholder-keycloak-extensions</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-server-spi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-server-spi-private</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-services</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-saml-core-public</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ws.rs</groupId>
            <artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>

I have experienced with sbt and a bit with maven.

The dependencies I’ve imported are not all necessary for this project. I’ve removed some parts of it and created a new repo as it contained some confidential thingies of mine :stuck_out_tongue:

You probably can remove the freemarker, jboss-jaxrs-api_2.1_spec, jboss-logging and keycloak-saml-core-public easily. Remove until breakage.

BTW, I always have my own standalone-ha.xml file outside my Docker container and mount it.

./config/standalone-ha.xml:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xml

2 Likes

@zonaut thanks so much for your help. I am appreciate a lot.

No problem at all.
Another thing about the dependencies, the scope ‘provided’ tells it to look for the dependencies in the container, in this case Keycloak itself. So these are not compiled into the jar as you can see by the size of it. So don’t worry if you’ve forgot one.

one more question:

What do I have to use here?

The docker-compose:

  keycloak:
    image: "jboss/keycloak"
    container_name: "keycloak"
    restart: always
    depends_on:
      - traefik
    networks:
      - dataxu
    environment:
      - KEYCLOAK_USER=
      - KEYCLOAK_PASSWORD=
      - PROXY_ADDRESS_FORWARDING=true
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.keycloak.rule=Host(`auth.dataxu.io`)"
      - "traefik.http.routers.keycloak.tls=true"
      #- "traefik.http.routers.keycloak.entrypoints=websecure"
      - "traefik.http.routers.keycloak.tls.certresolver=sslresolver"
      - "traefik.http.services.keycloak.loadbalancer.server.port=8080"
    volumes:
      - ./keycloak/placeholder-keycloak-extensions.jar:/opt/jboss/keycloak/standalone/deployments/placeholder-keycloak-extensions.jar
      - ./keycloak/standalone-ha.xml:/opt/jboss/keycloak/standalone/configuration/standalone-ha.xm

I think, that the extension was successfully loaded:

14:46:22,872 INFO  [org.keycloak.services] (ServerService Thread Pool -- 70) KC-SERVICES0001: Loading config from standalone.xml or domain.xml
14:46:22,919 INFO  [org.keycloak.url.DefaultHostnameProviderFactory] (ServerService Thread Pool -- 70) Frontend: <request>, Admin: <frontend>, Backend: <request>
14:46:23,487 INFO  [org.keycloak.url.DefaultHostnameProviderFactory] (ServerService Thread Pool -- 70) Frontend: <request>, Admin: <frontend>, Backend: <request>
14:46:23,512 WARN  [org.keycloak.services] (ServerService Thread Pool -- 70) KC-SERVICES0047: ph-registration-profile-action (com.placeholder.keycloak.extensions.actions.forms.PlaceholderRegistrationProfile) is implementing the internal SPI form-action. This SPI is internal and may change without notice
14:46:23,560 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 70) WFLYCLINF0002: Started realmRevisions cache from keycloak container
14:46:23,570 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 70) WFLYCLINF0002: Started userRevisions cache from keycloak container
14:46:23,590 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 70) WFLYCLINF0002: Started authorizationRevisions cache from keycloak container
14:46:23,591 INFO  [org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory] (ServerService Thread Pool -- 70) Node name: 1726f233343b, Site name: null  

Thanks

You’ve clicked the wrong Execution.
→ Click the Actions dropdown menu to the far right of ‘Copy Of Registration Registration Form’ and select ‘Add execution’

You need to click the blue actions dropdown farthest right

You gave me an idea to add pictures to the readme as this is something I’ve stumbled upon myself in the past.

@zonaut great it works like a charm:
Screenshot from 2020-04-03 20-50-00

Thanks so much for your help.
One more question, where do you get the implementation. How do you find it out?

Thanks

No problem.

I’ve found things out by crawling through the source code of Keycloak itself. It contains a bunch of examples on these providers and other little handy thingies. Github is a dream come true :stuck_out_tongue:
But at the end of the day it’s still trial and error so we can only learn from each other and pass that information on.

1 Like

Hello zonaut.
On readme, you read:
“Copy the jar in the target folder to the /opt/jboss/keycloak/standalone/deployments/ folder”

Sorry, but where is the .jar ? I haven’t found the jar in the repo.

Tks in advance.