mirror of
https://github.com/openziti/zrok.git
synced 2024-11-25 17:43:53 +01:00
oauth updates
This commit is contained in:
parent
a8c76b2877
commit
18424a1b48
@ -21,9 +21,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cfg *Config
|
cfg *config.Config
|
||||||
str *store.Store
|
str *store.Store
|
||||||
mtr *metricsAgent
|
|
||||||
idb influxdb2.Client
|
idb influxdb2.Client
|
||||||
limitsAgent *limits.Agent
|
limitsAgent *limits.Agent
|
||||||
)
|
)
|
||||||
@ -72,7 +71,7 @@ func Run(inCfg *config.Config) error {
|
|||||||
api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler)
|
api.MetadataVersionHandler = metadata.VersionHandlerFunc(versionHandler)
|
||||||
api.ShareAccessHandler = newAccessHandler()
|
api.ShareAccessHandler = newAccessHandler()
|
||||||
api.ShareOauthAuthenticateHandler = newOauthHandler()
|
api.ShareOauthAuthenticateHandler = newOauthHandler()
|
||||||
api.ShareShareHandler = newShareHandler(cfg.Limits)
|
api.ShareShareHandler = newShareHandler()
|
||||||
api.ShareUnaccessHandler = newUnaccessHandler()
|
api.ShareUnaccessHandler = newUnaccessHandler()
|
||||||
api.ShareUnshareHandler = newUnshareHandler()
|
api.ShareUnshareHandler = newUnshareHandler()
|
||||||
api.ShareUpdateShareHandler = newUpdateShareHandler()
|
api.ShareUpdateShareHandler = newUpdateShareHandler()
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/openziti/zrok/controller/oauth"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go-v2/config"
|
"github.com/aws/aws-sdk-go-v2/config"
|
||||||
"github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
|
"github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
@ -24,6 +26,8 @@ func newOauthHandler() *oauthHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *oauthHandler) Handle(params share.OauthAuthenticateParams) middleware.Responder {
|
func (h *oauthHandler) Handle(params share.OauthAuthenticateParams) middleware.Responder {
|
||||||
|
ghandle := oauth.NewGoogleOauthHandler()
|
||||||
|
return ghandle.Handle(params)
|
||||||
awsUrl := "https:///oauth2/token" // COGNITO URL OR WHATEVER OAUTH PROVIDER URL
|
awsUrl := "https:///oauth2/token" // COGNITO URL OR WHATEVER OAUTH PROVIDER URL
|
||||||
clientId := "" // PROVIDER CLIENT ID
|
clientId := "" // PROVIDER CLIENT ID
|
||||||
secret := "" // PROVIDER CLIENT SECRET
|
secret := "" // PROVIDER CLIENT SECRET
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/openziti/edge-api/rest_model"
|
"github.com/openziti/edge-api/rest_model"
|
||||||
"github.com/openziti/zrok/model"
|
"github.com/openziti/zrok/model"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Create options struct
|
// TODO: Create options struct
|
||||||
|
@ -26,6 +26,12 @@ func (o *OauthAuthenticateReader) ReadResponse(response runtime.ClientResponse,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
|
case 500:
|
||||||
|
result := NewOauthAuthenticateInternalServerError()
|
||||||
|
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return nil, result
|
||||||
default:
|
default:
|
||||||
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
return nil, runtime.NewAPIError("response status code does not match any response statuses defined for this endpoint in the swagger spec", response, response.Code())
|
||||||
}
|
}
|
||||||
@ -81,3 +87,54 @@ func (o *OauthAuthenticateOK) readResponse(response runtime.ClientResponse, cons
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewOauthAuthenticateInternalServerError creates a OauthAuthenticateInternalServerError with default headers values
|
||||||
|
func NewOauthAuthenticateInternalServerError() *OauthAuthenticateInternalServerError {
|
||||||
|
return &OauthAuthenticateInternalServerError{}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
OauthAuthenticateInternalServerError describes a response with status code 500, with default header values.
|
||||||
|
|
||||||
|
internal server error
|
||||||
|
*/
|
||||||
|
type OauthAuthenticateInternalServerError struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSuccess returns true when this oauth authenticate internal server error response has a 2xx status code
|
||||||
|
func (o *OauthAuthenticateInternalServerError) IsSuccess() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsRedirect returns true when this oauth authenticate internal server error response has a 3xx status code
|
||||||
|
func (o *OauthAuthenticateInternalServerError) IsRedirect() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsClientError returns true when this oauth authenticate internal server error response has a 4xx status code
|
||||||
|
func (o *OauthAuthenticateInternalServerError) IsClientError() bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsServerError returns true when this oauth authenticate internal server error response has a 5xx status code
|
||||||
|
func (o *OauthAuthenticateInternalServerError) IsServerError() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCode returns true when this oauth authenticate internal server error response a status code equal to that given
|
||||||
|
func (o *OauthAuthenticateInternalServerError) IsCode(code int) bool {
|
||||||
|
return code == 500
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OauthAuthenticateInternalServerError) Error() string {
|
||||||
|
return fmt.Sprintf("[GET /oauth/authorize][%d] oauthAuthenticateInternalServerError ", 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OauthAuthenticateInternalServerError) String() string {
|
||||||
|
return fmt.Sprintf("[GET /oauth/authorize][%d] oauthAuthenticateInternalServerError ", 500)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OauthAuthenticateInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -725,6 +725,9 @@ func init() {
|
|||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "testing"
|
"description": "testing"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "internal server error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2363,6 +2366,9 @@ func init() {
|
|||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "testing"
|
"description": "testing"
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "internal server error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,3 +35,28 @@ func (o *OauthAuthenticateOK) WriteResponse(rw http.ResponseWriter, producer run
|
|||||||
|
|
||||||
rw.WriteHeader(200)
|
rw.WriteHeader(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OauthAuthenticateInternalServerErrorCode is the HTTP code returned for type OauthAuthenticateInternalServerError
|
||||||
|
const OauthAuthenticateInternalServerErrorCode int = 500
|
||||||
|
|
||||||
|
/*
|
||||||
|
OauthAuthenticateInternalServerError internal server error
|
||||||
|
|
||||||
|
swagger:response oauthAuthenticateInternalServerError
|
||||||
|
*/
|
||||||
|
type OauthAuthenticateInternalServerError struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOauthAuthenticateInternalServerError creates OauthAuthenticateInternalServerError with default headers values
|
||||||
|
func NewOauthAuthenticateInternalServerError() *OauthAuthenticateInternalServerError {
|
||||||
|
|
||||||
|
return &OauthAuthenticateInternalServerError{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteResponse to the client
|
||||||
|
func (o *OauthAuthenticateInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||||
|
|
||||||
|
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||||
|
|
||||||
|
rw.WriteHeader(500)
|
||||||
|
}
|
||||||
|
@ -573,6 +573,8 @@ paths:
|
|||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: testing
|
description: testing
|
||||||
|
500:
|
||||||
|
description: internal server error
|
||||||
|
|
||||||
|
|
||||||
/share:
|
/share:
|
||||||
@ -1001,7 +1003,7 @@ definitions:
|
|||||||
$ref: "#/definitions/authUser"
|
$ref: "#/definitions/authUser"
|
||||||
oauthProvider:
|
oauthProvider:
|
||||||
type: string
|
type: string
|
||||||
enum: [amazon]
|
enum: [amazon,google]
|
||||||
oauthEmailDomains:
|
oauthEmailDomains:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
Loading…
Reference in New Issue
Block a user