Files
upstream-corteza/server/automation/automation/oauth2_handler.gen.go
upstream-mirror 7e385fc126
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
2026-09-18 01:22:23 +05:00

184 lines
3.6 KiB
Go
Generated

package automation
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// automation/automation/oauth2_handler.yaml
import (
"context"
atypes "github.com/cortezaproject/corteza/server/automation/types"
"github.com/cortezaproject/corteza/server/pkg/expr"
"github.com/cortezaproject/corteza/server/pkg/wfexec"
)
var _ wfexec.ExecResponse
type (
oauth2HandlerRegistry interface {
AddFunctions(ff ...*atypes.Function)
Type(ref string) expr.Type
}
)
func (h oauth2Handler) register() {
h.reg.AddFunctions(
h.Authenticate(),
)
}
type (
oauth2AuthenticateArgs struct {
hasClient bool
Client string
hasSecret bool
Secret string
hasScope bool
Scope string
hasTokenUrl bool
TokenUrl string
}
oauth2AuthenticateResults struct {
AccessToken string
RefreshToken string
Token interface{}
}
)
// Authenticate function Authentication: OAUTH2
//
// expects implementation of authenticate function:
//
// func (h oauth2Handler) authenticate(ctx context.Context, args *oauth2AuthenticateArgs) (results *oauth2AuthenticateResults, err error) {
// return
// }
func (h oauth2Handler) Authenticate() *atypes.Function {
return &atypes.Function{
Ref: "oauth2Authenticate",
Kind: "function",
Labels: map[string]string(nil),
Meta: &atypes.FunctionMeta{
Short: "Authentication: OAUTH2",
},
Parameters: []*atypes.Param{
{
Name: "client",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Client",
},
},
{
Name: "secret",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Secret",
},
},
{
Name: "scope",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Scope",
},
},
{
Name: "tokenUrl",
Types: []string{"String"}, Required: true,
Meta: &atypes.ParamMeta{
Label: "Token URL",
},
},
},
Results: []*atypes.Param{
{
Name: "accessToken",
Types: []string{"String"},
},
{
Name: "refreshToken",
Types: []string{"String"},
},
{
Name: "token",
Types: []string{"Any"},
},
},
Handler: func(ctx context.Context, in *expr.Vars) (out *expr.Vars, err error) {
var (
args = &oauth2AuthenticateArgs{
hasClient: in.Has("client"),
hasSecret: in.Has("secret"),
hasScope: in.Has("scope"),
hasTokenUrl: in.Has("tokenUrl"),
}
)
if err = in.Decode(args); err != nil {
return
}
var results *oauth2AuthenticateResults
if results, err = h.authenticate(ctx, args); err != nil {
return
}
out = &expr.Vars{}
{
// converting results.AccessToken (string) to String
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("String").Cast(results.AccessToken); err != nil {
return
} else if err = expr.Assign(out, "accessToken", tval); err != nil {
return
}
}
{
// converting results.RefreshToken (string) to String
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("String").Cast(results.RefreshToken); err != nil {
return
} else if err = expr.Assign(out, "refreshToken", tval); err != nil {
return
}
}
{
// converting results.Token (interface{}) to Any
var (
tval expr.TypedValue
)
if tval, err = h.reg.Type("Any").Cast(results.Token); err != nil {
return
} else if err = expr.Assign(out, "token", tval); err != nil {
return
}
}
return
},
}
}