Skip to content

Instantly share code, notes, and snippets.

View yigiterinc's full-sized avatar
What does the future awaits me with?

Yigit Kemal Erinc yigiterinc

What does the future awaits me with?
  • Munich, Germany
View GitHub Profile
@yigiterinc
yigiterinc / git_history_correction.sh
Created December 1, 2021 23:50
Run in a repository folder to rewrite git branch histories. Useful for fixing the commits with wrong git config. USE WITH EXTREME CAUTION!!!
git filter-branch --env-filter '
WRONG_EMAIL="WRONG_EMAIL"
NEW_NAME="NEW_NAME"
NEW_EMAIL="NEW_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
@yigiterinc
yigiterinc / rainbow_tables.py
Created July 9, 2021 11:05
Basic implementation of a rainbow table attack on Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Module for the rainbow generation.
"""
from math import floor
import csv
def h(x: int) -> int:
@EnableWebSecurity
public class WebSecurity extends WebSecurityConfigurerAdapter {
private UserDetailsServiceImpl userDetailsService;
private BCryptPasswordEncoder bCryptPasswordEncoder;
public WebSecurity(UserDetailsServiceImpl userService, BCryptPasswordEncoder bCryptPasswordEncoder) {
this.userDetailsService = userService;
this.bCryptPasswordEncoder = bCryptPasswordEncoder;
}
public class JWTAuthorizationFilter extends BasicAuthenticationFilter {
public JWTAuthorizationFilter(AuthenticationManager authManager) {
super(authManager);
}
@Override
protected void doFilterInternal(HttpServletRequest req,
HttpServletResponse res,
FilterChain chain) throws IOException, ServletException {
public class SecurityConstants {
public static final String SECRET = "SECRET_KEY";
public static final long EXPIRATION_TIME = 900_000; // 15 mins
public static final String TOKEN_PREFIX = "Bearer ";
public static final String HEADER_STRING = "Authorization";
public static final String SIGN_UP_URL = "/api/services/controller/user";
}
@yigiterinc
yigiterinc / JWTAuthenticationFilter.java
Last active August 30, 2023 13:48
JWT authentication filter class for my tutorial in Medium
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
private AuthenticationManager authenticationManager;
public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
setFilterProcessesUrl("/api/services/controller/user/login");
}