(Äldre) Apple SSO Cookbook (REST API V1) apple-sso-cookbook-rest-api-v1
Adobe Pass Authentication REST API V1 har stöd för Partner Single Sign-On (SSO) för slutanvändare av klientprogram som körs på iOS, iPadOS eller tvOS.
Det här dokumentet fungerar som ett tillägg till den befintliga dokumentationen för REST API V1, som finns här.
Cookbook apple-sso-cookbook-rest-api-v1-cookbook
För att du ska kunna dra nytta av Apple SSO-användarupplevelsen måste programmet integrera det Video Subscriber Account Framework som utvecklats av Apple, och för Adobe Pass Authentication REST API V1-kommunikationen måste programmet följa stegen nedan.
Behörighet apple-sso-cookbook-rest-api-v1-permission
Settings -> TV Provider
på iOS och iPadOS eller Settings -> Accounts -> TV Provider
på tvOS.Autentisering apple-sso-cookbook-rest-api-v1-authentication
- Finns det en giltig Adobe-autentiseringstoken?
- Är användaren inloggad via enkel inloggning för partner?
- Hämta Adobe-konfiguration
- Initiera enkel inloggning för partner med Adobe config
- Har användaren loggat in?
- Hämta en profilförfrågan från Adobe för den valda MVPD
- Vidarebefordra Adobe-begäran till partnerorganisationen för enkel inloggning för att erhålla profilen
- Byt SSO-profil för partner för en autentiseringstoken för Adobe
- Genereras Adobe-token korrekt?
- Starta ett arbetsflöde för vanlig autentisering
- Fortsätt med auktoriseringsflöden
Steg: "Finns det en giltig token för autentisering i Adobe?" step1
Steg:"Är användaren inloggad via enkel inloggning för partner?" step2
- Programmet måste kontrollera om användaren har behörighet att komma åt användarens prenumerationsinformation och fortsätta endast om användaren tillåter det.
- Programmet måste skicka en förfrågan för prenumerantkontoinformation.
- Programmet måste vänta och bearbeta metadata-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 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.
...
}
}
...
Steg: "Hämta Adobe-konfiguration" step3
enablePlatformServices
, boardingStatus
, displayInPlatformPicker
, platformMappingId
, requiredMetadataFields
och observera de kommentarer som presenteras i kodfragment från andra steg.Steg"Initiera enkel inloggning för partner med Adobe config" step4
- Programmet måste kontrollera om användaren har behörighet att komma åt användarens prenumerationsinformation och fortsätta endast om användaren tillåter det.
- Programmet måste tillhandahålla delegate för VSAccountManager.
- Programmet måste skicka en förfrågan för prenumerantkontoinformation.
- Programmet måste vänta och bearbeta metadata-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](/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.
...
}
}
...
Steg:"Har användarinloggningen slutförts?" step5
vsaMetadata!.accountProviderIdentifier
innehåller ett giltigt värde och det aktuella datumet inte har passerat värdet vsaMetadata!.authenticationExpirationDate
.Steg"Hämta en profilförfrågan från Adobe för den valda MVPD" step6
platformMappingId
i form av Adobe Pass-autentiseringskonfiguration. Därför måste programmet fastställa egenskapsvärdet för MVPD-id med hjälp av värdet platformMappingId
via API-tjänsten Adobe Pass Authentication Provide MVPD List .Steg:"Vidarebefordra Adobe-begäran till enkel inloggning för partner för att erhålla profilen" step7
- Programmet måste kontrollera om användaren har behörighet att komma åt användarens prenumerationsinformation och fortsätta endast om användaren tillåter det.
- Programmet måste skicka en förfrågan för prenumerantkontoinformation.
- Programmet måste vänta och bearbeta metadata-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](/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.
...
}
}
...
Steg:"Byt ut partnerns SSO-profil för en autentiseringstoken för Adobe" step8
vsaMetadata!.samlAttributeQueryResponse!
representerar SAMLResponse
, som måste skickas på Token Exchange och som kräver strängmanipulering och kodning (Base64-kodad och URL-kodad efteråt) innan anropet görs.Steg:"Har Adobe-token genererats utan fel?" step9
204 No Content
, vilket anger att token skapades och är klar att användas för auktoriseringsflödena.Steg:"Starta ett regelbundet autentiseringsarbetsflöde" step10
- Programmet måste hämta en registreringskod och presentera den för slutanvändaren på den första enheten (skärmen).
- Programmet måste starta avsökningen för att bekräfta autentiseringstillståndet på den första enheten (skärmen) när registreringskoden har hämtats.
- Ett annat program måste initiera autentisering på en andra enhet (skärm) när registreringskoden används.
- Programmet måste stoppa avsökningen på den första enheten (skärmen) när autentiseringstoken genereras.
- Programmet måste hämta en registreringskod som inte ska visas för slutanvändaren på den första enheten (skärmen).
- Programmet måste initiera autentisering på den första enheten (skärmen) med registreringskoden och en WKWebView eller en SFSafariViewController -komponent.
- Programmet måste starta avsökningen för att känna till autentiseringstillståndet på den första enheten (skärmen) när WKWebView eller SFSafariViewController -komponenten stängs.
- Programmet måste stoppa avsökningen på den första enheten (skärmen) när autentiseringstoken genereras.
Steg:"Fortsätt med auktoriseringsflöden" step11
Utloggning apple-sso-cookbook-rest-api-v1-logout
Video Subscriber Account Framework innehåller inget API för att programmässigt logga ut personer som har loggat in på sitt TV-leverantörskonto på enhetssystemnivå. För att utloggningen ska få full effekt måste slutanvändaren därför uttryckligen logga ut från Settings -> TV Provider
på iOS/iPadOS eller Settings -> Accounts -> TV Provider
på tvOS. Det andra alternativet som användaren skulle ha möjlighet att återkalla behörigheten att få åtkomst till användarens prenumerationsinformation från det specifika avsnittet för programinställningar (TV-leverantörsåtkomst).
- Programmet måste avgöra om autentiseringen har skett som ett resultat av en inloggning via partnerns SSO eller inte, med hjälp av tokenSource användarens metadata från Adobe Pass-autentiseringstjänsten.
- Programmet måste instruera/uppmana användaren att explicit logga ut från
Settings -> Accounts -> TV Provider
på tvOS only om värdet "tokenSource" är lika med Apple". - Programmet måste initiera utloggningen från Adobe Pass-autentiseringstjänsten med ett direkt HTTP-anrop. Detta underlättar inte sessionssanering på MVPD sida.
- Programmet måste avgöra om autentiseringen har skett som ett resultat av en inloggning via partnerns SSO eller inte, med hjälp av tokenSource användarens metadata från Adobe Pass-autentiseringstjänsten.
- Programmet måste instruera/uppmana användaren att explicit logga ut från
Settings -> TV Provider
på iOS/iPadOS only om värdet "tokenSource" är lika med "Apple". - Programmet måste initiera utloggningen från Adobe Pass-autentiseringstjänsten med en WKWebView eller en SFSafariViewController -komponent. Detta underlättar sessionssanering på MVPD sida.