diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-07-11 22:31:08 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-07-11 22:31:08 -0400 |
| commit | b5641013cea8542d3a992fb11811347e761a1f50 (patch) | |
| tree | edf14d9448f57e7e567668b6b1915844d9c5de58 /MediaBrowser.Server.Implementations | |
| parent | 59de5c0d14fbf0c09926e37dce0c2e6de69000dd (diff) | |
Add api key functions
Diffstat (limited to 'MediaBrowser.Server.Implementations')
5 files changed, 52 insertions, 18 deletions
diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 85cc51f53..a69a7b124 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -233,5 +233,8 @@ "OptionBlockGames": "Games", "OptionBlockLiveTvPrograms": "Live TV Programs", "OptionBlockLiveTvChannels": "Live TV Channels", - "OptionBlockChannelContent": "Internet Channel Content" + "OptionBlockChannelContent": "Internet Channel Content", + "ButtonRevoke": "Revoke", + "MessageConfirmRevokeApiKey": "Are you sure you wish to revoke this api key? The application's connection to Media Browser will be abruptly terminated.", + "HeaderConfirmRevokeApiKey": "Revoke Api Key" }
\ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index bc350bb38..96b80d143 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -849,7 +849,7 @@ "LabelXbmcMetadataEnablePathSubstitutionHelp2": "See path substitution.", "LabelGroupChannelsIntoViews": "Display the following channels directly within my views:", "LabelGroupChannelsIntoViewsHelp": "If enabled, these channels will be displayed directly alongside other views. If disabled, they'll be displayed within a separate Channels view.", - "LabelDisplayCollectionsView": "Display a Collections view to show movie collections", + "LabelDisplayCollectionsView": "Display a collections view to show movie collections", "LabelXbmcMetadataEnableExtraThumbs": "Copy extrafanart into extrathumbs", "LabelXbmcMetadataEnableExtraThumbsHelp": "When downloading images they can be saved into both extrafanart and extrathumbs for maximum Xbmc skin compatibility.", "TabServices": "Services", @@ -870,5 +870,17 @@ "LabelImagesByName": "Images by name:", "LabelTranscodingTemporaryFiles": "Transcoding temporary files:", "HeaderLatestMusic": "Latest Music", - "HeaderBranding": "Branding" + "HeaderBranding": "Branding", + "HeaderApiKeys": "Api Keys", + "HeaderApiKeysHelp": "External applications are required to have an Api key in order to communicate with Media Browser. Keys are issued by logging in with a Media Browser account, or by manually granting the application a key.", + "HeaderApiKey": "Api Key", + "HeaderApp": "App", + "HeaderDevice": "Device", + "HeaderUser": "User", + "HeaderDateIssued": "Date Issued", + "LabelChapterName": "Chapter {0}", + "HeaderNewApiKey": "New Api Key", + "LabelAppName": "App name", + "LabelAppNameExample": "Example: Sickbeard, NzbDrone", + "HeaderNewApiKeyHelp": "Grant an application permission to communicate with Media Browser." }
\ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs b/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs index 5f225ddd4..43a960ea2 100644 --- a/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs +++ b/MediaBrowser.Server.Implementations/Security/AuthenticationRepository.cs @@ -283,11 +283,11 @@ namespace MediaBrowser.Server.Implementations.Security } info.IsActive = reader.GetBoolean(6); - info.DateCreated = reader.GetDateTime(7); + info.DateCreated = reader.GetDateTime(7).ToUniversalTime(); if (!reader.IsDBNull(8)) { - info.DateRevoked = reader.GetDateTime(8); + info.DateRevoked = reader.GetDateTime(8).ToUniversalTime(); } return info; diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 338bf8959..1d1910e40 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1210,15 +1210,15 @@ namespace MediaBrowser.Server.Implementations.Session /// <returns>Task{SessionInfo}.</returns> /// <exception cref="System.UnauthorizedAccessException">Invalid user or password entered.</exception> /// <exception cref="UnauthorizedAccessException"></exception> - public async Task<AuthenticationResult> AuthenticateNewSession(string username, - string password, - string clientType, - string appVersion, - string deviceId, - string deviceName, + public async Task<AuthenticationResult> AuthenticateNewSession(string username, + string password, + string clientType, + string appVersion, + string deviceId, + string deviceName, string remoteEndPoint) { - var result = (IsLocalhost(remoteEndPoint) && string.Equals(clientType, "Dashboard", StringComparison.OrdinalIgnoreCase)) || + var result = (IsLocalhost(remoteEndPoint) && string.Equals(clientType, "Dashboard", StringComparison.OrdinalIgnoreCase)) || await _userManager.AuthenticateUser(username, password).ConfigureAwait(false); if (!result) @@ -1332,6 +1332,11 @@ namespace MediaBrowser.Server.Implementations.Session } } + public Task RevokeToken(string token) + { + return Logout(token); + } + private bool IsLocalhost(string remoteEndpoint) { if (string.IsNullOrWhiteSpace(remoteEndpoint)) diff --git a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs index 5fc28e81b..e1d77c268 100644 --- a/MediaBrowser.Server.Implementations/Session/WebSocketController.cs +++ b/MediaBrowser.Server.Implementations/Session/WebSocketController.cs @@ -62,14 +62,28 @@ namespace MediaBrowser.Server.Implementations.Session void connection_Closed(object sender, EventArgs e) { - var capabilities = new SessionCapabilities + if (!GetActiveSockets().Any()) { - PlayableMediaTypes = Session.PlayableMediaTypes, - SupportedCommands = Session.SupportedCommands, - SupportsMediaControl = SupportsMediaControl - }; + try + { + _sessionManager.ReportSessionEnded(Session.Id); + } + catch (Exception ex) + { + _logger.ErrorException("Error reporting session ended.", ex); + } + } + else + { + var capabilities = new SessionCapabilities + { + PlayableMediaTypes = Session.PlayableMediaTypes, + SupportedCommands = Session.SupportedCommands, + SupportsMediaControl = SupportsMediaControl + }; - _sessionManager.ReportCapabilities(Session.Id, capabilities); + _sessionManager.ReportCapabilities(Session.Id, capabilities); + } } private IWebSocketConnection GetActiveSocket() |
