Skip to content
Snippets Groups Projects
Verified Commit cc39f6fb authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Presub konfigurace do pi_tube.conf

parent 82fdd5a4
No related branches found
No related tags found
No related merge requests found
...@@ -12,36 +12,26 @@ sub startup { ...@@ -12,36 +12,26 @@ sub startup {
my $self = shift; my $self = shift;
# Nacteni konfigurace # Nacteni konfigurace
my $config = $self->plugin('Config'); my $cfg = $self->plugin('Config');
$self->helper( cfg => sub { return $cfg; } );
$self->secrets([$ENV{SECRET}]); $self->secrets($cfg->{session}{secrets});
$self->plugin('PiTube::Helpers::OAuth2'); $self->plugin('PiTube::Helpers::OAuth2');
my $home = Mojo::Home->new()->detect; my $home = Mojo::Home->new()->detect;
my $pg = Mojo::Pg->new my $pg = Mojo::Pg->new
->dsn($ENV{DB_DSN}) ->dsn($cfg->{database}{dsn})
->username($ENV{DB_USERNAME}) ->username($cfg->{database}{user})
->password($ENV{DB_PASSWORD}) ->password($cfg->{database}{password})
; ;
$pg->migrations->from_file("$home/sql/migrations.sql"); $pg->migrations->from_file("$home/sql/migrations.sql");
$pg->migrations->migrate(); $pg->migrations->migrate();
# Spojeni s databazi # Spojeni s databazi
my $schema = PiTube::Schema->connect( { my $schema = PiTube::Schema->connect($cfg->{database});
dsn => $ENV{DB_DSN},
user => $ENV{DB_USERNAME},
password => $ENV{DB_PASSWORD},
AutoCommit => 1,
quote_char => '"',
name_sep => '.',
pg_enable_utf8 => 1,
on_connect_do => [
"set timezone to 'Europe/Prague'",
],
});
$self->helper( schema => sub { return $schema; } ); $self->helper( schema => sub { return $schema; } );
$self->plugin('authentication', { $self->plugin('authentication', {
......
...@@ -18,7 +18,7 @@ sub register { ...@@ -18,7 +18,7 @@ sub register {
# get public key # get public key
my $tx = $ua->get( $ENV{OAUTH_REALM_URL} ); my $tx = $ua->get( $self->cfg->{oauth2}{realm_url} );
my $res = $tx->result; my $res = $tx->result;
if ($res->is_success) { if ($res->is_success) {
...@@ -27,9 +27,9 @@ sub register { ...@@ -27,9 +27,9 @@ sub register {
); );
} }
# get urls # get endpoints
$tx = $ua->get( $ENV{OAUTH_REALM_URL} . '/.well-known/openid-configuration'); $tx = $ua->get( $self->cfg->{oauth2}{realm_well_known} );
$res = $tx->result; $res = $tx->result;
if ($res->is_success) { if ($res->is_success) {
...@@ -37,13 +37,9 @@ sub register { ...@@ -37,13 +37,9 @@ sub register {
} }
my $oauth2 = Net::OAuth2::Profile::WebServer->new( my $oauth2 = Net::OAuth2::Profile::WebServer->new(
name => 'SSO', %{ $self->cfg->{oauth2}},
scope => 'profile',
client_id => $ENV{OAUTH_CLIENT_ID},
client_secret => $ENV{OAUTH_CLIENT_SECRET},
authorize_url => $discovered->{authorization_endpoint}, authorize_url => $discovered->{authorization_endpoint},
access_token_url => $discovered->{token_endpoint}, access_token_url => $discovered->{token_endpoint},
redirect_uri => $ENV{BASE_URL} . '/oauth2',
); );
$self->helper( oauth2 => sub { return $oauth2; } ); $self->helper( oauth2 => sub { return $oauth2; } );
......
...@@ -3,6 +3,33 @@ ...@@ -3,6 +3,33 @@
workers => 10, workers => 10,
proxy => 1, proxy => 1,
pid_file => '/var/tmp/hypnotoad.pid', pid_file => '/var/tmp/hypnotoad.pid',
listen => ['http://*:3000'] listen => ['http://*:3000'],
},
session => {
secrets => [$ENV{SECRET}],
},
database => {
dsn => $ENV{DB_DSN},
user => $ENV{DB_USERNAME},
password => $ENV{DB_PASSWORD},
AutoCommit => 1,
quote_char => '"',
name_sep => '.',
pg_enable_utf8 => 1,
on_connect_do => [
"set timezone to 'Europe/Prague'",
],
},
oauth2 => {
name => 'SSO',
scope => 'profile',
client_id => $ENV{OAUTH_CLIENT_ID},
client_secret => $ENV{OAUTH_CLIENT_SECRET},
redirect_uri => $ENV{BASE_URL} . '/oauth2',
realm_url => $ENV{OAUTH_REALM_URL},
realm_well_known => $ENV{OAUTH_REALM_URL} . '/.well-known/openid-configuration',
},
rtmp => {
base_url => $ENV{RTMP_BASE_URL},
} }
}; };
...@@ -5,6 +5,6 @@ Nemáte oprávnění ke sledování streamu <strong>"<%= $c->stash->{stream}->na ...@@ -5,6 +5,6 @@ Nemáte oprávnění ke sledování streamu <strong>"<%= $c->stash->{stream}->na
</p> </p>
% if ( $c->is('publisher')) { % if ( $c->is('publisher')) {
<p> <p>
stream rtp url: <%= $ENV{RTMP_BASE_URL} %>/<%= $c->stash->{stream}->key %>?token=<%= $c->current_user->token %> stream rtp url: <%= $c->config->{rtmp}{base_url} %>/<%= $c->stash->{stream}->key %>?token=<%= $c->current_user->token %>
</p> </p>
% } % }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment