Apple SSO-Cookbook (REST-API) apple-sso-cookbook-rest-api
Einführung Introduction
Die Adobe Pass Authentication REST-API kann die SSO-Authentifizierung (Platform Single Sign-On) für Endbenutzer von Clientanwendungen unterstützen, die auf iOS, iPadOS oder tvOS ausgeführt werden. Dies erfolgt über den so genannten Apple SSO-Workflow.
Bitte beachten Sie, dass dieses Dokument als Erweiterung der vorhandenen REST-API-Dokumentation dient, die Sie hier finden here.
Cookbooks Cookbooks
Um das Apple SSO-Benutzererlebnis nutzen zu können, muss eine Anwendung die Video-Abonnentenkonto -Framework, das von Apple entwickelt wurde, während es hinsichtlich der Adobe Pass Authentication REST API-Kommunikation die unten dargestellte Tippsequenz befolgen muss.
Authentifizierung Authentication
- Gibt es ein gültiges Adobe-Authentifizierungstoken?
- Ist der Benutzer über Platform SSO angemeldet?
- Adobe-Konfiguration abrufen
- Starten des Platform SSO-Workflows mit der Adobe-Konfiguration
- Ist die Benutzeranmeldung erfolgreich?
- Abrufen einer Profilanfrage von Adobe für das ausgewählte MVPD
- Weiterleiten der Adobe-Anfrage an Platform SSO zum Abrufen des Profils
- Platform SSO-Profil für ein Adobe-Authentifizierungstoken austauschen
- Wird Adobe-Token erfolgreich generiert?
- Workflow für die Authentifizierung im zweiten Bildschirm starten
- Fahren Sie mit den Autorisierungsabläufen fort.
Schritt: "Gibt es ein gültiges Adobe-Authentifizierungstoken?" Is_there_a_valid_Adobe_authentication_token
Schritt: "Ist der Benutzer über Platform SSO angemeldet?" Is_the_user_logged_in_via_Platform_SSO
- Der Antrag müsste auf Zugriffsberechtigung die Abonnementinformationen des Benutzers ein und wird nur fortgesetzt, wenn der Benutzer dies erlaubt hat.
- Der Antrag müsste eine Anfrage für Informationen zum Konto des Abonnenten.
- Die Anwendung müsste warten und die Metadaten Informationen.
...
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.
...
}
}
...
Schritt: "Adobe-Konfiguration abrufen" Fetch_Adobe_configuration
enablePlatformServices
, boardingStatus
, displayInPlatformPicker
, platformMappingId
, requiredMetadataFields
und achten Sie besonders auf die Kommentare, die in Code-Snippets aus anderen Schritten vorgestellt werden.Schritt "Starten des Platform SSO-Workflows mit Adobe config" Initiate_Platform_SSO_workflow_with_Adobe_config
- Der Antrag müsste auf Zugriffsberechtigung die Abonnementinformationen des Benutzers ein und wird nur fortgesetzt, wenn der Benutzer dies erlaubt hat.
- Der Antrag müsste eine delegate für den VSAccountManager.
- Der Antrag müsste eine Anfrage für Informationen zum Konto des Abonnenten.
- Die Anwendung müsste warten und die Metadaten Informationen.
...
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=de) 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=de) 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.
...
}
}
...
Schritt: "Ist die Benutzeranmeldung erfolgreich?" Is_user_login_successful
vsaMetadata!.accountProviderIdentifier
einen gültigen Wert enthält und das aktuelle Datum nicht über die vsaMetadata!.authenticationExpirationDate
-Wert.Schritt "Abrufen einer Profilanfrage von Adobe für den ausgewählten MVPD" Obtain_a_profile_request_from_Adobe_for_the_selected_MVPD
platformMappingId
in Bezug auf die Adobe Pass-Authentifizierungskonfiguration. Daher muss die Anwendung den Wert der MVPD ID-Eigenschaft mithilfe der platformMappingId
-Wert über das Medium Adobe Pass-Authentifizierung MVPD-Liste bereitstellen -Dienst.Schritt: "Weiterleiten der Adobe-Anfrage an Platform SSO zum Abrufen des Profils" Forward_the_Adobe_request_to_Platform_SSO_to_obtain_the_profile
- Der Antrag müsste auf Zugriffsberechtigung die Abonnementinformationen des Benutzers ein und wird nur fortgesetzt, wenn der Benutzer dies erlaubt hat.
- Der Antrag müsste eine Anfrage für Informationen zum Konto des Abonnenten.
- Die Anwendung müsste warten und die Metadaten Informationen.
...
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=de) 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=de) 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.
...
}
}
...
Schritt: "Ersetzen des Platform SSO-Profils durch ein Adobe-Authentifizierungstoken" Exchange_the_Platform_SSO_profile_for_an_Adobe_authentication_token
vsaMetadata!.samlAttributeQueryResponse!
steht für SAMLResponse
, die weitergegeben werden muss Token Exchange und erfordert Zeichenfolgenbearbeitung und -kodierung (Base64 kodiert und URL codiert danach), bevor der Aufruf erfolgt.Schritt: "Wird das Adobe-Token erfolgreich generiert?" Is_Adobe_token_generated_successfully
204 No Content
, der angibt, dass das Token erfolgreich erstellt wurde und für die Autorisierungsflüsse verwendet werden kann.Schritt: "Workflow für die Authentifizierung am zweiten Bildschirm starten" Initiate_second_screen_authentication_workflow
Wichtig: Die Terminologie "Zweiter Workflow für die Bildschirmauthentifizierung"eignet sich für AppleTV, während die Terminologie "Workflow für die erste Bildschirmauthentifizierung"/ "Workflow für die regelmäßige Authentifizierung" für iPhones und iPads besser geeignet wäre.
Registrierungs-Code-Anfrage, Authentifizierung initiieren und REST API-Authentifizierungstoken abrufen oder Authentifizierungstoken überprüfen Dienste.
- Der Antrag müsste Registrierungscode abrufen und präsentieren sie dem Endbenutzer auf dem ersten Gerät (Bildschirm).
- Die Anwendung müsste beginnen Abfrage zur Bestätigung des Authentifizierungsstatus auf dem ersten Gerät (Bildschirm), nachdem der Registrierungs-Code abgerufen wurde.
- Eine andere Anwendung müsste Authentifizierung initiieren auf einem zweiten Gerät (Bildschirm), wenn der Registrierungs-Code verwendet wird.
- Der Antrag müsste Abruf auf dem ersten Gerät (Bildschirm), wenn das Authentifizierungstoken generiert wird.
- Der Antrag müsste Registrierungscode abrufen , die dem Endbenutzer nicht auf dem ersten Gerät (Bildschirm) angezeigt werden sollte.
- Der Antrag müsste Authentifizierung initiieren auf dem ersten Gerät (Bildschirm) mit dem Registrierungs-Code und einem WKWebView oder SFSafariViewController -Komponente.
- Die Anwendung müsste beginnen Abfrage zum Authentifizierungsstatus auf dem ersten Gerät (Bildschirm) nach dem WKWebView oder SFSafariViewController -Komponente geschlossen.
- Der Antrag müsste Abruf auf dem ersten Gerät (Bildschirm), wenn das Authentifizierungstoken generiert wird.
Schritt: "Mit Autorisierungsflüssen fortfahren" Proceed_with_authorization_flows
Abmelden Logout
Die Video-Abonnentenkonto Framework stellt keine API zum programmatischen Abmelden von Personen bereit, die sich auf Gerätesystemebene bei ihrem TV-Anbieterkonto angemeldet haben. Damit die Abmeldung vollständig wirksam wird, muss sich der Endbenutzer daher explizit von abmelden Settings -> TV Provider
auf iOS/iPadOS oder Settings -> Accounts -> TV Provider
auf tvOS. Die andere Option, die der Benutzer hätte, besteht darin, die Berechtigung zum Zugriff auf die Abonnementinformationen des Benutzers aus dem Abschnitt für die spezifischen Anwendungseinstellungen (TV Provider-Zugriff) zu entziehen.
- Die Anwendung muss mithilfe des Felds ""feststellen, ob die Authentifizierung aufgrund einer Anmeldung über die Plattform-SSO erfolgte oder nicht.tokenSource" Benutzermetadaten vom Adobe Pass-Authentifizierungsdienst aus.
- Die Anwendung muss den Benutzer anweisen/auffordern, sich explizit von abzumelden
Settings -> Accounts -> TV Provider
auf tvOS only im Fall der "tokenSource" Wert gleich "Apple". - Der Antrag müsste Logout starten über den Adobe Pass-Authentifizierungsdienst mithilfe eines direkten HTTP-Aufrufs. Dies würde die Sitzungsbereinigung auf der MVPD-Seite nicht erleichtern.
- Die Anwendung muss mithilfe der "" ermitteln, ob die Authentifizierung aufgrund einer Anmeldung über die Plattform-SSO erfolgte oder nicht.tokenSource" Benutzermetadaten vom Adobe Pass-Authentifizierungsdienst aus.
- Die Anwendung muss den Benutzer anweisen/auffordern, sich explizit von abzumelden
Settings -> TV Provider
auf iOS/iPadOS only im Fall der "tokenSource" Wert ist gleich "Apple". - Der Antrag müsste Logout starten vom Adobe Pass-Authentifizierungsdienst mithilfe einer WKWebView oder SFSafariViewController -Komponente. Dies würde die Sitzungsbereinigung auf der MVPD-Seite erleichtern.