Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 798 Bytes

README.md

File metadata and controls

32 lines (22 loc) · 798 Bytes

Okta Auth

Small and simple drop in utils for handling Okta auth.

OAuth handler

This handler is an easy way to put Okta OAuth in front of endpoints.

import "github.com/nanzhong/oktaauth"

var (
    sessionKey   []byte
    clientID     string
    clientSecret string
    issuer       string
    redirectURI  string
    preservePath bool
    errorWriter  func(w http.ResponseWriter, r *http.Request, err error, status int)
)

// ...

oaHandler, err := oktaauth.NewAuthHandler(sessionKey, clientID, clientSecret, issuer, redirectURI, WithPreservePath(true), WithErrorWriter(errorWriter))

// ...

http.HandleFunc("/oauth/callback", oaHandler.AuthCodeCallbackHandler)
http.HandleFunc("/", oaHandler.Ensure(realRouteHandler))
http.HandleFunc("/logout", oaHandler.ClearSessionHandler)