cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [cxf] branch master updated: Stripping the prefix from the dyn calculated issuer URI reported by OIDCConfigurationService by default to make it easier to sync it with the the same value reported from the sibling endpoints
Date Fri, 29 Sep 2017 11:43:12 GMT
This is an automated email from the ASF dual-hosted git repository.

sergeyb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 487b5f3  Stripping the prefix from the dyn calculated issuer URI reported by OIDCConfigurationService
by default to make it easier to sync it with the the same value reported from the sibling
endpoints
487b5f3 is described below

commit 487b5f3f1ad43e4c2f9583b35f1967950dec0cd5
Author: Sergey Beryozkin <sberyozkin@gmail.com>
AuthorDate: Fri Sep 29 12:42:59 2017 +0100

    Stripping the prefix from the dyn calculated issuer URI reported by OIDCConfigurationService
by default to make it easier to sync it with the the same value reported from the sibling
endpoints
---
 .../services/AuthorizationMetadataService.java     | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationMetadataService.java
b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationMetadataService.java
index 10c2b7d..5fe9326 100644
--- a/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationMetadataService.java
+++ b/rt/rs/security/oauth-parent/oauth2/src/main/java/org/apache/cxf/rs/security/oauth2/services/AuthorizationMetadataService.java
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.rs.security.oauth2.services;
 
+import java.net.URI;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -33,6 +34,7 @@ import org.apache.cxf.jaxrs.json.basic.JsonMapObjectReaderWriter;
 @Path("oauth-authorization-server")
 public class AuthorizationMetadataService {
     private String issuer;
+    private boolean stripPathFromIssuerUri = true;
     // Required
     private String authorizationEndpointAddress;
     // Optional if only an implicit flow is used
@@ -62,7 +64,7 @@ public class AuthorizationMetadataService {
 
     protected void prepareConfigurationData(Map<String, Object> cfg, String baseUri)
{
         // Issuer
-        cfg.put("issuer", issuer == null ? baseUri : issuer);
+        cfg.put("issuer", buildIssuerUri(baseUri));
         // Authorization Endpoint
         String theAuthorizationEndpointAddress =
             calculateEndpointAddress(authorizationEndpointAddress, baseUri, "/idp/authorize");
@@ -169,4 +171,22 @@ public class AuthorizationMetadataService {
         this.dynamicRegistrationEndpointAddress = dynamicRegistrationEndpointAddress;
     }
 
+    private String buildIssuerUri(String baseUri) {
+        URI uri = issuer == null || !issuer.startsWith("/") ? URI.create(baseUri) 
+            : UriBuilder.fromUri(baseUri).path(issuer).build();
+        if (stripPathFromIssuerUri) {
+            StringBuilder sb = new StringBuilder();
+            sb.append(uri.getScheme()).append("://").append(uri.getHost());
+            if (uri.getPort() != -1) {
+                sb.append(':').append(uri.getPort());
+            }
+            return sb.toString();
+        } else {
+            return uri.toString();
+        }
+    }
+
+    public void setStripPathFromIssuerUri(boolean stripPathFromIssuerUri) {
+        this.stripPathFromIssuerUri = stripPathFromIssuerUri;
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <commits@cxf.apache.org>'].

Mime
View raw message