L'infrastructure préfabriquée de connexion unique de Build Forge® permet l'intégration avec un grand nombre de solutions de connexion unique disponibles sur le marché. Elle est basée sur un intercepteur, ce qui signifie qu'elle intercepte une requête HTTP et fournit des méthodes pour la gérer. Vous pouvez écrire des intercepteurs personnalisés pour recevoir et valider des artefacts de sécurité dans la requête HTTP. Les intercepteurs peuvent en particulier définir des jetons dans la réponse HTTP puis les rechercher dans une requête ultérieure.
Deux solutions de connexion unique sont fournies avec Build Forge® :
com.buildforge.services.server.sso.ISSOInterceptor
Il se trouve dans le composant de couche de services :<rép_install_bf>/Apache/tomcat/webapps/jas/WEB-INF/eclipse/plugins/com.ibm.jas-1.0.jar
L'interface fournit les méthodes suivantes.
Les configurations d'intercepteur sont définies dans Build Forge® :
. Les configurations suivantes sont fournies avecAprès avoir implémenté une classe d'intercepteur et l'avoir placée sur le serveur d'applications Apache Tomcat de Build Forge®, vous configurez une nouvelle configuration de connexion unique ici. La classe est une propriété de la configuration de connexion unique.
L'ordre de cette liste détermine celui de la consultation des intercepteurs pour traiter les requêtes. Vous pouvez configurer plusieurs intercepteurs pour traiter les requêtes. Au cours d'une connexion, chaque intercepteur est consulté dans l'ordre. L'intercepteur qui traite la requête est le premier intercepteur actif dont les attributs sont appropriés pour les attributs de la requête. Un seul intercepteur traite la requête. Il s'agit toujours du premier intercepteur qui répond true pour isTargetInterceptor.
Pour créer un intercepteur personnalisé dans Build Forge®, procédez comme suit :
Elle doit implémenter l'interface ISSOInterceptor.
Pendant une requête, l'accès aux configurations de connexion unique actives est effectué dans l'ordre dans lequel elles apparaissent sur ce panneau. Etant donné qu'elle est active par défaut et qu'elle renvoie systématiquement true lorsque vous y accédez, votre configuration doit être placée avant la configuration Form SSO. La configuration SPNEGO SSO est inactive par défaut.
L'exemple ci-dessous est extrait de l'intercepteur de connexion unique WebSphere, utilisé pour intégrer la sécurité WebSphere Application Server à Build Forge®.
L'intercepteur utilise le reflet pour trouver la classe WebSphere WSSubject. La classe a une méthode getCallerPrincipal permettant de renvoyer le principal utilisé pour la connexion à AuthServlet. AuthServlet doit être protégé avant que WebSphere Application Server ne s'authentifie auprès de lui.
D'autres méthodes pouvant renvoyer encore plus d'informations sont disponibles. Des méthodes similaires sont disponibles pour travailler avec le serveur d'applications.
public Result authenticateRequest
(Request requestAttributes, Response responseAttributes)
throws SSOException {
Result result = null;
try {
Class<?> cl =
Class.forName(“com.ibm.websphere.security.auth.WSSubject”);
Method theMethod = cl.getMethod("getCallerPrincipal",
(Class[])null);
String principal = (String)theMethod.invoke((Object[])null,
(Object[])null);
if (principal != null
&& principal.length() > 0
&& !principal.equals("UNAUTHENTICATED")) {
result = new Result(Result.UseridOnlyOID, domain, principal);
responseAttributes.setStatus(HttpServletResponse.SC_OK);
} catch (Exception e) {
throw new SSOException(e);
}
return result;
}
Pendant l'implémentation de authenticateRequest, vous devez définir un état de réponse avant le renvoi :
responseAttributes.setStatus(HttpServletResponse.SC_OK);
responseAttributes.setStatus(HttpServletResponse,SC_FORBIDDEN);
responseAttributes.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
responseAttributes.sendRedirecct(url);
Il existe des valeurs d'état supplémentaires qui peuvent être utilisées. Voir le JavaDoc pour HttpServletResponse.
Si votre intercepteur personnalisé ne fonctionne pas correctement lors du test, le problème le plus probable est lié à l'authentification. Une page d'erreur s'affiche avec les informations suivantes :
Erreur Build Forge
Accès à la console Build Forge refusé
"Error authenticating:
com.buildforge.services.common.api.APIException - API:
Authentication Error."
Cliquez ici pour réessayer le même type de connexion
ou ici pour forcer une connexion de formulaire (ID utilisateur/mot de passe).
Vous avez deux options de reprise :
Les commentaires et listes de sources suivants fournissent plus d'informations sur les méthodes de l'interface ISSOInterceptor.
initInterceptor
/**
* This method is called when the interceptor is loaded. A map of the
configuration properties is passed into the init method. You can create
the configuration properties from a BuildForge Environment and associate
it with the SSO configuration.
*
* @param initializationProps used to configure the implementation
* @return true if successful, false if an error should be reported.
* @throws SSOException if the initialization fails
**/
public boolean initInterceptor (Properties initializationProps) throws SSOException;
isTargetInterceptor
/**
* This methods will review the attributes in the requestAttributes Map
to determine if there is something that this interceptor should
act on. If the interceptor return is "true", then the interceptor will
be responsible for authenticating the request and the authenticateRequest
method is invoked. If the interceptor return is "false", then this
interceptor is skipped and the next isTargetInterceptor in the list will
be called. Ordering of the interceptors during the configuration will
return which interceptor has the first shot at authenticating a request.
*
* @param requestAttributes attributes found in the inbound request
* @return true if this interceptor will authenticate the request,
false if it will not.
* @throws SSOException
*
**/
public boolean isTargetInterceptor(Request requestAttributes) throws SSOException;
authenticateRequest
/**
* This method is called on an interceptor that returns true for the
isTargetInterceptor method. The Request will contain data used
to perform the authentication. The Response is for the interceptor
to send information back to the client. The Result returned will contain
the following information if the status code is 200:
*
* OID: an object identifier of the SecurityContext that can process token
information stored in this map when going to an Agent.
* Domain: a valid BF domain name or <default> if not known
(the username must be valid in the configured realm).
* Username: a valid BF username. This will be used to lookup BFUser attributes
that are used in checking authorization policy.
* @see com.buildforge.services.common.security.context.Result
*
* @param requestAttributes attributes found in the inbound request
* @param responseAttributes sent back in the outbound response
* @return com.buildforge.services.common.security.context.Result - result
information that tells BF how to handle the authentication request.
* @throws com.buildforge.services.server.sso.SSOException
**/
public Result authenticateRequest(
Request requestAttributes,
Response responseAttributes)
throws SSOException;
logoutRequest
/**
* This method is called to logout a request. The first interceptor that
returns true for the isTargetInterceptor method will perform the logout.
The main point is to clean up any user-related security information that
should not be kept. The interceptor can inspect the request and response
objects to determine what needs to be removed.
*
* @param requestAttributes attributes found in the inbound request
* @param responseAttributes sent back in the outbound response
* @return boolean - true if request redirect to exit page,
false if redirect to login page.
* @throws com.buildforge.services.server.sso.SSOException
**/
public boolean logoutRequest(
Request requestAttributes,
Response responseAttributes)
throws SSOException;