This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ export GO111MODULE=off | |
$ go clean --modcache | |
$ go clean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# security configurations | |
quarkus.oidc.client-id=quarkus-bff | |
quarkus.oidc.credentials.secret=<secret> | |
quarkus.oidc.auth-server-url=http://localhost:8081/auth/realms/keycloak-demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("/user") | |
@Authenticated | |
@Produces(MediaType.APPLICATION_JSON) | |
@Consumes(MediaType.APPLICATION_JSON) | |
public class UserResource { | |
private final User user; | |
public UserResource() { | |
user = new User(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [data, setData] = useState({ users: [] }); | |
useEffect(() => { | |
const fetchData = async () => { | |
const result = await axios( | |
'http://127.0.0.1:8080/user', { headers: { "Authorization": "Bearer " + localStorage.getItem("react-token") } } | |
); | |
setData(result.data); | |
}; | |
fetchData(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getJWTToken() { | |
KeycloakAuthenticationToken authentication = (KeycloakAuthenticationToken) SecurityContextHolder.getContext() | |
.getAuthentication(); | |
KeycloakPrincipal<KeycloakSecurityContext> keycloakPrincipal = (KeycloakPrincipal<KeycloakSecurityContext>) authentication | |
.getPrincipal(); | |
return keycloakPrincipal.getKeycloakSecurityContext().getTokenString(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class CustomKeycloakSpringBootConfigResolver extends KeycloakSpringBootConfigResolver { | |
private final KeycloakDeployment keycloakDeployment; | |
public CustomKeycloakSpringBootConfigResolver(KeycloakSpringBootProperties properties) { | |
keycloakDeployment = KeycloakDeploymentBuilder.build(properties); | |
} | |
@Override | |
public KeycloakDeployment resolve(HttpFacade.Request facade) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@KeycloakConfiguration | |
class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { | |
/** | |
* Registers the KeycloakAuthenticationProvider with the authentication manager. | |
*/ | |
@Autowired | |
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { | |
KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider(); | |
auth.authenticationProvider(keycloakAuthenticationProvider); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//keycloak init options | |
let initOptions = { | |
url: 'https://0.0.0.0:8445/auth', realm: 'keycloak-demo', clientId: 'react-test-app', onLoad: 'login-required' | |
} | |
let keycloak = Keycloak(initOptions); | |
keycloak.init({ onLoad: initOptions.onLoad }).success((auth) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//keycloak init options | |
let initOptions = { | |
url: 'https://0.0.0.0:8445/auth', realm: 'keycloak-demo', clientId: 'angular-test-app' | |
} | |
let keycloak = Keycloak(initOptions); | |
keycloak.init({ onLoad: "login-required" }).success((auth) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let initOptions = { | |
url: 'https://0.0.0.0:8445/auth', realm: 'keycloak-demo', clientId: 'vue-test-app', onLoad:'login-required' | |
} | |
let keycloak = Keycloak(initOptions); | |
keycloak.init({ onLoad: initOptions.onLoad }).success((auth) =>{ | |
if(!auth) { | |
window.location.reload(); |