Skip to main content

Go SDK

The Go SDK provides net/http compatible authentication and authorization middleware. It is a Vertex client SDK, not a separate server product. The commands pin the root, Chi, Gin and Echo modules to the same source commit through its public Go pseudo-version.

To keep tokens on your application backend, use the optional BFF server-session integration. The existing examples below retain their browser-token/Bearer behavior.

Install​

For net/http, install the root module:

go get github.com/axis-iam/vertex-sdk-go@v0.1.2-0.20261120053216-18ba54527e50

For Chi, install the root and adapter modules together:

go get github.com/axis-iam/vertex-sdk-go@v0.1.2-0.20261120053216-18ba54527e50 github.com/axis-iam/vertex-sdk-go/chi@v0.1.2-0.20261120053216-18ba54527e50

For Gin:

go get github.com/axis-iam/vertex-sdk-go@v0.1.2-0.20261120053216-18ba54527e50 github.com/axis-iam/vertex-sdk-go/gin@v0.1.2-0.20261120053216-18ba54527e50

For Echo:

go get github.com/axis-iam/vertex-sdk-go@v0.1.2-0.20261120053216-18ba54527e50 github.com/axis-iam/vertex-sdk-go/echo@v0.1.2-0.20261120053216-18ba54527e50

Quickstart​

package main

import (
"net/http"
vertex "github.com/axis-iam/vertex-sdk-go"
"github.com/axis-iam/vertex-sdk-go/authz"
)

func routes(iam *vertex.SDK) http.Handler {
mux := http.NewServeMux()
mux.Handle("GET /orders", iam.RequirePerm(authz.PermissionKey{Resource: "orders", Action: "read"})(http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNoContent) },
)))
return iam.Authenticate()(mux)
}

Construct the SDK with issuer endpoint, WEB/M2M ClientID, server-held ClientSecret, and resource audience. Missing or invalid identity and permission context denies access.

import (
"log"
"os"
vertex "github.com/axis-iam/vertex-sdk-go"
)

func newVertexSDK() *vertex.SDK {
iam, err := vertex.New(&vertex.SDKConfig{
Endpoint: os.Getenv("IAM_ENDPOINT"),
Issuer: os.Getenv("IAM_ENDPOINT"),
ClientID: os.Getenv("IAM_CLIENT_ID"),
ClientSecret: os.Getenv("IAM_CLIENT_SECRET"),
Audience: os.Getenv("IAM_RESOURCE_AUDIENCE"),
})
if err != nil { log.Fatal(err) }
return iam
}

IAM_CLIENT_ID and IAM_CLIENT_SECRET belong to the Go API's WEB/M2M confidential client, not the browser SPA. Set Audience explicitly to the Application resource audience. The SDK does not infer it from ClientID.

Resource server and management boundary​

SDK.Authenticate and SDK.RequirePerm protect incoming user bearer requests. PortalOpenAPIClient is a separate server-side M2M management client with issuer, Portal endpoint, client ID, and secret. Grant it only the exact management scopes required by the called methods. Do not instantiate it in browser or mobile code.

Reference​

The reference is produced with the Go toolchain's go doc -all across public module packages.