I want to optimize the creation of things people find truly valuable in as short of time as possible. To that end, I wanted to make it super simple for Goalora users to join the Goalora Discord community by using Red Hat SSO's ability to link social media accounts to their Goalora SSO account. Then, if they choose to pay for extra GPT4 assessments of their data, I wanted to auto join them to an exclusive feature-request channel they can use to guide the creation of new features. The willingness to pay for features, signals those users are where the best ideas for creating additional value in Goalora should come from. This post is about how I accomplished all of that with writing as little code as possible in as few steps as possible. I always reach for code last and try to find the solution that hurts my brain least and doesn't make me tired thinking about maintaining the solution. I took the extra time to think about the problem and find an elegant solution.
- Sign up for Goalora with Red Hat SSO.
- Link Discord option appears.
3. Built in Reed Hat SSO Account page includes Discord linking option.
4. Authorize Goalora
5. While Linking, the Discord Plugin uses the access token granted during the process to auto join the user to the Goalora server in the same process
6. Once the user is joined to the Discord server, the regular bot API that uses bot tokens can auto check for roles and auto add roles to give subscribers access to the "feature-request" channel on the Goalora Discord server. This could be a whole other blog post. I will include a link to the no-code (declaritive) kamelets and kamelet bindings I use in place of writing custom REST endpoints to make the necessary calls to allow the bot to add roles to a user. You could instead write a simple REST endpoint in your language of choice to do this part. The first 5 steps above do not require a bot. I took the next steps because the main purpose of the Goalora community right now is to give subscribers the ability to exclusively drive the feature creation of Goalora.
Red Hat Single Sign On supports many social login providers out of the box. Normally I would just create an OpenID Connect provider for Discord without needing to add a plugin, but I need to add a plugin in this case to auto join users to the Goalora server upon linking their Discord account plus get around a limitation due to Discord being strict about not allowing the openid scope in requests.
- Install the Red Hat Single Sign On Operator on the Openshift cluster in a specific namespace.
- Clone this repository: Keycloak Discord Plugin
- cd to the pom.xml directory and run mvn install
- Upload the generated jar in the target directory to a public aws bucket or another location accessible to your Openshift cluster
- With the namespace selected where you installed the Red Hat Single Sign On Operator, on the left hand menu select "Installed Operators", then click on the Red Hat Single Sign On Operator, go to the "Keycloak" tab, click create new and enter the following
kind: Keycloak apiVersion: keycloak.org/v1alpha1 metadata: name: goalsetter-keycloak labels: app: sso namespace: goalsetter spec: instances: 1 externalAccess: enabled: true extensions: - >- https://itd-game-download.s3.us-east-2.amazonaws.com/keycloak-discord-0.4.9-SNAPSHOT.jar
Replace the extensions link with where you put the jar file you uploaded in step 4.
That's it for linking Discord accounts and auto joining to your server. You will see a Discord option under social Identity Provider options.
Optional Steps to Add Discord Roles to Users with declaritive integration (Kamelet and KameletBinding)
- clone repository: Discord Kamelets
- There are two text files. One in the add-roles folder and one in the check-roles folder. Those are the steps to add the Kamelet and KameletBindings.
I don't want to have to write code and maintain a deployment. I prefer declarative kamelets that I can deploy in seconds. However, you may prefer to just create REST endpoints in your language of choice for this simple functionality of calling the Discord API via bot token to check if a user that is joined to the server has a role and if not, add that role. I use this for subscribers to auto give them the feature-request role so they have "feature-request" channel access.