forked from indigo-iam/iam
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request indigo-iam#416 from indigo-iam/release-v1.7.1
Release v1.7.1
- Loading branch information
Showing
17 changed files
with
325 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
iam-test-client/src/main/java/it/infn/mw/tc/IamAuthRequestOptionsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package it.infn.mw.tc; | ||
|
||
import static com.google.common.base.Strings.isNullOrEmpty; | ||
import static java.util.stream.Collectors.joining; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.mitre.oauth2.model.RegisteredClient; | ||
import org.mitre.openid.connect.client.service.AuthRequestOptionsService; | ||
import org.mitre.openid.connect.config.ServerConfiguration; | ||
|
||
import com.google.common.base.Splitter; | ||
import com.google.common.base.Strings; | ||
|
||
public class IamAuthRequestOptionsService implements AuthRequestOptionsService { | ||
|
||
IamClientConfig properties; | ||
|
||
|
||
public IamAuthRequestOptionsService(IamClientConfig properties) { | ||
this.properties = properties; | ||
} | ||
|
||
private String sanitizeScope(String scope, RegisteredClient client) { | ||
List<String> requestedScopes = Splitter.on(" ").splitToList(scope); | ||
return requestedScopes.stream().filter(client.getScope()::contains).collect(joining(" ")); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getOptions(ServerConfiguration server, RegisteredClient client, | ||
HttpServletRequest request) { | ||
Map<String, String> options = new HashMap<>(); | ||
|
||
if (!isNullOrEmpty(properties.getExtAuthnHint())) { | ||
options.put("ext_authn_hint", properties.getExtAuthnHint()); | ||
} | ||
|
||
if (request.getParameter("scope") != null) { | ||
String sanitizedScope = sanitizeScope(request.getParameter("scope"), client); | ||
|
||
if (!Strings.isNullOrEmpty(sanitizedScope)) { | ||
options.put("scope", sanitizedScope); | ||
} | ||
|
||
} | ||
|
||
return options; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getTokenOptions(ServerConfiguration server, RegisteredClient client, | ||
HttpServletRequest request) { | ||
|
||
return Collections.emptyMap(); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
iam-test-client/src/main/java/it/infn/mw/tc/IamAuthRequestUrlBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package it.infn.mw.tc; | ||
|
||
import java.net.URISyntaxException; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
|
||
import org.apache.http.client.utils.URIBuilder; | ||
import org.mitre.oauth2.model.RegisteredClient; | ||
import org.mitre.openid.connect.client.service.AuthRequestUrlBuilder; | ||
import org.mitre.openid.connect.config.ServerConfiguration; | ||
import org.springframework.security.authentication.AuthenticationServiceException; | ||
|
||
import com.google.common.base.Joiner; | ||
import com.google.common.base.Strings; | ||
|
||
public class IamAuthRequestUrlBuilder implements AuthRequestUrlBuilder { | ||
|
||
|
||
@Override | ||
public String buildAuthRequestUrl(ServerConfiguration serverConfig, RegisteredClient clientConfig, | ||
String redirectUri, String nonce, String state, Map<String, String> options, | ||
String loginHint) { | ||
|
||
try { | ||
|
||
URIBuilder uriBuilder = new URIBuilder(serverConfig.getAuthorizationEndpointUri()); | ||
uriBuilder.addParameter("response_type", "code"); | ||
uriBuilder.addParameter("client_id", clientConfig.getClientId()); | ||
|
||
if (options.get("scope") != null) { | ||
uriBuilder.addParameter("scope", options.get("scope")); | ||
} else { | ||
uriBuilder.addParameter("scope", Joiner.on(" ").join(clientConfig.getScope())); | ||
} | ||
|
||
|
||
uriBuilder.addParameter("redirect_uri", redirectUri); | ||
|
||
uriBuilder.addParameter("nonce", nonce); | ||
|
||
uriBuilder.addParameter("state", state); | ||
|
||
// Optional parameters: | ||
for (Entry<String, String> option : options.entrySet()) { | ||
uriBuilder.addParameter(option.getKey(), option.getValue()); | ||
} | ||
|
||
// if there's a login hint, send it | ||
if (!Strings.isNullOrEmpty(loginHint)) { | ||
uriBuilder.addParameter("login_hint", loginHint); | ||
} | ||
|
||
return uriBuilder.build().toString(); | ||
|
||
} catch (URISyntaxException e) { | ||
throw new AuthenticationServiceException("Malformed Authorization Endpoint Uri", e); | ||
|
||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.