mirror of
https://github.com/wso2/open-mcp-auth-proxy.git
synced 2025-06-27 09:05:41 +00:00
Fix multiple redirect uri format and filter supported grant types (#36)
This commit is contained in:
parent
316370be1c
commit
fdb81007d4
1 changed files with 16 additions and 3 deletions
|
@ -113,6 +113,7 @@ func (p *asgardeoProvider) RegisterHandler() http.HandlerFunc {
|
||||||
|
|
||||||
if err := p.createAsgardeoApplication(regReq); err != nil {
|
if err := p.createAsgardeoApplication(regReq); err != nil {
|
||||||
logger.Warn("Asgardeo application creation failed: %v", err)
|
logger.Warn("Asgardeo application creation failed: %v", err)
|
||||||
|
http.Error(w, "Failed to create application in Asgardeo", http.StatusInternalServerError)
|
||||||
// Optionally http.Error(...) if you want to fail
|
// Optionally http.Error(...) if you want to fail
|
||||||
// or continue to return partial data.
|
// or continue to return partial data.
|
||||||
}
|
}
|
||||||
|
@ -269,6 +270,18 @@ func buildAsgardeoPayload(regReq RegisterRequest) map[string]interface{} {
|
||||||
}
|
}
|
||||||
appName += "-" + randomString(5)
|
appName += "-" + randomString(5)
|
||||||
|
|
||||||
|
// Build redirect URIs regex from list of redirect URIs : regexp=(https://app.example.com/callback1|https://app.example.com/callback2)
|
||||||
|
redirectURI := "regexp=(" + strings.Join(regReq.RedirectURIs, "|") + ")"
|
||||||
|
redirectURIs := []string{redirectURI}
|
||||||
|
|
||||||
|
// Filter unsupported grant types
|
||||||
|
var grantTypes []string
|
||||||
|
for _, gt := range regReq.GrantTypes {
|
||||||
|
if gt == "authorization_code" || gt == "refresh_token" {
|
||||||
|
grantTypes = append(grantTypes, gt)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"name": appName,
|
"name": appName,
|
||||||
"templateId": "custom-application-oidc",
|
"templateId": "custom-application-oidc",
|
||||||
|
@ -276,10 +289,10 @@ func buildAsgardeoPayload(regReq RegisterRequest) map[string]interface{} {
|
||||||
"oidc": map[string]interface{}{
|
"oidc": map[string]interface{}{
|
||||||
"clientId": regReq.ClientID,
|
"clientId": regReq.ClientID,
|
||||||
"clientSecret": regReq.ClientSecret,
|
"clientSecret": regReq.ClientSecret,
|
||||||
"grantTypes": regReq.GrantTypes,
|
"grantTypes": grantTypes,
|
||||||
"callbackURLs": regReq.RedirectURIs,
|
"callbackURLs": redirectURIs,
|
||||||
"allowedOrigins": []string{},
|
"allowedOrigins": []string{},
|
||||||
"publicClient": false,
|
"publicClient": true,
|
||||||
"pkce": map[string]bool{
|
"pkce": map[string]bool{
|
||||||
"mandatory": true,
|
"mandatory": true,
|
||||||
"supportPlainTransformAlgorithm": true,
|
"supportPlainTransformAlgorithm": true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue