mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Reenable Facebook authentication.
This commit is contained in:
parent
5639dae42d
commit
01fa099cda
6 changed files with 16 additions and 30 deletions
|
@ -13,7 +13,7 @@ addons:
|
|||
script:
|
||||
- cargo build
|
||||
- cargo build --features with-tremor
|
||||
#- cargo build --features facebook
|
||||
- cargo build --features facebook
|
||||
# Building without syntex only works on nightly
|
||||
- if [[ $(rustc --version) == *"nightly"* ]]; then
|
||||
cargo build --no-default-features;
|
||||
|
|
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -107,6 +107,8 @@ name = "cookie"
|
|||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"openssl 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -172,6 +174,7 @@ dependencies = [
|
|||
"log 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"mime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"openssl 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
@ -58,6 +58,6 @@ json_macros = { git = "https://github.com/plietar/json_macros" }
|
|||
discovery = ["dns-sd"]
|
||||
with-syntex = ["syntex", "protobuf_macros/with-syntex", "json_macros/with-syntex"]
|
||||
with-tremor = ["tremor"]
|
||||
#facebook = ["hyper/ssl", "openssl"]
|
||||
facebook = ["hyper/ssl", "openssl"]
|
||||
static-appkey = []
|
||||
default = ["with-syntex"]
|
||||
|
|
|
@ -1,38 +1,19 @@
|
|||
use hyper;
|
||||
use hyper::net::Openssl;
|
||||
use hyper::net::NetworkListener;
|
||||
use hyper::server::Request;
|
||||
use hyper::server::Response;
|
||||
use hyper::uri::RequestUri;
|
||||
use hyper::header::AccessControlAllowOrigin;
|
||||
use openssl::ssl::{SslContext, SslMethod, SSL_VERIFY_NONE};
|
||||
use openssl::ssl::error::SslError;
|
||||
use openssl::crypto::pkey::PKey;
|
||||
use openssl::x509::X509;
|
||||
use rand::{self, Rng};
|
||||
use rustc_serialize::json;
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::{Cursor, Read};
|
||||
use std::sync::{mpsc, Arc, Mutex};
|
||||
use std::io::Read;
|
||||
use std::sync::{mpsc, Mutex};
|
||||
use url;
|
||||
|
||||
use protocol::authentication::AuthenticationType;
|
||||
use authentication::Credentials;
|
||||
|
||||
static SPOTILOCAL_CERT : &'static [u8] = include_bytes!("data/spotilocal.cert");
|
||||
static SPOTILOCAL_KEY : &'static [u8] = include_bytes!("data/spotilocal.key");
|
||||
|
||||
fn spotilocal_ssl_context() -> Result<Openssl, SslError> {
|
||||
let cert = try!(X509::from_pem(&mut Cursor::new(SPOTILOCAL_CERT)));
|
||||
let key = try!(PKey::private_key_from_pem(&mut Cursor::new(SPOTILOCAL_KEY)));
|
||||
|
||||
let mut ctx = try!(SslContext::new(SslMethod::Sslv23));
|
||||
try!(ctx.set_cipher_list("DEFAULT"));
|
||||
try!(ctx.set_private_key(&key));
|
||||
try!(ctx.set_certificate(&cert));
|
||||
ctx.set_verify(SSL_VERIFY_NONE, None);
|
||||
Ok(Openssl { context: Arc::new(ctx) })
|
||||
}
|
||||
use ::spotilocal::ssl_context;
|
||||
|
||||
struct ServerHandler {
|
||||
token_tx: Mutex<mpsc::Sender<String>>,
|
||||
|
@ -93,7 +74,7 @@ pub fn facebook_login() -> Result<Credentials, ()> {
|
|||
csrf: csrf.clone()
|
||||
};
|
||||
|
||||
let ssl = spotilocal_ssl_context().unwrap();
|
||||
let ssl = ssl_context().unwrap();
|
||||
|
||||
let mut listener = hyper::net::HttpsListener::new("127.0.0.1:0", ssl).unwrap();
|
||||
let port = listener.local_addr().unwrap().port();
|
||||
|
|
|
@ -172,11 +172,10 @@ pub fn discovery_login(device_name: &str, device_id: &str) -> Result<Credentials
|
|||
Err(())
|
||||
}
|
||||
|
||||
//FIXME
|
||||
//#[cfg(feature = "facebook")]
|
||||
//mod facebook;
|
||||
//#[cfg(feature = "facebook")]
|
||||
//pub use self::facebook::facebook_login;
|
||||
#[cfg(feature = "facebook")]
|
||||
mod facebook;
|
||||
#[cfg(feature = "facebook")]
|
||||
pub use self::facebook::facebook_login;
|
||||
#[cfg(not(feature = "facebook"))]
|
||||
pub fn facebook_login() -> Result<Credentials, ()> {
|
||||
Err(())
|
||||
|
|
|
@ -17,4 +17,7 @@ pub mod spirc;
|
|||
pub mod link;
|
||||
pub mod stream;
|
||||
|
||||
#[cfg(feature = "facebook")]
|
||||
pub mod spotilocal;
|
||||
|
||||
pub use album_cover::get_album_cover;
|
||||
|
|
Loading…
Reference in a new issue