From 8603d016a022ec7235c0792c8e7478391ad958aa Mon Sep 17 00:00:00 2001
From: zachmann <gabriel.zachmann@kit.edu>
Date: Tue, 21 Sep 2021 11:25:50 +0200
Subject: [PATCH] cleanup grant types

---
 go.mod                                               |  2 +-
 go.sum                                               |  2 ++
 internal/config/config.go                            |  8 ++------
 .../endpoints/configuration/configurationEndpoint.go | 12 ------------
 internal/endpoints/token/mytoken/mytokenEndpoint.go  |  8 --------
 shared/model/grantType.go                            |  4 +---
 6 files changed, 6 insertions(+), 30 deletions(-)

diff --git a/go.mod b/go.mod
index 005f8a02..88a62479 100644
--- a/go.mod
+++ b/go.mod
@@ -18,7 +18,7 @@ require (
 	github.com/jinzhu/copier v0.3.2
 	github.com/jmoiron/sqlx v1.3.4
 	github.com/lestrrat-go/jwx v1.2.6
-	github.com/oidc-mytoken/api v0.0.0-20210730065550-117f733ae8a1
+	github.com/oidc-mytoken/api v0.3.1-0.20210921092134-2599cdd1db99
 	github.com/oidc-mytoken/lib v0.2.1-0.20210730094903-f59c9a8f84e0
 	github.com/pkg/errors v0.9.1
 	github.com/satori/go.uuid v1.2.0
diff --git a/go.sum b/go.sum
index 3cd3fbf8..3017bacc 100644
--- a/go.sum
+++ b/go.sum
@@ -415,6 +415,8 @@ github.com/nishanths/exhaustive v0.0.0-20200525081945-8e46705b6132 h1:NjznefjSrr
 github.com/nishanths/exhaustive v0.0.0-20200525081945-8e46705b6132/go.mod h1:wBEpHwM2OdmeNpdCvRPUlkEbBuaFmcK4Wv8Q7FuGW3c=
 github.com/oidc-mytoken/api v0.0.0-20210730065550-117f733ae8a1 h1:i1LIDAuTm4SR65iPjVq+elXHSKNju3Yt61+jreULTuE=
 github.com/oidc-mytoken/api v0.0.0-20210730065550-117f733ae8a1/go.mod h1:S8t1XA42EFAgc3vUfis0g1LPGA4TXH0nfDynvgo6cwk=
+github.com/oidc-mytoken/api v0.3.1-0.20210921092134-2599cdd1db99 h1:0b66hU44d5wwcOpQhnilvIP0prVaQnZeaMLVCOYfAjQ=
+github.com/oidc-mytoken/api v0.3.1-0.20210921092134-2599cdd1db99/go.mod h1:S8t1XA42EFAgc3vUfis0g1LPGA4TXH0nfDynvgo6cwk=
 github.com/oidc-mytoken/lib v0.2.1-0.20210730094903-f59c9a8f84e0 h1:eo1lEHaU6vkQZnAQyy7dA7JIoXpUOS/G4csV1LPIi80=
 github.com/oidc-mytoken/lib v0.2.1-0.20210730094903-f59c9a8f84e0/go.mod h1:2ITx3/ZTRyrR6GGIG3BfNdscxERXsD0Up8G3yZZDJng=
 github.com/oidc-mytoken/server v0.2.0/go.mod h1:6uFm+Za9NMK3gq4OOIeX3gs3T6leluVIWsGiM1zlQbA=
diff --git a/internal/config/config.go b/internal/config/config.go
index cc9ecb2f..e37a2324 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -7,7 +7,7 @@ import (
 	"github.com/coreos/go-oidc/v3/oidc"
 	"github.com/pkg/errors"
 	log "github.com/sirupsen/logrus"
-	yaml "gopkg.in/yaml.v3"
+	"gopkg.in/yaml.v3"
 
 	model2 "github.com/oidc-mytoken/server/internal/model"
 	"github.com/oidc-mytoken/server/internal/utils/errorfmt"
@@ -76,9 +76,7 @@ var defaultConfig = Config{
 			PollingCodeExpiresAfter: 300,
 			PollingInterval:         5,
 		},
-		TokenRotation:    onlyEnable{true},
-		AccessTokenGrant: onlyEnable{true},
-		SignedJWTGrant:   onlyEnable{true},
+		TokenRotation: onlyEnable{true},
 		TokenInfo: tokeninfoConfig{
 			Introspect: onlyEnable{true},
 			History:    onlyEnable{true},
@@ -120,8 +118,6 @@ type featuresConf struct {
 	TransferCodes           onlyEnable             `yaml:"transfer_codes"`
 	Polling                 pollingConf            `yaml:"polling_codes"`
 	TokenRotation           onlyEnable             `yaml:"token_rotation"`
-	AccessTokenGrant        onlyEnable             `yaml:"access_token_grant"`
-	SignedJWTGrant          onlyEnable             `yaml:"signed_jwt_grant"`
 	TokenInfo               tokeninfoConfig        `yaml:"tokeninfo"`
 	WebInterface            onlyEnable             `yaml:"web_interface"`
 	DisabledRestrictionKeys model2.RestrictionKeys `yaml:"unsupported_restrictions"`
diff --git a/internal/endpoints/configuration/configurationEndpoint.go b/internal/endpoints/configuration/configurationEndpoint.go
index 1beb4f7e..fd31a905 100644
--- a/internal/endpoints/configuration/configurationEndpoint.go
+++ b/internal/endpoints/configuration/configurationEndpoint.go
@@ -41,8 +41,6 @@ func Init() {
 	addShortTokens(mytokenConfig)
 	addTransferCodes(mytokenConfig)
 	addPollingCodes(mytokenConfig)
-	addAccessTokenGrant(mytokenConfig)
-	addSignedJWTGrant(mytokenConfig)
 	addTokenInfo(mytokenConfig)
 }
 
@@ -95,16 +93,6 @@ func addPollingCodes(mytokenConfig *pkg.MytokenConfiguration) {
 		pkgModel.GrantTypePollingCode.AddToSliceIfNotFound(&mytokenConfig.MytokenEndpointGrantTypesSupported)
 	}
 }
-func addAccessTokenGrant(mytokenConfig *pkg.MytokenConfiguration) {
-	if config.Get().Features.AccessTokenGrant.Enabled {
-		pkgModel.GrantTypeAccessToken.AddToSliceIfNotFound(&mytokenConfig.MytokenEndpointGrantTypesSupported)
-	}
-}
-func addSignedJWTGrant(mytokenConfig *pkg.MytokenConfiguration) {
-	if config.Get().Features.SignedJWTGrant.Enabled {
-		pkgModel.GrantTypePrivateKeyJWT.AddToSliceIfNotFound(&mytokenConfig.MytokenEndpointGrantTypesSupported)
-	}
-}
 func addTokenInfo(mytokenConfig *pkg.MytokenConfiguration) {
 	if !config.Get().Features.TokenInfo.Enabled {
 		mytokenConfig.TokeninfoEndpoint = ""
diff --git a/internal/endpoints/token/mytoken/mytokenEndpoint.go b/internal/endpoints/token/mytoken/mytokenEndpoint.go
index 99667122..2e26d655 100644
--- a/internal/endpoints/token/mytoken/mytokenEndpoint.go
+++ b/internal/endpoints/token/mytoken/mytokenEndpoint.go
@@ -34,14 +34,6 @@ func HandleMytokenEndpoint(ctx *fiber.Ctx) error {
 		if config.Get().Features.Polling.Enabled {
 			return polling.HandlePollingCode(ctx)
 		}
-	case model.GrantTypeAccessToken:
-		if config.Get().Features.AccessTokenGrant.Enabled {
-			return serverModel.ResponseNYI.Send(ctx)
-		}
-	case model.GrantTypePrivateKeyJWT:
-		if config.Get().Features.SignedJWTGrant.Enabled {
-			return serverModel.ResponseNYI.Send(ctx)
-		}
 	case model.GrantTypeTransferCode:
 		if config.Get().Features.TransferCodes.Enabled {
 			return mytoken.HandleMytokenFromTransferCode(ctx).Send(ctx)
diff --git a/shared/model/grantType.go b/shared/model/grantType.go
index 4636da9d..5f2eaa5d 100644
--- a/shared/model/grantType.go
+++ b/shared/model/grantType.go
@@ -5,7 +5,7 @@ import (
 
 	"github.com/oidc-mytoken/api/v0"
 	"github.com/pkg/errors"
-	yaml "gopkg.in/yaml.v3"
+	"gopkg.in/yaml.v3"
 )
 
 // GrantType is an enum like type for grant types
@@ -19,8 +19,6 @@ const ( // assert that these are in the same order as api.AllGrantTypes
 	GrantTypeMytoken GrantType = iota
 	GrantTypeOIDCFlow
 	GrantTypePollingCode
-	GrantTypeAccessToken
-	GrantTypePrivateKeyJWT
 	GrantTypeTransferCode
 	maxGrantType
 )
-- 
GitLab