basic login service/state (#17)

This commit is contained in:
Michael Quigley
2022-08-02 13:23:31 -04:00
parent cf1abe7282
commit e699994ca5
26 changed files with 875 additions and 476 deletions

View File

@ -53,6 +53,9 @@ func NewZrokAPI(spec *loads.Document) *ZrokAPI {
IdentityEnableHandler: identity.EnableHandlerFunc(func(params identity.EnableParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation identity.Enable has not yet been implemented")
}),
IdentityLoginHandler: identity.LoginHandlerFunc(func(params identity.LoginParams) middleware.Responder {
return middleware.NotImplemented("operation identity.Login has not yet been implemented")
}),
TunnelTunnelHandler: tunnel.TunnelHandlerFunc(func(params tunnel.TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation tunnel.Tunnel has not yet been implemented")
}),
@ -116,6 +119,8 @@ type ZrokAPI struct {
IdentityCreateAccountHandler identity.CreateAccountHandler
// IdentityEnableHandler sets the operation handler for the enable operation
IdentityEnableHandler identity.EnableHandler
// IdentityLoginHandler sets the operation handler for the login operation
IdentityLoginHandler identity.LoginHandler
// TunnelTunnelHandler sets the operation handler for the tunnel operation
TunnelTunnelHandler tunnel.TunnelHandler
// TunnelUntunnelHandler sets the operation handler for the untunnel operation
@ -209,6 +214,9 @@ func (o *ZrokAPI) Validate() error {
if o.IdentityEnableHandler == nil {
unregistered = append(unregistered, "identity.EnableHandler")
}
if o.IdentityLoginHandler == nil {
unregistered = append(unregistered, "identity.LoginHandler")
}
if o.TunnelTunnelHandler == nil {
unregistered = append(unregistered, "tunnel.TunnelHandler")
}
@ -328,6 +336,10 @@ func (o *ZrokAPI) initHandlerCache() {
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/login"] = identity.NewLogin(o.context, o.IdentityLoginHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/tunnel"] = tunnel.NewTunnel(o.context, o.TunnelTunnelHandler)
if o.handlers["DELETE"] == nil {
o.handlers["DELETE"] = make(map[string]http.Handler)