Apple SSO Cookbook (REST API) apple-sso-cookbook-rest-api
Inleiding Introduction
De Adobe Pass Authentication REST API kan platform Single Sign-On (SSO)-verificatie ondersteunen voor eindgebruikers van clienttoepassingen die op iOS, iPadOS of tvOS worden uitgevoerd via wat we de Apple SSO-workflow noemen.
Dit document fungeert als een uitbreiding op de bestaande REST API-documentatie, die u kunt vinden hier.
Cookbooks Cookbooks
Om van de Apple SSO-gebruikerservaring te kunnen profiteren, moet één toepassing de Video-abonneeaccount door Apple ontwikkeld raamwerk, maar wat de communicatie van de Adobe Pass Authentication REST API betreft, moet het de reeks tips volgen die hieronder wordt weergegeven.
Verificatie Authentication
- Is er een geldig teken van de Adobe authentificatie?
- Is de gebruiker aangemeld via Platform SSO?
- Configuratie Adobe ophalen
- Platform SSO-workflow starten met Adobe config
- Is gebruikersaanmelding geslaagd?
- Vraag een profielverzoek van Adobe voor geselecteerde MVPD
- Het verzoek van de Adobe doorsturen naar Platform SSO om het profiel te verkrijgen
- Exchange the Platform SSO profile for an Adobe authentication token
- Is het genereren van een Adobe token gelukt?
- Tweede workflow voor schermverificatie starten
- Doorgaan met autorisatiestromen
Stap: "Is er een geldig token voor Adobe-verificatie?" Is_there_a_valid_Adobe_authentication_token
Stap: "Is de gebruiker aangemeld via Platform SSO?" Is_the_user_logged_in_via_Platform_SSO
- De toepassing moet controleren op toegangsrechten de abonnementsgegevens van de gebruiker en ga alleen verder als de gebruiker dit heeft toegestaan.
- De aanvraag moet een verzoek voor de informatie van de abonneerekening.
- De toepassing moet wachten en de metagegevens informatie.
...
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.
...
}
}
...
Stap: "Configuratie Adobe ophalen" Fetch_Adobe_configuration
enablePlatformServices
, boardingStatus
, displayInPlatformPicker
, platformMappingId
, requiredMetadataFields
en extra aandacht besteden aan de opmerkingen in codefragmenten uit andere stappen.Stap "De werkschema van SSO van het Platform met Adobe config"initialiseren Initiate_Platform_SSO_workflow_with_Adobe_config
- De toepassing moet controleren op toegangsrechten de abonnementsgegevens van de gebruiker en ga alleen verder als de gebruiker dit heeft toegestaan.
- De toepassing moet een gedelegeerde voor VSAccountManager.
- De aanvraag moet een verzoek voor de informatie van de abonneerekening.
- De toepassing moet wachten en de metagegevens informatie.
...
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=nl) 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=nl) 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.
...
}
}
...
Stap: "Is gebruikersaanmelding geslaagd?" Is_user_login_successful
vsaMetadata!.accountProviderIdentifier
bevat een geldige waarde en de huidige datum is nog niet verstreken vsaMetadata!.authenticationExpirationDate
waarde.Stap "verkrijg een profielverzoek van Adobe voor geselecteerde MVPD" Obtain_a_profile_request_from_Adobe_for_the_selected_MVPD
platformMappingId
in termen van Adobe Pass-verificatieconfiguratie. Daarom moet de toepassing de MVPD identiteitskaart bezitswaarde bepalen, gebruikend platformMappingId
waarde, via het medium Adobe Pass Authentication MVPD-lijst opgeven service.Stap: "Verstuur het verzoek van de Adobe naar Platform SSO om het profiel te verkrijgen" Forward_the_Adobe_request_to_Platform_SSO_to_obtain_the_profile
- De toepassing moet controleren op toegangsrechten de abonnementsgegevens van de gebruiker en ga alleen verder als de gebruiker dit heeft toegestaan.
- De aanvraag moet een verzoek voor de informatie van de abonneerekening.
- De toepassing moet wachten en de metagegevens informatie.
...
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=nl) 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=nl) 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.
...
}
}
...
Stap: "Exchange the Platform SSO profile for an Adobe authentication token" Exchange_the_Platform_SSO_profile_for_an_Adobe_authentication_token
vsaMetadata!.samlAttributeQueryResponse!
vertegenwoordigt de SAMLResponse
, die moet worden doorgegeven Tokenuitwisseling en vereist tekenreeksmanipulatie en -codering (Base64 gecodeerd en URL gecodeerd nadien) alvorens de vraag te maken.Stap: "Wordt het teken van de Adobe met succes geproduceerd?" Is_Adobe_token_generated_successfully
204 No Content
, die aangeeft dat de token is gemaakt en klaar is om te worden gebruikt voor de machtigingsstromen.Stap: "De tweede workflow voor schermverificatie starten" Initiate_second_screen_authentication_workflow
Belangrijk: De terminologie van de "Tweede workflow voor schermverificatie" is geschikt voor AppleTV's, terwijl de terminologie "Eerste workflow voor schermverificatie" / "Reguliere workflow voor verificatie" geschikter zou zijn voor iPhones en iPads.
Registratiecode-aanvraag, Verificatie starten en REST API-verificatietoken ophalen of Verificatietoken controleren diensten.
- De aanvraag moet een registratiecode verkrijgen en deze aan de eindgebruiker presenteren op het eerste apparaat (scherm).
- De toepassing moet worden gestart opiniepeiling ter erkenning van de verificatiestatus op het eerste apparaat (scherm) nadat de registratiecode is verkregen.
- Een andere toepassing moet verificatie starten op een tweede apparaat (scherm) wanneer de registratiecode wordt gebruikt.
- De toepassing moet stoppen pollen op het eerste apparaat (scherm) wanneer het authentificatietoken wordt geproduceerd.
- De aanvraag moet een registratiecode verkrijgen die niet aan het eind - gebruiker op het 1ste apparaat (scherm) zou moeten worden voorgesteld.
- De aanvraag moet verificatie starten op het eerste apparaat (scherm) met behulp van de registratiecode en een WKWebView of SFSafariViewController component.
- De toepassing moet worden gestart opiniepeiling om de verificatiestatus te kennen op het eerste apparaat (scherm) na de WKWebView of de SFSafariViewController wordt gesloten.
- De toepassing moet stoppen pollen op het eerste apparaat (scherm) wanneer het authentificatietoken wordt geproduceerd.
Stap: "Doorgaan met vergunningsstromen" Proceed_with_authorization_flows
Afmelden Logout
De Video-abonneeaccount framework biedt geen API om personen die zich op het niveau van het apparaatsysteem hebben aangemeld bij hun tv-provider, via programmacode af te melden. Om de logout volledig van kracht te laten worden, moet de eindgebruiker zich daarom expliciet afmelden Settings -> TV Provider
op iOS/iPadOS of Settings -> Accounts -> TV Provider
op tvOS. De andere mogelijkheid die de gebruiker zou hebben, is het intrekken van de machtiging om de abonnementsgegevens van de gebruiker te openen in het gedeelte met specifieke toepassingsinstellingen (toegang tot tv-provider).
- De toepassing zou moeten bepalen als de authentificatie als resultaat van een login door platform SSO of niet, gebruikend "tokenSource" gebruikersmetagegevens van de Adobe Pass Authentication-service.
- De toepassing moet de gebruiker de instructie geven/vragen zich expliciet af te melden
Settings -> Accounts -> TV Provider
op tvOS alleen in geval van "tokenSource" waarde is gelijk aan "Apple". - De aanvraag moet start de logout van de Adobe Pass-verificatieservice via een directe HTTP-aanroep. Dit zou sessieopruiming aan de MVPD-zijde niet vergemakkelijken.
- De toepassing zou moeten bepalen als de authentificatie als resultaat van een login door platform SSO of niet, gebruikend "tokenSource" gebruikersmetagegevens van de Adobe Pass Authentication-service.
- De toepassing moet de gebruiker de instructie geven/vragen zich expliciet af te melden
Settings -> TV Provider
op iOS/iPadOS alleen in geval van "tokenSource" waarde is gelijk aan "Apple". - De aanvraag moet start de logout van de Adobe Pass-verificatieservice via een WKWebView of SFSafariViewController component. Dit zou zittingsschoonmaak aan de kant van MVPD vergemakkelijken.