Skip to content

skos-ninja/cf-cli-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cf-CLI-Auth

This library piggy backs off of the Cloudflared CLI to allow you to perform authentication to Cloudflare Access applications using either user based auth or service token auth.

The library implements a http.RoundTripper for authentication with a Cloudflare Access Application.

Examples

The examples below show an implementation for user and service auth that return a http.Client for use by client wrappers.

User auth

An example of the user auth flow

appDomain := "https://<domain>/"
tr := http.DefaultTransport
transport, err := cf.NewAccessTokenClient(context, tr, appDomain)
if err != nil {
    return err
}
client := &http.Client{Transport: transport}

Service auth

An example of the service auth flow

tr := http.DefaultTransport
transport := cf.NewServiceTokenClient(tr, clientId, clientSecret)
client := &http.Client{Transport: transport}

Limitations

The library is currently limited to only perform an initial token fetch at the creation of the RoundTripper and as such is not designed to be used for long running operations.

About

Cloudflare Access auth for CLIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages