AppleAuthProvider
Required to use Sign In with Apple:
- Membership Team ID from https://developer.apple.com/account/#/membership/
- Create & configure App ID from https://developer.apple.com/account/resources/identifiers/list
- Use App Id to create & configure Service ID from https://developer.apple.com/account/resources/identifiers/list/serviceId
- Use App Id to create & configure Private Key from https://developer.apple.com/account/resources/authkeys/list Service ID must be configured with non-localhost trusted domain and HTTPS callback URL, for development can use:
- Domain: local.servicestack.com
- Callback URL: https://local.servicestack.com:5001/auth/apple
Assembly: ServiceStack.Extensions.dll
View Source
public class AppleAuthProvider : OAuth2Provider, IOAuthProvider, IAuthProvider, IAuthPlugin
Properties
Audience
The audience used in JWT Client Secret. Default: https://appleid.apple.com
View Source
public string Audience { get; set; }
TeamId
Apple Developer Membership Team ID
View Source
public string TeamId { get; set; }
ClientId
Service ID
View Source
public string ClientId { get; set; }
BundleId
Bundle ID
View Source
public string BundleId { get; set; }
KeyId
The Private Key ID
View Source
public string KeyId { get; set; }
KeyPath
Path to .p8 Private Key
View Source
public string KeyPath { get; set; }
KeyBase64
Base64 of .p8 Private Key bytes
View Source
public string KeyBase64 { set; }
KeyBytes
.p8 Private Key bytes
View Source
public byte[] KeyBytes { get; set; }
ClientSecretFactory
Customize ClientSecret JWT
View Source
public Func<AppleAuthProvider, string> ClientSecretFactory { get; set; }
ClientSecretExpiry
When JWT Client Secret expires, defaults to Apple Max 6 Month Expiry
View Source
public TimeSpan ClientSecretExpiry { get; set; }
IssuerSigningKeysJson
Optional: static list of Apple's public keys, defaults to fetching from https://appleid.apple.com/auth/keys
View Source
public string IssuerSigningKeysJson { get; set; }
CacheKey
Whether to cache private Key if loading from KeyPath, defaults: true
View Source
public bool CacheKey { get; set; }
CacheIssuerSigningKeys
Whether to cache Apple's public keys, defaults: true
View Source
public bool CacheIssuerSigningKeys { get; set; }
ValidateRefreshTokenExpiry
How long before re-validating Sign in RefreshToken, default: 1 day. Set to null to disable RefreshToken validation.
View Source
public TimeSpan? ValidateRefreshTokenExpiry { get; set; }
Inherited Properties
ResolveUnknownDisplayName
Custom DisplayName resolver function when not provided
View Source
public Func<IAuthSession, IAuthTokens, string> ResolveUnknownDisplayName { get; set; }
ResponseMode
View Source
public string ResponseMode { get; set; }
Scopes
View Source
public string[] Scopes { get; set; }
Fields
Name
View Source
public const string Name = null
Realm
View Source
public static string Realm
DefaultAudience
View Source
public const string DefaultAudience = null
DefaultAuthorizeUrl
View Source
public const string DefaultAuthorizeUrl = null
DefaultAccessTokenUrl
View Source
public const string DefaultAccessTokenUrl = null
DefaultIssuerSigningKeysUrl
View Source
public const string DefaultIssuerSigningKeysUrl = null
Methods
Register(IAppHost, AuthFeature)
View Source
public override void Register(IAppHost appHost, AuthFeature feature)
Parameters
Type | Name |
---|---|
ServiceStack.IAppHost | appHost |
ServiceStack.AuthFeature | feature |
OnVerifyAccessTokenAsync(String, AuthContext)
View Source
public virtual async Task<bool> OnVerifyAccessTokenAsync(string idToken, AuthContext ctx)
Returns
Task<System.Boolean>
Parameters
Type | Name |
---|---|
System.String | idToken |
ServiceStack.Auth.AuthContext | ctx |
ValidateRefreshToken(String, String, AuthContext)
View Source
public async Task<string> ValidateRefreshToken(string refreshToken, string clientId, AuthContext ctx)
Returns
Task<System.String>
Parameters
Type | Name |
---|---|
System.String | refreshToken |
System.String | clientId |
ServiceStack.Auth.AuthContext | ctx |
AssertValidState()
View Source
protected override void AssertValidState()
AssertConsumerSecret()
View Source
protected override void AssertConsumerSecret()
GetClientSecret(String)
View Source
protected virtual string GetClientSecret(string clientId)
Returns
System.String
Parameters
Type | Name |
---|---|
System.String | clientId |
GetPrivateKeyBytes()
View Source
protected virtual byte[] GetPrivateKeyBytes()
Returns
System.Byte[]
GetAccessTokenJsonAsync(String, AuthContext, CancellationToken)
View Source
protected override async Task<string> GetAccessTokenJsonAsync(string code, AuthContext ctx, CancellationToken token = null)
Returns
Task<System.String>
Parameters
Type | Name |
---|---|
System.String | code |
ServiceStack.Auth.AuthContext | ctx |
CancellationToken | token |
GetRedirectUri(AuthContext)
View Source
protected virtual string GetRedirectUri(AuthContext ctx)
Returns
System.String
Parameters
Type | Name |
---|---|
ServiceStack.Auth.AuthContext | ctx |
GetIssuerSigningKeysJson()
View Source
protected virtual string GetIssuerSigningKeysJson()
Returns
System.String
AuthenticateWithAccessTokenAsync(IServiceBase, IAuthSession, IAuthTokens, String, Dictionary<String, String>, CancellationToken)
View Source
protected override async Task<object> AuthenticateWithAccessTokenAsync(IServiceBase authService, IAuthSession session, IAuthTokens tokens, string accessToken, Dictionary<string, string> authInfo = null, CancellationToken token = null)
Returns
Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.IServiceBase | authService |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthTokens | tokens |
System.String | accessToken |
Dictionary<System.String,System.String> | authInfo |
CancellationToken | token |
ValidateIdentityToken(String)
View Source
public void ValidateIdentityToken(string idToken)
Parameters
Type | Name |
---|---|
System.String | idToken |
CreateAuthInfoAsync(String, CancellationToken)
View Source
protected override Task<Dictionary<string, string>> CreateAuthInfoAsync(string idToken, CancellationToken token = null)
Returns
Task<Dictionary<System.String,System.String>>
Parameters
Type | Name |
---|---|
System.String | idToken |
CancellationToken | token |
DefaultResolveUnknownDisplayName(IAuthSession, IAuthTokens)
View Source
public static string DefaultResolveUnknownDisplayName(IAuthSession authSession, IAuthTokens tokens)
Returns
System.String
Parameters
Type | Name |
---|---|
ServiceStack.Auth.IAuthSession | authSession |
ServiceStack.Auth.IAuthTokens | tokens |
LoadUserAuthInfoAsync(AuthUserSession, IAuthTokens, Dictionary<String, String>, CancellationToken)
View Source
protected override Task LoadUserAuthInfoAsync(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo, CancellationToken token = null)
Returns
Task
Parameters
Type | Name |
---|---|
ServiceStack.AuthUserSession | userSession |
ServiceStack.Auth.IAuthTokens | tokens |
Dictionary<System.String,System.String> | authInfo |
CancellationToken | token |
Inherited Methods
AssertAccessTokenUrl()
View Source
protected virtual void AssertAccessTokenUrl()
AssertAuthorizeUrl()
View Source
protected virtual void AssertAuthorizeUrl()
AssertValidState()
View Source
protected override void AssertValidState()
AuthenticateAsync(IServiceBase, IAuthSession, Authenticate, CancellationToken)
View Source
public override async Task<object> AuthenticateAsync(IServiceBase authService, IAuthSession session, Authenticate request, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.IServiceBase | authService |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Authenticate | request |
System.Threading.CancellationToken | token |
AuthenticateWithAccessTokenAsync(IServiceBase, IAuthSession, IAuthTokens, String, Dictionary<String, String>, CancellationToken)
View Source
protected virtual async Task<object> AuthenticateWithAccessTokenAsync(IServiceBase authService, IAuthSession session, IAuthTokens tokens, string accessToken, Dictionary<string, string> authInfo = null, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Object>
Parameters
Type | Name |
---|---|
ServiceStack.IServiceBase | authService |
ServiceStack.Auth.IAuthSession | session |
ServiceStack.Auth.IAuthTokens | tokens |
System.String | accessToken |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
System.Threading.CancellationToken | token |
CreateAuthInfoAsync(String, CancellationToken)
View Source
protected abstract Task<Dictionary<string, string>> CreateAuthInfoAsync(string accessToken, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.Collections.Generic.Dictionary<System.String,System.String>>
Parameters
Type | Name |
---|---|
System.String | accessToken |
System.Threading.CancellationToken | token |
GetAccessTokenJsonAsync(String, AuthContext, CancellationToken)
View Source
protected virtual async Task<string> GetAccessTokenJsonAsync(string code, AuthContext ctx, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task<System.String>
Parameters
Type | Name |
---|---|
System.String | code |
ServiceStack.Auth.AuthContext | ctx |
System.Threading.CancellationToken | token |
GetUserAuthName(IAuthTokens, Dictionary<String, String>)
Override to return User chosen username or Email for this AuthProvider
View Source
protected virtual string GetUserAuthName(IAuthTokens tokens, Dictionary<string, string> authInfo)
Returns
System.String
Parameters
Type | Name |
---|---|
ServiceStack.Auth.IAuthTokens | tokens |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
LoadUserAuthInfoAsync(AuthUserSession, IAuthTokens, Dictionary<String, String>, CancellationToken)
View Source
protected override Task LoadUserAuthInfoAsync(AuthUserSession userSession, IAuthTokens tokens, Dictionary<string, string> authInfo, CancellationToken token = default(CancellationToken))
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.AuthUserSession | userSession |
ServiceStack.Auth.IAuthTokens | tokens |
System.Collections.Generic.Dictionary<System.String,System.String> | authInfo |
System.Threading.CancellationToken | token |
LoadUserOAuthProviderAsync(IAuthSession, IAuthTokens)
View Source
public override Task LoadUserOAuthProviderAsync(IAuthSession authSession, IAuthTokens tokens)
Returns
System.Threading.Tasks.Task
Parameters
Type | Name |
---|---|
ServiceStack.Auth.IAuthSession | authSession |
ServiceStack.Auth.IAuthTokens | tokens |