Skip to content

fnproject/ext-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A very simple (too simple) auth extension example

Simple authentication extension for Fn.

Usage

Simply add github.com/fnproject/ext-auth to your ext.yaml file and build. Learn more.

Required environment variables:

  • SIMPLE_SECRET - a secret string to use for signing JWT tokens.

Try running the following commands to try it out:

# First, let's try to access and endpoint without credentials.
curl http://localhost:8080/v1/apps
# Fails... :(

# Login: this will create a user if one doesn't exist
curl -H "Content-Type: application/json" -X POST -d '{"username":"johnny","password":"xyz"}' http://localhost:8080/v1/login

# deploy a function
fn init --runtime go gofunc
cd gofunc
fn deploy --app myapp --local
# SHOULD FAIL

export FN_TOKEN=YOUR_TOKEN
fn deploy --app myapp --local
# SHOULD WORK

# Grab token returned from above and try to access another endpoint
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8080/v1/apps
# Success! :)

# now make another user
curl -H "Content-Type: application/json" -X POST -d '{"username":"tommy","password":"abc"}' http://localhost:8080/v1/login
export FN_TOKEN=TOMMY_TOKEN
fn deploy --app myapp --local
# SHOULD FAIL
fn deploy --app tommyapp --local
# SHOULD WORK

For Development

cd main
SIMPLE_SECRET=ubersecret go run main.go

About

Authentication extension for Fn Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages