remove utils deps

This commit is contained in:
Livio Amstutz 2019-11-29 15:35:37 +01:00
parent 616b42e525
commit eb774003d7
8 changed files with 46 additions and 88 deletions

View file

@ -11,7 +11,7 @@ import (
"github.com/gorilla/schema"
"github.com/caos/oidc/pkg/oidc"
str_utils "github.com/caos/utils/strings"
"github.com/caos/oidc/pkg/utils"
)
type Authorizer interface {
@ -94,7 +94,7 @@ func ValidateAuthReqScopes(scopes []string) error {
if len(scopes) == 0 {
return ErrInvalidRequest("scope missing")
}
if !str_utils.Contains(scopes, oidc.ScopeOpenID) {
if !utils.Contains(scopes, oidc.ScopeOpenID) {
return ErrInvalidRequest("scope openid missing")
}
return nil
@ -108,7 +108,7 @@ func ValidateAuthReqRedirectURI(uri, client_id string, responseType oidc.Respons
if err != nil {
return ErrServerError(err.Error())
}
if !str_utils.Contains(client.RedirectURIs(), uri) {
if !utils.Contains(client.RedirectURIs(), uri) {
return ErrInvalidRequest("redirect_uri not allowed")
}
if strings.HasPrefix(uri, "https://") {

View file

@ -5,9 +5,9 @@ import (
"net/http"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"github.com/caos/oidc/pkg/oidc"
"github.com/caos/utils/logging"
)
type OpenIDProvider interface {
@ -36,12 +36,16 @@ func Start(ctx context.Context, o OpenIDProvider) {
go func() {
<-ctx.Done()
err := o.HttpHandler().Shutdown(ctx)
logging.Log("SERVE-REqwpM").OnError(err).Error("graceful shutdown of oidc server failed")
if err != nil {
logrus.Error("graceful shutdown of oidc server failed")
}
}()
go func() {
err := o.HttpHandler().ListenAndServe()
logging.Log("SERVE-4YNIwG").OnError(err).Panic("oidc server serve failed")
if err != nil {
logrus.Panic("oidc server serve failed")
}
}()
logging.LogWithFields("SERVE-koAFMs", "port", o.Port()).Info("oidc server is listening")
logrus.Infof("oidc server is listening on %s", o.Port())
}