Skip to content

Instantly share code, notes, and snippets.

View rkbalgi's full-sized avatar
🏠
Working from home

Raghavendra Balgi rkbalgi

🏠
Working from home
View GitHub Profile
@rkbalgi
rkbalgi / keycloak.java
Created October 6, 2018 11:04
Check permissions of a user in Keycloak with Java API
AccessTokenResponse token = authzClient
.obtainAccessToken(userName, password);
final AuthorizationRequest authReq = new AuthorizationRequest();
//checking for a specific permission
authReq.setMetadata(new Metadata());
authReq.getMetadata().setResponseMode("decision");
authReq.addPermission("payroll", "write");
AuthorizationResponse authResponse = null;
@rkbalgi
rkbalgi / gist:07f39dd1ad45d402058613d28890bb90
Created October 7, 2018 07:38
Adding a Bind DN in AD LDS (and other useful LDAP related stuff)
How to add a bind dn on AD LDS
https://proofid.com/blog/blogset-okta-ldap-integration-microsoft-ad-lds/
(Basically, add a new DN (say cn=admin,cn=service-accounts,dc=example,dc=com), reset password and then add this as a "member" of cn=Readers
@rkbalgi
rkbalgi / SampleTestSuite.java
Last active November 30, 2018 15:42
Creating multiple databases before test execution (Junit, SpringBoot)
package com.example;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
import org.h2.tools.Server;
import org.hibernate.jpa.HibernatePersistenceProvider;
import org.junit.BeforeClass;
@rkbalgi
rkbalgi / gist:605c6b50be0c6b2842d1f4c9667654f2
Created December 4, 2018 16:05
Create Roles and Permissions with Keycloak
http://lists.jboss.org/pipermail/keycloak-user/2018-March/013417.html
https://github.com/pedroigor/keycloak/tree/1e1de85685bb5d5f180f510630cd7133f8a35375/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/admin/client/authorization
@rkbalgi
rkbalgi / DateTimeConversionWithTz.java
Last active December 28, 2018 04:22
Dealing with TimeZone in Java8 and/with Postgresql
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
@Configuration
public class AppConfig{
@Bean
public KeycloakConfigResolver KeycloakConfigResolver(KeycloakSpringBootProperties props) {
return new SimpleKcConfigResolver(props);
}
@rkbalgi
rkbalgi / pom.xml
Last active January 25, 2019 14:11
Generate and build swagger API client using maven
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<configuration>
<apiSources>
<apiSource>
<springmvc>true</springmvc>
<locations>
<location>com.example.resources.DemoResource</location>
@rkbalgi
rkbalgi / gist:11cc334798d6d9428cd07de695005ba3
Created February 23, 2019 17:45
Replace ID's in keycloak realm export JSON file (clone realm)
https://github.com/rkbalgi/keycloak-cli/blob/master/src/main/java/com/github/rkbalgi/apps/keycloak/IdReplacer.java
@rkbalgi
rkbalgi / ubuntu19.10_virtualbox.md
Last active April 8, 2020 09:12
Setting up Ubuntu 19.10 server edition on VirtualBox (osboxes)

Ubuntu 19.10 on VirtualBox (Using osboxes server edition image)

I had few problems setting up Ubuntu 19.10 using a osbox image on my windows 10 (NAT mode). Hopefully, this gist will help those trying the same

Set up networking as NAT mode in Virtual Box

  • Attached Mode: NAT
  • Promiscuos Mode: Allow All
  • Cable Attached - Selected (Port forwarding if necessary - I included 22 as I work by ssh'ing into the box)

Figure out your network interface name

@rkbalgi
rkbalgi / build_envoy_vm.md
Last active October 10, 2020 09:25
Building envoyproxy on a VirtualBox VM (Ubuntu 19.10)

Building envoy on Windows

This is targeted for Windows users (who wish to build outside of a docker container - which BTW is still the preferred way to build the image)

sudo apt-get install build-essential
sudo wget -O /usr/local/bin/bazel https://github.com/bazelbuild/bazelisk/releases/download/v0.0.8/bazelisk-linux-amd64
sudo chmod +x /usr/local/bin/bazel