Manuel de l’authentification unique Apple (hérité) (API REST V1) apple-sso-cookbook-rest-api-v1
L’API REST d’authentification Adobe Pass V1 prend en charge l’authentification unique (SSO) du partenaire pour les utilisateurs finaux des applications clientes s’exécutant sur iOS, iPadOS ou tvOS.
Ce document agit comme une extension de la documentation existante de l’API REST V1, qui se trouve ici.
Livre de cuisine apple-sso-cookbook-rest-api-v1-cookbook
Pour bénéficier de l’expérience utilisateur de l’authentification unique d’Apple, l’application doit intégrer le framework de compte d’abonné vidéo développé par Apple, tandis que pour la communication de l’API REST d’authentification Adobe Pass V1, elle doit suivre la séquence d’étapes présentée ci-dessous.
Autorisation apple-sso-cookbook-rest-api-v1-permission
Settings -> TV Provider
sur iOS et iPadOS ou Settings -> Accounts -> TV Provider
sur tvOS.Authentification apple-sso-cookbook-rest-api-v1-authentication
- Existe-t-il un jeton d’authentification d’Adobe valide ?
- L’utilisateur est-il connecté via l’authentification unique du partenaire ?
- Récupérer la configuration de l’Adobe
- Lancement du workflow SSO du partenaire avec la configuration d’Adobe
- La connexion de l’utilisateur a-t-elle réussi ?
- Obtenir une requête de profil de l’Adobe pour le MVPD sélectionné
- Transférer la demande d’Adobe au SSO du partenaire pour obtenir le profil
- Exchange du profil SSO du partenaire pour un jeton d’authentification Adobe
- Le jeton d’Adobe est-il généré avec succès ?
- Lancement du workflow d’authentification standard
- Poursuivre les flux d’autorisation
Étape : « Existe-t-il un jeton d’authentification d’Adobe valide ? » step1
Étape : « L’utilisateur est-il connecté via l’authentification unique du partenaire ? » step2
- L’application doit vérifier la autorisation d’accès les informations d’abonnement de l’utilisateur et continuer uniquement si l’utilisateur l’autorise.
- La demande devrait présenter une demande pour obtenir des renseignements sur le compte de l'abonné.
- L’application doit attendre et traiter les informations métadonnées.
...
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 Partner 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:
// Continue with the "Initiate regular authentication workflow" step.
...
}
}
...
Étape : « Récupérer la configuration de l’Adobe » step3
enablePlatformServices
, boardingStatus
, displayInPlatformPicker
, platformMappingId
, requiredMetadataFields
et prêtez une attention particulière aux commentaires présentés dans les fragments de code provenant d'autres étapes.Étape « Lancer le workflow SSO du partenaire avec la configuration d’Adobe » step4
- L’application doit vérifier la autorisation d’accès les informations d’abonnement de l’utilisateur et continuer uniquement si l’utilisateur l’autorise.
- L’application doit fournir un délégué pour VSAccountManager.
- La demande devrait présenter une demande pour obtenir des renseignements sur le compte de l'abonné.
- L’application doit attendre et traiter les informations métadonnées.
...
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](/docs/pass/authentication/provide-mvpd-list.md) 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](/docs/pass/authentication/provide-mvpd-list.md) 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 Partner 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 regular authentication 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 regular authentication workflow" step.
...
}
} else {
// Continue with the "Initiate regular authentication workflow" step.
...
}
} else {
// Continue with the "Initiate regular authentication workflow" step.
...
}
}
}
// The user has not yet made a choice or does not allow the application to access subscription information.
default:
// Continue with the "Initiate regular authentication workflow" step.
...
}
}
...
Étape : « La connexion de l’utilisateur a-t-elle réussi ? » step5
vsaMetadata!.accountProviderIdentifier
contient une valeur valide et que la date actuelle n’a pas transmis la valeur vsaMetadata!.authenticationExpirationDate
.Étape « Obtenir une requête de profil de l’Adobe pour le MVPD sélectionné » step6
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’API Authentification Adobe Pass Fournir une liste MVPD.Étape : « Transférer la demande d’Adobe au SSO du partenaire pour obtenir le profil » step7
- L’application doit vérifier la autorisation d’accès les informations d’abonnement de l’utilisateur et continuer uniquement si l’utilisateur l’autorise.
- La demande devrait présenter une demande pour obtenir des renseignements sur le compte de l'abonné.
- L’application doit attendre et traiter les informations métadonnées.
...
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](/docs/pass/authentication/provide-mvpd-list.md) 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](/docs/pass/authentication/retrieve-profilerequest.md) 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 Partner SSO profile for an Adobe authentication token" step.
...
} else {
// Continue with the "Initiate regular authentication workflow" step.
...
}
}
// The user has not yet made a choice or does not allow the application to access subscription information.
default:
// Continue with the "Initiate regular authentication workflow" step.
...
}
}
...
Étape : « Exchange du profil SSO du partenaire pour un jeton d’authentification Adobe » step8
vsaMetadata!.samlAttributeQueryResponse!
représente le SAMLResponse
, qui doit être transmis sur Exchange du jeton et nécessite une manipulation et un codage de chaîne (codés en Base64 et en URL codés par la suite) avant d’effectuer l’appel.Étape : « Le jeton d’Adobe a-t-il été généré avec succès ? » step9
204 No Content
, indiquant que le jeton a été créé avec succès et est prêt à être utilisé pour les flux d’autorisation.Étape : « Lancer le workflow d’authentification standard » step10
- L'application devrait obtenir un code d'enregistrement et le présenter à l'utilisateur final sur le 1er appareil (écran).
- L’application doit lancer l’interrogation pour confirmer l’état d’authentification sur le premier appareil (écran) après l’obtention du code d’enregistrement.
- Une autre application devrait initier l’authentification sur un deuxième appareil (écran) lorsque le code d’enregistrement est utilisé.
- L’application doit arrêter l’interrogation sur le premier appareil (écran) lorsque le jeton d’authentification est généré.
- L'application devrait obtenir un code d'enregistrement qui ne devrait pas être présenté à l'utilisateur final sur le 1er 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 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 l’interrogation sur le premier appareil (écran) lorsque le jeton d’authentification est généré.
Étape : « Poursuivre les flux d’autorisation » step11
Déconnexion apple-sso-cookbook-rest-api-v1-logout
Le framework de compte d’abonné vidéo ne fournit pas d’API pour déconnecter par programmation les personnes qui se sont connectées au compte de leur fournisseur de télévision au niveau du système de l’appareil. Par conséquent, pour que la déconnexion prenne pleinement effet, l’utilisateur final doit se déconnecter explicitement d’Settings -> TV Provider
sur iOS/iPadOS ou Settings -> Accounts -> TV Provider
sur tvOS. L'autre option dont dispose l'utilisateur est de retirer son autorisation d'accès aux informations d'abonnement de l'utilisateur à partir de la section de paramétrage de l'application spécifique (accès au fournisseur de télévision).
- L’application doit déterminer si l’authentification a eu lieu suite à une connexion par le biais de l’authentification unique du partenaire, à l’aide de la « tokenSource » métadonnées de l’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 au cas où la valeur « tokenSource » est égale à « Apple ». - L’application doit initier la déconnexion à partir du service d’authentification Adobe Pass à l’aide d’un appel HTTP direct. Cela ne facilite pas le nettoyage de la session côté MVPD.
- L’application doit déterminer si l’authentification a eu lieu suite à une connexion par le biais de l’authentification unique du partenaire, à l’aide de la « tokenSource » métadonnées de l’utilisateur du service d’authentification Adobe Pass.
- L’application doit demander à l’utilisateur de se déconnecter explicitement d’
Settings -> TV Provider
sur iOS/iPadOS uniquement au cas où la valeur « tokenSource » est égale à « Apple ». - L’application doit initier la déconnexion à partir du service d’authentification Adobe Pass à l’aide d’un composant WKWebView ou SFSafariViewController. Cela facilite le nettoyage de la session côté MVPD.