Skip to content

Instantly share code, notes, and snippets.

View brunokrebs's full-sized avatar

Bruno brunokrebs

  • Brazil
View GitHub Profile
@brunokrebs
brunokrebs / webtask-test.js
Created October 30, 2017 11:17
Webtask and MongoDB
var parallel = require('async').parallel;
var MongoClient = require('[email protected]').MongoClient;
module.exports = function (ctx, done) {
var url = 'mongodb://bkrebs:[email protected]:23410/brunokrebsauth0'
MongoClient.connect(url, function (err, db) {
if(err) return done(err);
db.collection('test').insertOne({
name: 'Bruno [email protected]',
package com.auth0.samples.authapi.security;
// imports ...
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
private AuthenticationManager authenticationManager;
public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
setFilterProcessesUrl("/api/login");
// ...
public class JWTAuthorizationFilter extends BasicAuthenticationFilter{
// ...
private CustomAuthenticationToken getAuthentication(HttpServletRequest request) {
String token = request.getHeader(HEADER_STRING);
if(token != null) {
// get claims from JWT
@brunokrebs
brunokrebs / JWTAuthenticationFilter.java
Created October 3, 2017 12:31
Adding claims to a JWT on Spring Boot
package com.auth0.samples.authapi.security;
// ... imports
public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
// ...
@Override
protected void successfulAuthentication(HttpServletRequest req,
HttpServletResponse res,
@brunokrebs
brunokrebs / .bash_profile
Created September 16, 2017 00:13
Streamlining Auth0 blog editing—or—Scripts to improve tasks while editing Auth0 blog posts
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
alias git_poc="git push origin HEAD"
alias git_wip="git add . && git commit -m 'wip'"
alias git_cap="(cd ~/git/blog && git_wip && git_poc )"
alias refresh_hosts="sudo killall -HUP mDNSResponder"
alias refresh_bash="source ~/.bash_profile"
alias ll="ls -la"
alias blog="bundle exec jekyll serve --watch --limit_posts 10 &"
alias new_post="create_new_post"
function create_new_post {
# are we are on blog's root dir?
ls | grep Rakefile &> /dev/null \
&& ls | grep _posts &> /dev/null
if [ $? -gt 0 ]; then
echo "not on blog's root directory"
return 1
fi
# adds new repo as a remote
git remote add origin [email protected]:YOUR-USERNAME/YOUR-REPO.git
# commits our code
git add .
git commit -m "Task List Angular app with a secure serverless REST API."
# push work to new repo
git push origin master
// ... other imports
import { EventEmitter, Output } from '@angular/core';
// ... component definition
export class TaskListComponent implements OnInit {
@Output()
startAjaxRequest = new EventEmitter<void>();
@Output()
<app-nav-bar></app-nav-bar>
<div class="app-container">
<!-- ... welcome message ... -->
<app-task-list *ngIf="authService.authenticated()"
(startAjaxRequest)="slimLoading.start()"
(completeAjaxRequest)="slimLoading.complete()">
</app-task-list>
</div>
// ... other imports
import { SlimLoadingBarService } from 'ng2-slim-loading-bar';
// ... component definition
export class AppComponent {
constructor(private authService: AuthService, private slimLoading: SlimLoadingBarService) { }
// ... method definitions
}