#!/usr/bin/perl
use strict;
use warnings;
use utf8;

#$MOJO_HOME/etc/plugins/auth.conf
#Default configuration for Ado::Plugin::Auth

{   
    #Methods which will be displayed in the "Sign in" menu.
    # Add OAuth2 providers to ado.development.conf.
    auth_methods => ['ado'],
    #Configurations for methods not provided by Mojolicious::Plugin::OAuth2
    providers => {
			#Add the rest of the needed configuration options 
            # to auth.development.conf or auth.production.conf only 
            # because this is highly sensitive and application specific information.
            # Get the credentials from
            # https://console.developers.google.com/project/yourproject/apiui/credential
            # See https://developers.google.com/accounts/docs/OAuth2UserAgent
            # https://developers.google.com/oauthplayground/
            #Example for google:
            # google =>{
            #     #client_id
            #     key =>'123456654321abcd.apps.googleusercontent.com',
            #     secret =>'Y0uRS3cretHEre',
            #     scope=>'profile email',
            #     info_url => 'https://www.googleapis.com/userinfo/v2/me',
            #     },
    },
    #Add your routes definitions here.
    routes => [

        #the login form and authentication
        {   route => '/login/:auth_method',
            via   => ['GET', 'POST'],
            to    => {
                auth_method => 'ado',
                cb          => \&Ado::Plugin::Auth::login
            },
            description =>'GET: Renders a login form when :auth_method is "ado".'
            .' or authenticates a user when :auth_method is an OAuth2 provider.'.$/
            .'POST:authenticates a user.',
        },

        {   route =>'/authorize/:auth_method',
            via   => ['GET', 'POST'],
            to    => {
                auth_method => 'google',
                cb  => \&Ado::Plugin::Auth::authorize
            },
        },

        {   route => '/logout',
            to    => {cb => \&Ado::Plugin::Auth::logout}
        },
        {   route => '/test/authenticateduser',
            over  => {authenticated => 1},
            to    => 'test#authenticateduser'
        },

    ],
};