Header Creation service extension (Legacy)
ℹ️
This topic refers to legacy configuration syntax. App gateways are now defined as Proxy apps. A new example of the create header service extension is documented here.
Crafting custom HTTP headers is a common operation for legacy applications that consume identity via headers.
CreateHeader
This example uses the createHeader
Service Extension to enrich the attribute data
returned in claims by an authentication provider.
appgateways:
- name: Sonar
basePath: /
headers:
SM_USER: azure.name
firstname:
createHeader:
funcName: CreateHeader
file: /etc/maverics/extensions/createHeader.go
policies:
- location: /
authentication:
idps:
- azure
authorization:
allowAll: true
/etc/maverics/extensions/createHeader.go
package main
import (
"errors"
"net/http"
"maverics/app"
"maverics/session"
)
func CreateHeader(
ag *app.AppGateway,
rw http.ResponseWriter,
req *http.Request,
) (http.Header, error) {
header := make(http.Header)
name := session.GetString(req, "azure.givenname")
if name == "" {
return nil, errors.New("did not find 'azure.givenname' on session")
}
name += " the Great"
header["firstname"] = []string{name}
return header, nil
}