Skip to content

Instantly share code, notes, and snippets.

View krnbr's full-sized avatar
🏠

Karanbir Singh krnbr

🏠
  • Home
  • India
View GitHub Profile
import React, {useEffect, useLayoutEffect, useRef, useState} from 'react';
import {Button,CircularProgress,CssBaseline,TextField,Grid,Container,Theme,makeStyles,Box,FormHelperText,SnackbarContent,Snackbar,Icon,IconButton} from '@material-ui/core';
/*import Link from '@material-ui/core/Link';*/
/*import {makeStyles} from '@material-ui/core/styles';*/
import defaultTheme from '../src/theme';
import {ThemeProvider} from '@material-ui/styles';
import Logo from "../src/components/logo";
import {PasswordDto, RecaptchaDto, SignInDto, UserDto} from "../models/SignInDto";
import {NextPage} from "next";
import '../styles/signin.scss';
import React, {useEffect, useLayoutEffect, useRef, useState} from 'react';
import {Button,CircularProgress,CssBaseline,TextField,Grid,Container,Theme,makeStyles,Box,FormHelperText,SnackbarContent,Snackbar,Icon,IconButton} from '@material-ui/core';
/*import Link from '@material-ui/core/Link';*/
/*import {makeStyles} from '@material-ui/core/styles';*/
import defaultTheme from '../src/theme';
import {ThemeProvider} from '@material-ui/styles';
import Logo from "../src/components/logo";
import {PasswordDto, RecaptchaDto, RegisterDto, UserDto, RePasswordDto} from "../models/RegisterDto";
import {NextPage} from "next";
import '../styles/signin.scss';
@krnbr
krnbr / postman_oauth_auto_access_token.js
Last active October 17, 2019 19:04
Postman's Pre-request Script
/*
NOTES
replace your http://your.oauth.server.domain/oauth/token with actual token url for your oauth server
replace your_client_id with actual client id of your oauth server
replace your_client_secret with actual client secret of your oauth server
replace "your scopes space seperated" with actual scopes
*/
const postRequest = {
url: "http://your.oauth.server.domain/oauth/token",
function JSONStringify(object) {
var cache:any[] = [];
var str = JSON.stringify(object,
// custom replacer fxn - gets around "TypeError: Converting circular structure to JSON"
function(key, value) {
if (typeof value === 'object' && value !== null) {
if (cache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
{
"aud": [
"neuw_api_resources"
],
"scope": [
"system"
],
"iss": "http://localhost:8080",
"scopes": "system",
"exp": 1586855599,
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
{
"aud": [
"mock_aud"
],
"scope": [
"system"
],
"iss": "http://localhost:8080",
"scopes": "system",
"exp": 1586855599,
public class JKStoBase64String {
private static final int BUFFER_SIZE = 65535;
public static byte[] convertFileToByteArray(String certificateFilePath) throws Exception {
if (certificateFilePath == null || certificateFilePath.isEmpty()) {
throw new Exception("file path should not be null or empty");
}
File file = new File(certificateFilePath);
if (!file.exists()) {
throw new Exception("file not exist : " + file.getAbsolutePath());
\--oauth2-spring-boot-client - Root
| .gitignore - Git management for ignoring not required files
| pom.xml - Maven pom.xml
+---src
| +---main
| | +---java
| | | \---in
| | | \---neuw
| | | \---oauth2
| | | | Oauth2SpringBootClientApplication.java - The SpringBootApplication main class.
@krnbr
krnbr / application.properties
Created July 18, 2020 17:34
Oauth2 Client Important Properties
spring.security.oauth2.client.registration.<identifier>.authorization-grant-type=client_credentials
spring.security.oauth2.client.registration.<identifier>.client-id=client_id
spring.security.oauth2.client.registration.<identifier>.client-secret=client_secret
spring.security.oauth2.client.provider.<identifier>.token-uri=http://localhost:8353/oauth/token