Guide pas à pas Apple SSO (API REST) apple-sso-cookbook-rest-api
Introduction Introduction
L’API REST d’authentification Adobe Pass peut prendre en charge l’authentification SSO (Single Sign-On) par plateforme pour les utilisateurs finaux des applications clientes s’exécutant sur iOS, iPadOS ou tvOS via ce que nous appelons le processus SSO Apple.
Veuillez noter que ce document agit comme une extension de la documentation de l'API REST existante, qui se trouve ici.
Cookbooks Cookbooks
Pour bénéficier de l’expérience utilisateur de l’authentification unique Apple, une application doit intégrer le framework Compte d’abonné vidéo développé par Apple, tout en ce qui concerne la communication de l’API REST d’authentification Adobe Pass, elle doit suivre la séquence de conseils présentée ci-dessous.
Authentification Authentication
- Existe-t-il un jeton d’authentification d’Adobe valide ?
- L’utilisateur est-il connecté via la connexion unique à Platform ?
- Récupérer la configuration des Adobes
- Lancement du processus d’authentification unique de Platform avec configuration d’Adobe
- La connexion de l’utilisateur est-elle réussie ?
- Obtenir une requête de profil de l’Adobe pour le MVPD sélectionné
- Transférez la demande d’Adobe à Platform SSO pour obtenir le profil.
- Exchange du profil d’authentification unique de Platform pour un jeton d’authentification d’Adobe
- Le jeton d’Adobe est-il généré correctement ?
- Lancement du processus d’authentification du deuxième écran
- Poursuivre avec les flux d’autorisation
Étape : "Existe-t-il un jeton d’authentification d’Adobe valide ?" Is_there_a_valid_Adobe_authentication_token
Étape : "L’utilisateur est-il connecté via la connexion unique à Platform ?" Is_the_user_logged_in_via_Platform_SSO
- L’application doit rechercher l’autorisation d’accéder aux informations d’abonnement de l’utilisateuret procéder uniquement si l’utilisateur l’a autorisée.
- L’application doit envoyer une requête pour les informations de compte d’abonné.
- L’application doit attendre et traiter les informations metadata.
...
let videoSubscriberAccountManager: VSAccountManager = VSAccountManager();
videoSubscriberAccountManager.checkAccessStatus(options: [VSCheckAccessOption.prompt: true]) { (accessStatus, error) -> Void in
switch (accessStatus) {
// The user allows the application to access subscription information.
case VSAccountAccessStatus.granted:
// Construct the request for subscriber account information.
let vsaMetadataRequest: VSAccountMetadataRequest = VSAccountMetadataRequest();
// This is actually the SAML Issuer not the channel ID.
vsaMetadataRequest.channelIdentifier = "https://saml.sp.auth.adobe.com";
// This is the subscription account information needed at this step.
vsaMetadataRequest.includeAccountProviderIdentifier = true;
// This is the subscription account information needed at this step.
vsaMetadataRequest.includeAuthenticationExpirationDate = true;
// This is going to make the Video Subscriber Account framework to refrain from prompting the user with the providers picker at this step.
vsaMetadataRequest.isInterruptionAllowed = false;
// Submit the request for subscriber account information - accountProviderIdentifier.
videoSubscriberAccountManager.enqueue(vsaMetadataRequest) { vsaMetadata, vsaError in
if (vsaMetadata != nil && vsaMetadata!.accountProviderIdentifier != nil) {
// The vsaMetadata!.authenticationExpirationDate will contain the expiration date for current authentication session.
// The vsaMetadata!.authenticationExpirationDate should be compared against current date.
...
// The vsaMetadata!.accountProviderIdentifier will contain the provider identifier as it is known for the platform configuration.
// The vsaMetadata!.accountProviderIdentifier represents the platformMappingId in terms of Adobe Pass Authentication configuration.
...
// The application must determine the MVPD id property value based on the platformMappingId property value obtained above.
// The application must use the MVPD id further in its communication with Adobe Pass Authentication services.
...
// Continue with the "Obtain a profile request from Adobe for the selected MVPD" step.
...
// Continue with the "Forward the Adobe request to Platform SSO to obtain the profile" step.
...
} else {
// The user is not authenticated at platform level, continue with the "Fetch Adobe configuration" step.
...
}
}
// The user has not yet made a choice or does not allow the application to access subscription information.
default:
// Fallback to regular authentication workflow.
...
}
}
...
Étape : "Récupérer la configuration des Adobes" Fetch_Adobe_configuration
enablePlatformServices
, boardingStatus
, displayInPlatformPicker
, platformMappingId
, requiredMetadataFields
et prêtez une attention particulière aux commentaires présentés dans les fragments de code d’autres étapes.Étape "Lancement du workflow SSO Platform avec configuration Adobe" Initiate_Platform_SSO_workflow_with_Adobe_config
- L’application doit rechercher l’autorisation d’accéder aux informations d’abonnement de l’utilisateuret procéder uniquement si l’utilisateur l’a autorisée.
- L’application doit fournir un délégué pour VSAccountManager.
- L’application doit envoyer une requête pour les informations de compte d’abonné.
- L’application doit attendre et traiter les informations metadata.
...
let videoSubscriberAccountManager: VSAccountManager = VSAccountManager();
// This must be a class implementing the VSAccountManagerDelegate protocol.
let videoSubscriberAccountManagerDelegate: VideoSubscriberAccountManagerDelegate = VideoSubscriberAccountManagerDelegate();
videoSubscriberAccountManager.delegate = videoSubscriberAccountManagerDelegate;
videoSubscriberAccountManager.checkAccessStatus(options: [VSCheckAccessOption.prompt: true]) { (accessStatus, error) -> Void in
switch (accessStatus) {
// The user allows the application to access subscription information.
case VSAccountAccessStatus.granted:
// Construct the request for subscriber account information.
let vsaMetadataRequest: VSAccountMetadataRequest = VSAccountMetadataRequest();
// This is actually the SAML Issuer not the channel ID.
vsaMetadataRequest.channelIdentifier = "https://saml.sp.auth.adobe.com";
// This is the subscription account information needed at this step.
vsaMetadataRequest.includeAccountProviderIdentifier = true;
// This is the subscription account information needed at this step.
vsaMetadataRequest.includeAuthenticationExpirationDate = true;
// This is going to make the Video Subscriber Account framework to prompt the user with the providers picker at this step.
vsaMetadataRequest.isInterruptionAllowed = true;
// This can be computed from the [Adobe Pass Authentication](https://experienceleague.adobe.com/docs/pass/authentication/programmer-integration-guide/restapi/rest-api-reference/provide-mvpd-list.html?lang=fr) service response in order to filter the TV providers from the Apple picker.
vsaMetadataRequest.supportedAccountProviderIdentifiers = supportedAccountProviderIdentifiers;
// This can be computed from the [Adobe Pass Authentication](https://experienceleague.adobe.com/docs/pass/authentication/programmer-integration-guide/restapi/rest-api-reference/provide-mvpd-list.html?lang=fr) service response in order to sort the TV providers from the Apple picker.
if #available(iOS 11.0, tvOS 11, *) {
vsaMetadataRequest.featuredAccountProviderIdentifiers = featuredAccountProviderIdentifiers;
}
// Submit the request for subscriber account information - accountProviderIdentifier.
videoSubscriberAccountManager.enqueue(vsaMetadataRequest) { vsaMetadata, vsaError in
// This represents the checks for the "Is user login successful?" step.
if (vsaMetadata != nil && vsaMetadata!.accountProviderIdentifier != nil) {
// The vsaMetadata!.authenticationExpirationDate will contain the expiration date for current authentication session.
// The vsaMetadata!.authenticationExpirationDate should be compared against current date.
...
// The vsaMetadata!.accountProviderIdentifier will contain the provider identifier as it is known for the platform configuration.
// The vsaMetadata!.accountProviderIdentifier represents the platformMappingId in terms of Adobe Pass Authentication configuration.
...
// The application must determine the MVPD id property value based on the platformMappingId property value obtained above.
// The application must use the MVPD id further in its communication with Adobe Pass Authentication services.
...
// Continue with the "Obtain a profile request from Adobe for the selected MVPD" step.
...
// Continue with the "Forward the Adobe request to Platform SSO to obtain the profile" step.
...
} else {
// The user is not authenticated at platform level.
if (vsaError != nil) {
// The application can check to see if the user selected a provider which is present in Apple picker, but the provider is not onboarded in platform SSO.
if let error: NSError = (vsaError! as NSError), error.code == 1, let appleMsoId = error.userInfo["VSErrorInfoKeyUnsupportedProviderIdentifier"] as! String? {
var mvpd: Mvpd? = nil;
// The requestor.mvpds must be computed during the "Fetch Adobe configuration" step.
for provider in requestor.mvpds {
if provider.platformMappingId == appleMsoId {
mvpd = provider;
break;
}
}
if mvpd != nil {
// Continue with the "Initiate second screen authentcation workflow" step, but you can skip prompting the user with your MVPD picker and use the mvpd selection, therefore creating a better UX.
...
} else {
// Continue with the "Initiate second screen authentcation workflow" step.
...
}
} else {
// Continue with the "Initiate second screen authentcation workflow" step.
...
}
} else {
// Continue with the "Initiate second screen authentcation workflow" step.
...
}
}
}
// The user has not yet made a choice or does not allow the application to access subscription information.
default:
// Fallback to regular authentication workflow.
...
}
}
...
Étape : "La connexion de l’utilisateur est-elle réussie ?" Is_user_login_successful
vsaMetadata!.accountProviderIdentifier
contient une valeur valide et que la date actuelle n’a pas dépassé la valeur vsaMetadata!.authenticationExpirationDate
.Étape "Obtention d’une requête de profil de l’Adobe pour le MVPD sélectionné" Obtain_a_profile_request_from_Adobe_for_the_selected_MVPD
platformMappingId
en termes de configuration de l’authentification Adobe Pass. Par conséquent, l’application doit déterminer la valeur de la propriété d’identifiant MVPD, à l’aide de la valeur platformMappingId
, par le biais du service d’authentification Adobe Pass Fournir une liste MVPD.Étape : "Transfert de la demande d’Adobe vers Platform SSO pour obtenir le profil" Forward_the_Adobe_request_to_Platform_SSO_to_obtain_the_profile
- L’application doit rechercher l’autorisation d’accéder aux informations d’abonnement de l’utilisateuret procéder uniquement si l’utilisateur l’a autorisée.
- L’application doit envoyer une requête pour les informations de compte d’abonné.
- L’application doit attendre et traiter les informations metadata.
...
let videoSubscriberAccountManager: VSAccountManager = VSAccountManager();
videoSubscriberAccountManager.checkAccessStatus(options: [VSCheckAccessOption.prompt: true]) { (accessStatus, error) -> Void in
switch (accessStatus) {
// The user allows the application to access subscription information.
case VSAccountAccessStatus.granted:
// Construct the request for subscriber account information.
let vsaMetadataRequest: VSAccountMetadataRequest = VSAccountMetadataRequest();
// This is actually the SAML Issuer not the channel ID.
vsaMetadataRequest.channelIdentifier = "https://saml.sp.auth.adobe.com";
// This is going to include subscription account information which should match the provider determined in a previous step.
vsaMetadataRequest.includeAccountProviderIdentifier = true;
// This is going to include subscription account information which should match the provider determined in a previous step.
vsaMetadataRequest.includeAuthenticationExpirationDate = true;
// This is going to make the Video Subscriber Account framework to refrain from prompting the user with the providers picker at this step.
vsaMetadataRequest.isInterruptionAllowed = false;
// This are the user metadata fields expected to be available on a successful login and are determined from the [Adobe Pass Authentication](https://experienceleague.adobe.com/docs/pass/authentication/programmer-integration-guide/restapi/rest-api-reference/provide-mvpd-list.html?lang=fr) service. Look for the requiredMetadataFields associated with the provider determined in a previous step.
vsaMetadataRequest.attributeNames = requiredMetadataFields;
// This is the payload from [Adobe Pass Authentication](https://experienceleague.adobe.com/docs/pass/authentication/programmer-integration-guide/restapi/rest-api-reference/retrieve-profilerequest.html?lang=fr) service.
vsaMetadataRequest.verificationToken = profileRequestPayload;
// Submit the request for subscriber account information.
videoSubscriberAccountManager.enqueue(vsaMetadataRequest) { vsaMetadata, vsaError in
if (vsaMetadata != nil && vsaMetadata!.samlAttributeQueryResponse != nil) {
var samlResponse: String? = vsaMetadata!.samlAttributeQueryResponse!;
// Remove new lines, new tabs and spaces.
samlResponse = samlResponse?.replacingOccurrences(of: "[ \\t]+", with: " ", options: String.CompareOptions.regularExpression);
samlResponse = samlResponse?.components(separatedBy: CharacterSet.newlines).joined(separator: "");
samlResponse = samlResponse?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines);
// Base64 encode.
samlResponse = samlResponse?.data(using: .utf8)?.base64EncodedString(options: []);
// URL encode. Please be aware not to double URL encode it further.
samlResponse = samlResponse?.addingPercentEncoding(withAllowedCharacters: CharacterSet.init(charactersIn: "!*'();:@&=+$,/?%#[]").inverted);
// Continue with the "Exchange the Platform SSO profile for an Adobe authentication token" step.
...
} else {
// Fallback to regular authentication workflow.
...
}
}
// The user has not yet made a choice or does not allow the application to access subscription information.
default:
// Fallback to regular authentication workflow.
...
}
}
...
Étape : "Exchange du profil d’authentification unique de Platform pour un jeton d’authentification d’Adobe" Exchange_the_Platform_SSO_profile_for_an_Adobe_authentication_token
vsaMetadata!.samlAttributeQueryResponse!
représente le SAMLResponse
, qui doit être transmis sur Exchange de jeton et qui nécessite une manipulation et un codage de chaîne (Base64 codé et URL encodé par la suite) avant d’effectuer l’appel.Étape : "Le jeton d’Adobe est-il généré avec succès ?" Is_Adobe_token_generated_successfully
204 No Content
, indiquant que le jeton a été créé avec succès et qu’il est prêt à être utilisé pour les flux d’autorisation.Étape : "Lancement du deuxième workflow d’authentification d’écran" Initiate_second_screen_authentication_workflow
Important : La terminologie "Processus d’authentification du deuxième écran" est appropriée pour les Apple TV, tandis que la terminologie "Processus d’authentification du premier écran" / "Processus d’authentification régulier" serait plus appropriée pour les iPhone et les iPad.
Demande de code d’enregistrement, Lancer l’authentification et API REST Récupérer le jeton d’authentification ou les services Vérifier le jeton d’authentification.
- L’application doit obtenir un code d’enregistrement et le présenter à l’utilisateur final sur le premier appareil (écran).
- L’application doit démarrer polling pour reconnaître l’état d’authentification sur le 1er appareil (écran) après l’obtention du code d’enregistrement.
- Une autre application doit lancer l’authentification sur un 2e appareil (écran) lorsque le code d’enregistrement est utilisé.
- L’application doit arrêter polling sur le 1er appareil (écran) lorsque le jeton d’authentification est généré.
- L’application doit obtenir un code d’enregistrement qui ne doit pas être présenté à l’utilisateur final sur le premier appareil (écran).
- L’application doit lancer l’authentification sur le premier appareil (écran) à l’aide du code d’enregistrement et d’un composant WKWebView ou SFSafariViewController.
- L’application doit démarrer l’interrogation pour connaître l’état d’authentification sur le premier appareil (écran) après la fermeture du composant WKWebView ou SFSafariViewController.
- L’application doit arrêter polling sur le 1er appareil (écran) lorsque le jeton d’authentification est généré.
Étape : "Poursuivre avec les flux d’autorisation" Proceed_with_authorization_flows
Déconnexion Logout
La structure du compte d’abonné vidéone fournit pas d’API pour déconnecter par programmation les personnes qui se sont connectées à leur compte de fournisseur de télévision au niveau du système de l’appareil. Par conséquent, pour que la déconnexion entre en vigueur, l’utilisateur final doit se déconnecter explicitement de Settings -> TV Provider
sur iOS/iPadOS ou Settings -> Accounts -> TV Provider
sur tvOS. L’autre option dont dispose l’utilisateur consiste à retirer l’autorisation d’accéder aux informations d’abonnement de l’utilisateur dans la section des paramètres de l’application spécifique (accès au fournisseur de télévision).
- L’application doit déterminer si l’authentification s’est produite suite à une connexion par le biais de la plateforme SSO ou non, à l’aide des "tokenSource" métadonnées utilisateur du service d’authentification Adobe Pass.
- L’application doit demander à l’utilisateur de se déconnecter explicitement de
Settings -> Accounts -> TV Provider
sur tvOS uniquement si la valeur "tokenSource" est égale à "Apple". - L’application doit lancer la déconnexion à partir du service d’authentification Adobe Pass à l’aide d’un appel HTTP direct. Cela ne faciliterait pas le nettoyage de session du côté MVPD.
- L’application doit déterminer si l’authentification s’est produite suite à une connexion par le biais de la plateforme SSO ou non, à l’aide des "tokenSource" métadonnées utilisateur du service d’authentification Adobe Pass.
- L’application doit demander à l’utilisateur de se déconnecter explicitement de
Settings -> TV Provider
sur iOS/iPadOS uniquement si la valeur "tokenSource" est égale à "Apple". - L’application doit lancer la déconnexion à partir du service d’authentification Adobe Pass à l’aide d’un composant WKWebView ou SFSafariViewController. Cela faciliterait le nettoyage de session du côté MVPD.