Skip to content

Commit

Permalink
Merge pull request trustbloc#1606 from fqutishat/new1234
Browse files Browse the repository at this point in the history
chore: remove not used code
  • Loading branch information
fqutishat authored Feb 26, 2024
2 parents 72ebd7d + 6820426 commit f2ac6b9
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 500 deletions.
353 changes: 175 additions & 178 deletions api/spec/openapi.gen.go

Large diffs are not rendered by default.

76 changes: 0 additions & 76 deletions docs/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,33 +105,6 @@ paths:
description: Returns Credential Issuance history.
tags:
- issuer
'/oidc/idp/{profileID}/{profileVersion}/.well-known/openid-configuration':
parameters:
- schema:
type: string
name: profileID
in: path
required: true
description: Profile Id
- schema:
type: string
name: profileVersion
in: path
required: true
description: Profile Version
get:
summary: Request openid-config public endpoint.
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/WellKnownOpenIDConfiguration'
operationId: openid-config-v2
description: Returns openid-config.
tags:
- issuer
'/issuer/profiles/{profileID}/{profileVersion}/credentials/issue':
parameters:
- schema:
Expand Down Expand Up @@ -848,55 +821,6 @@ components:
required:
- status
description: Response model for health check status.
WellKnownOpenIDConfiguration:
title: WellKnownOpenIDConfiguration response
x-tags:
- issuer
type: object
description: OpenID Config response.
properties:
authorization_endpoint:
type: string
description: URL of the OP's OAuth 2.0 Authorization Endpoint.
token_endpoint:
type: string
description: URL of the OP's OAuth 2.0 Token Endpoint.
response_types_supported:
type: array
description: JSON array containing a list of the OAuth 2.0 response_type values that this OP supports.
items:
type: string
registration_endpoint:
type: string
description: URL of the OP's Dynamic Client Registration Endpoint.
scopes_supported:
type: array
items:
type: string
description: 'JSON array containing a list of the OAuth 2.0 [RFC6749] scope values that this server supports.'
grant_types_supported:
type: array
items:
type: string
description: JSON array containing a list of the OAuth 2.0 Grant Type values that this OP supports.
pre-authorized_grant_anonymous_access_supported:
type: boolean
description: JSON Boolean indicating whether the issuer accepts a Token Request with a Pre-Authorized Code but without a client id. The default is false.
wallet_initiated_auth_flow_supported:
type: boolean
description: JSON Boolean indicating whether the issuer profile supports wallet initiated flow in OIDC4CI. The default is false.
credential_ack_endpoint:
type: string
description: URL of the acknowledgement endpoint.
required:
- authorization_endpoint
- token_endpoint
- response_types_supported
- scopes_supported
- grant_types_supported
- wallet_initiated_auth_flow_supported
- pre-authorized_grant_anonymous_access_supported
- credential_ack_endpoint
WellKnownOpenIDIssuerConfiguration:
title: WellKnownOpenIDIssuerConfiguration response
x-tags:
Expand Down
46 changes: 0 additions & 46 deletions pkg/restapi/v1/issuer/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"reflect"
"strings"
"time"
Expand Down Expand Up @@ -430,51 +429,6 @@ func (c *Controller) InitiateCredentialIssuance(e echo.Context, profileID, profi
return util.WriteOutputWithContentType(e)(resp, ct, nil)
}

// OpenidConfigV2 request openid configuration for issuer. // TODO to remove
// GET /oidc/idp/{profileID}/{profileVersion}/.well-known/openid-configuration.
func (c *Controller) OpenidConfigV2(ctx echo.Context, profileID, profileVersion string) error {
return util.WriteOutput(ctx)(c.GetOpenIDConfig(profileID, profileVersion))
}

func (c *Controller) GetOpenIDConfig(profileID, profileVersion string) (*WellKnownOpenIDIssuerConfiguration, error) {
host := c.externalHostURL
if !strings.HasSuffix(host, "/") {
host += "/"
}

config := &WellKnownOpenIDIssuerConfiguration{
AuthorizationEndpoint: lo.ToPtr(fmt.Sprintf("%soidc/authorize", host)),
ResponseTypesSupported: lo.ToPtr([]string{"code"}),
TokenEndpoint: lo.ToPtr(fmt.Sprintf("%soidc/token", host)),
CredentialAckEndpoint: lo.ToPtr(fmt.Sprintf("%soidc/acknowledgement", host)),
}

profile, err := c.profileSvc.GetProfile(profileID, profileVersion)
if err != nil {
return nil, err
}

if profile.OIDCConfig != nil {
config.GrantTypesSupported = &profile.OIDCConfig.GrantTypesSupported
config.ScopesSupported = &profile.OIDCConfig.ScopesSupported
config.PreAuthorizedGrantAnonymousAccessSupported =
&profile.OIDCConfig.PreAuthorizedGrantAnonymousAccessSupported

if profile.OIDCConfig.EnableDynamicClientRegistration {
var regURL string

regURL, err = url.JoinPath(host, "oidc", profileID, profileVersion, "register")
if err != nil {
return nil, fmt.Errorf("build registration endpoint: %w", err)
}

config.RegistrationEndpoint = lo.ToPtr(regURL)
}
}

return config, nil
}

func (c *Controller) initiateIssuance(
ctx context.Context,
req *InitiateOIDC4CIRequest,
Expand Down
24 changes: 0 additions & 24 deletions pkg/restapi/v1/issuer/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2287,30 +2287,6 @@ func Test_getCredentialSubjects(t *testing.T) {
})
}

func TestGetConfig(t *testing.T) {
profileSvc := NewMockProfileService(gomock.NewController(t))

ctr := NewController(&Config{
ProfileSvc: profileSvc,
})

profileSvc.EXPECT().GetProfile("12345", "v0.1").
Return(&profileapi.Issuer{
OIDCConfig: &profileapi.OIDCConfig{
ScopesSupported: []string{"scope1"},
GrantTypesSupported: []string{"grantType1"},
EnableDynamicClientRegistration: true,
PreAuthorizedGrantAnonymousAccessSupported: true,
},
}, nil)
resp, err := ctr.GetOpenIDConfig("12345", "v0.1")
assert.NoError(t, err)
assert.Equal(t, "/oidc/acknowledgement", *resp.CredentialAckEndpoint)
assert.Equal(t, []string{"grantType1"}, *resp.GrantTypesSupported)
assert.Equal(t, []string{"scope1"}, *resp.ScopesSupported)
assert.Equal(t, "/oidc/12345/v0.1/register", *resp.RegistrationEndpoint)
}

func Test_sendFailedEvent(t *testing.T) {
t.Run("marshal error", func(t *testing.T) {
c := NewController(&Config{})
Expand Down
Loading

0 comments on commit f2ac6b9

Please sign in to comment.