Skip to content

Instantly share code, notes, and snippets.

View vdelacou's full-sized avatar

Vincent DELACOURT vdelacou

View GitHub Profile
@vdelacou
vdelacou / Auth0ManagementApiService.java
Last active August 30, 2018 07:14
Auth0ManagementApiService
package com.seelix.api.service;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import org.apache.commons.lang3.RandomStringUtils;
@vdelacou
vdelacou / UserDTO.java
Created June 14, 2018 09:32
UserDTO adapt for Auth0 User in JHipster
package com.seelix.api.service.dto;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Set;
import java.util.stream.Collectors;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
@vdelacou
vdelacou / Auth0ApiConfiguration.java
Created June 14, 2018 09:28
Create Configuration file in spring boot for Auth0 API
package com.seelix.api.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.auth0.client.auth.AuthAPI;
import com.auth0.client.mgmt.ManagementAPI;
import com.auth0.exception.Auth0Exception;
import com.auth0.json.auth.TokenHolder;
@vdelacou
vdelacou / ApplicationProperties.java
Created June 14, 2018 09:26
Add Auth0 Properties with Management API to JHipster spring boot application
package com.seelix.api.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Properties specific to Seelix.
* <p>
* Properties are configured in the application.yml file. See
* {@link io.github.jhipster.config.JHipsterProperties} for a good example.
*/
@vdelacou
vdelacou / logout.tsx
Created June 14, 2018 09:12
Change jhipster Logout with Auth0
import * as React from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
import { IRootState } from 'app/shared/reducers';
import { logout } from 'app/shared/reducers/authentication';
import Auth0 from 'app/config/auth0';
export interface ILogoutProps extends StateProps, DispatchProps { }
@vdelacou
vdelacou / login.tsx
Created June 14, 2018 09:06
Change Jhipster login to work with Auth0
import * as React from 'react';
import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router-dom';
import { Storage } from 'react-jhipster';
import { IRootState } from 'app/shared/reducers';
import { getSession } from 'app/shared/reducers/authentication';
import Auth0 from 'app/config/auth0';
export interface ILoginProps extends StateProps, DispatchProps, RouteComponentProps<{}> { }
@vdelacou
vdelacou / Auth0.ts
Last active June 14, 2018 09:01
Create class for instance of auth0
import Auth0Lock from 'auth0-lock';
export default class Auth {
lock = new Auth0Lock(
'MVmsdXMGSS2JusuH82DeNAErxtoTmmir',
'seelix.eu.auth0.com',
{
auth:
{
audience: 'https://seelix-api.com',
@vdelacou
vdelacou / JWTFilter.java
Created June 7, 2018 07:11
Change JWT Filter with optional Authentication
package com.seelix.api.security.jwt;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@vdelacou
vdelacou / TokenProvider.java
Last active June 8, 2018 08:26
Change TokenProvider in JHipster app to add Auth0
package com.seelix.api.security.jwt;
import java.security.interfaces.RSAPublicKey;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
@vdelacou
vdelacou / ApplicationProperties.java
Created June 7, 2018 06:12
Add Auth0 Properties to JHipster spring boot application
package com.seelix.api.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Properties specific to Seelix.
* <p>
* Properties are configured in the application.yml file.
* See {@link io.github.jhipster.config.JHipsterProperties} for a good example.
*/