Apache Zeppelin configured for OIDC redirects to http://localhost:8081/null - apache-zeppelin

I've tried with both Apache Zeppelin 0.8 and 0.9 + pac4j and the problem is the same. When visiting the app root at http://localhost:8081/ I get redirected to http://localhost:8081/null. log4j does not output anything that may help.
This is my shiro.ini file:
[main]
sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
securityManager.sessionManager = $sessionManager
securityManager.sessionManager.globalSessionTimeout = 86400000
oidcConfig = org.pac4j.oidc.config.OidcConfiguration
oidcConfig.discoveryURI = http://localhost:8080/auth/realms/Test/.well-known/openid-configuration
oidcConfig.clientId = Zeppelin
oidcConfig.secret = e15b220e-9b3c-4997-9a76-81086e3e1ca3
oidcConfig.clientAuthenticationMethodAsString = client_secret_basic
oidcClient = org.pac4j.oidc.client.OidcClient
oidcClient.configuration = $oidcConfig
clients = org.pac4j.core.client.Clients
clients.callbackUrl = http://localhost:8081/api/callback
clients.clients = $oidcClient
requireRoleAdmin = org.pac4j.core.authorization.authorizer.RequireAnyRoleAuthorizer
config = org.pac4j.core.config.Config
config.clients = $clients
pac4jRealm = io.buji.pac4j.realm.Pac4jRealm
pac4jSubjectFactory = io.buji.pac4j.subject.Pac4jSubjectFactory
securityManager.subjectFactory = $pac4jSubjectFactory
oidcSecurityFilter = io.buji.pac4j.filter.SecurityFilter
oidcSecurityFilter.config = $config
oidcSecurityFilter.clients = oidcClient
callbackFilter = io.buji.pac4j.filter.CallbackFilter
callbackFilter.defaultUrl = http://localhost:8081
callbackFilter.config = $config
[urls]
/api/version = anon
/api/callback = callbackFilter
/** = oidcSecurityFilter

Add resolver will help redirect to the right oidc path
ajaxRequestResolver = org.pac4j.core.http.ajax.DefaultAjaxRequestResolver
ajaxRequestResolver.addRedirectionUrlAsHeader = true
oidcClient.ajaxRequestResolver = $ajaxRequestResolver

I believe this is a bug in one of the libraries. You could try to use specific versions of the underlying dependencies. This is the combination that helped me to solve this null problem:
https://repo1.maven.org/maven2/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar
https://repo1.maven.org/maven2/com/nimbusds/lang-tag/1.5/lang-tag-1.5.jar
https://repo1.maven.org/maven2/net/minidev/json-smart/2.4.7/json-smart-2.4.7.jar
https://repo1.maven.org/maven2/com/nimbusds/oauth2-oidc-sdk/9.9/oauth2-oidc-sdk-9.9.jar
https://repo1.maven.org/maven2/com/nimbusds/content-type/2.1/content-type-2.1.jar
https://repo1.maven.org/maven2/javax/mail/mail/1.4.7/mail-1.4.7.jar
https://repo1.maven.org/maven2/io/buji/buji-pac4j/5.0.1/buji-pac4j-5.0.1.jar
https://repo1.maven.org/maven2/org/pac4j/pac4j-core/4.0.3/pac4j-core-4.0.3.jar
https://repo1.maven.org/maven2/org/pac4j/pac4j-oidc/4.0.3/pac4j-oidc-4.0.3.jar

Related

How to use terraform to enable Managed private endpoint on datafactory azure sql database linked service

I am trying to use terraform to create adf linked services however the terraform resource doesn't give the option to select an already existing managed private endpoint for the linked service to communicate over but when creating from the portal, this is possible. bellow is my code
resource "azurerm_data_factory" "process-adf" {
resource_group_name = module.resourcegroup.resource_group.name
location = module.resourcegroup.resource_group.location
name = "adf"
managed_virtual_network_enabled = true
public_network_enabled = false
tags = var.tags
identity {
type = "SystemAssigned"
}
}
resource "azurerm_data_factory_linked_service_azure_sql_database" "process-mssql-adf" {
name = "mssql-adf"
data_factory_id = azurerm_data_factory.process-adf.id
integration_runtime_name = azurerm_data_factory_integration_runtime_azure.adf.id
connection_string = "data source=servername;initial catalog=databasename;user id=admin;Password=password;integrated security=True;encrypt=True;connection timeout=30"
}
resource "azurerm_data_factory_managed_private_endpoint" "adf-msssql-pe" {
name = "adf"
data_factory_id = azurerm_data_factory.process-adf.id
target_resource_id = azurerm_mssql_server.process-control.id
subresource_name = "sqlServer"
}
resource "azurerm_data_factory_integration_runtime_azure" "adf" {
name = "adf"
data_factory_id = azurerm_data_factory.process-adf.id
location = module.resourcegroup.resource_group.location
virtual_network_enabled = true
}
how do i point the resource azurerm_data_factory_linked_service_azure_sql_database to the resource azurerm_data_factory_managed_private_endpoint ?

Create database schema with terraform

I created RDS instance using aws_db_instance (main.tf):
resource "aws_db_instance" "default" {
identifier = "${module.config.database["db_inst_name"]}"
allocated_storage = 20
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t3.micro"
name = "${module.config.database["db_name_prefix"]}${terraform.workspace}"
username = "${module.config.database["db_username"]}"
password = "${module.config.database["db_password"]}"
parameter_group_name = "default.mysql5.7"
skip_final_snapshot = true
}
Can I also create database schemas from file schema.sql with terraform apply?
$ tree -L 1
.
├── main.tf
└── schema.sql
You can use a provisioner (https://www.terraform.io/docs/provisioners/index.html) for that:
resource "aws_db_instance" "default" {
identifier = module.config.database["db_inst_name"]
allocated_storage = 20
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t3.micro"
name = "${module.config.database["db_name_prefix"]}${terraform.workspace}"
username = module.config.database["db_username"]
password = module.config.database["db_password"]
parameter_group_name = "default.mysql5.7"
skip_final_snapshot = true
provisioner "local-exec" {
command = "mysql --host=${self.address} --port=${self.port} --user=${self.username} --password=${self.password} < ./schema.sql"
}
}
#Apply scheme by using bastion host
resource "aws_db_instance" "default_bastion" {
identifier = module.config.database["db_inst_name"]
allocated_storage = 20
storage_type = "gp2"
engine = "mysql"
engine_version = "5.7"
instance_class = "db.t3.micro"
name = "${module.config.database["db_name_prefix"]}${terraform.workspace}"
username = module.config.database["db_username"]
password = module.config.database["db_password"]
parameter_group_name = "default.mysql5.7"
skip_final_snapshot = true
provisioner "file" {
connection {
user = "ec2-user"
host = "bastion.example.com"
private_key = file("~/.ssh/ec2_cert.pem")
}
source = "./schema.sql"
destination = "~"
}
provisioner "remote-exec" {
connection {
user = "ec2-user"
host = "bastion.example.com"
private_key = file("~/.ssh/ec2_cert.pem")
}
command = "mysql --host=${self.address} --port=${self.port} --user=${self.username} --password=${self.password} < ~/schema.sql"
}
}
mysql client needs to be installed on your device.
If you don't have direct access to your DB, there is also a remote-exec provisioner, where you can use a bastion host (transfer file to remote place with file provisioner first).
If your schema is not to complex, you could also use the MySQL provider of terraform:
https://www.terraform.io/docs/providers/mysql/index.html

Terraform Error: vsphere provider doesn’t support resource

I have a small issue, my terraform code is saying the vsphere provider does not support a vsphere_instance resource.
When I run terraform plan, I get:
1 error(s) occurred:
*vsphere_instance.node1: Provider doesn’t support resource: vsphere_instance
Terraform template:
provider "vsphere" {
user = "andm"
password = "Welcome123!"
vsphere_server = "vcenter1.domain.com"
allow_unverified_ssl = true
}
resource "vsphere_instance" "node1" {
name = "node1.domain.com"
vcpu = 4
memory = 4096
time_zone = "040"
domain = "hosting.domain.com"
dns_servers = ["8.8.8.8"]
disk {
datastore = "WS006_LUN_197"
vmdk = "templates_01/AV_W2K8_Tmlate/AV_W2K8_Template.vmdk"
type = "thin"
}
network_interface {
ipv4_address = "192.168.0.1"
ipv4_gateway = "192.168.1.1"
ipv4_prefix_length = "24"
}
}
Can you change the resource name from vspher_instance to vsphere_virtual_machine
This should fix your issue.
https://www.terraform.io/docs/providers/vsphere/index.html
VMWARE VSPHERE PROVIDER
RESOURCES
vsphere_virtual_machine
vsphere_folder
vsphere_file
vsphere_virtual_disk

Copy DNN HTML Pro module in content to another module

Below code is working fine for HTML module but not working for HTML PRO module.
HtmlTextController htmlTextController = new HtmlTextController();
WorkflowStateController workflowStateController = new WorkflowStateController();
int workflowId = htmlTextController.GetWorkflow(ModuleId, TabId, PortalId).Value;
List<HtmlTextInfo> htmlContents = htmlTextController.GetAllHtmlText(ModuleModId);
htmlContents = htmlContents.OrderBy(c => c.Version).ToList();
foreach (var content in htmlContents)
{
HtmlTextInfo htmlContent = new HtmlTextInfo();
htmlContent.ItemID = -1;
htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowId);
htmlContent.WorkflowID = workflowId;
htmlContent.ModuleID = ModuleId;
htmlContent.IsPublished = content.IsPublished;
htmlContent.Approved = content.Approved;
htmlContent.IsActive = content.IsActive;
htmlContent.Content = content.Content;
htmlContent.Summary = content.Summary;
htmlContent.Version = content.Version;
}
htmlTextController.UpdateHtmlText(htmlContent, htmlTextController.GetMaximumVersionHistory(PortalId));
This is occurred due to HTML Pro module has different methods. That is partially different from DNN HTML Module. below is the code.
HtmlTextController htmlTextController = new HtmlTextController();
WorkflowStateController workflowStateController = new WorkflowStateController();
WorkflowStateInfo wsinfo = new WorkflowStateInfo();
int workflowId = wsinfo.WorkflowID;
HtmlTextInfo htmlContents = htmlTextController.GetLatestHTMLContent(ModuleModId);
HtmlTextInfo htmlContent = new HtmlTextInfo();
htmlContent.ItemID = -1;
htmlContent.StateID = workflowStateController.GetFirstWorkflowStateID(workflowId);
htmlContent.WorkflowID = workflowId;
htmlContent.ModuleID = ModuleId;
htmlContent.IsPublished = htmlContents.IsPublished;
htmlContent.Approved = htmlContents.Approved;
htmlContent.IsActive = htmlContents.IsActive;
htmlContent.Content = htmlContents.Content;
htmlContent.Summary = htmlContents.Summary;
htmlContent.Version = htmlContents.Version;
if (Tags != null && Tags.Count > 0)
{
foreach (KeyValuePair<string, string> tag in Tags)
{
if (htmlContent.Content.Contains(tag.Key))
{
htmlContent.Content = htmlContent.Content.Replace(tag.Key, tag.Value);
}
}
}
htmlTextController.SaveHtmlContent(htmlContent, newModule);
And please add below reference to the code to refer the methods.
using DotNetNuke.Modules.HtmlPro;
using DotNetNuke.Professional.HtmlPro;
using DotNetNuke.Professional.HtmlPro.Components;
using DotNetNuke.Professional.HtmlPro.Services;
If you are looking to simply "copy" the content from one to the other, you might investigate the usage of the "Import" and "Export" functions that are part of these modules.
I recommend using this route to help you ensure better compatibility as time progresses. Should they update fields or other data elements you will not have to investigate and then update your code as part of this.
You can simply look at the .dnn manifest for each of these modules and find the BusinessControllerClass which will have two methods "ImportModule" and "ExportModule" that you could use.

Accessing a database through codeigniter based on login

I have a functionality as follows:
When Any user logs in I want to connect to a particular DB based on login credentials
.
I tried with
$this->db->close();
and this->db->reconnect();
but it did not help
In your application/config/database.php you can define more than one database connection by doing
$db['database1']['hostname'] = 'localhost';
$db['database1']['username'] = 'db1_root';
$db['database1']['password'] = 'xxxxxx';
$db['database1']['database'] = 'database1_name';
$db['database1']['db_debug'] = false; //Important
$db['database2']['hostname'] = 'localhost';
$db['database2']['username'] = 'db2_root';
$db['database2']['password'] = 'xxxxxx';
$db['database2']['database'] = 'database2_name';
$db['database2']['db_debug'] = false; //Important
Then you can load specific databases by doing
$database1 = $this->load->database('database1', true);
$database2 = $this->load->database('database2', true);
Then rather than doing
$this->db->query();
You will need to do either
$database1->query();
$database2->query();
You can connect using a dynamic config in your controller/model/library/whatever by passing a config array to $this->load->database().
$config['hostname'] = "localhost";
$config['username'] = $user_name;
$config['password'] = $user_password;
$config['database'] = $user_database;
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$user_db = $this->load->database($config, true);
I figured out my answer.. Coded as follows:
in the database.php file i have added a new database config:
$db['db2']=$db['default'];
$db['db2']['database'] = 'new_db2';
and then in all the models constructor function i have put the following code:
$new_db = $this->load->database('db2', TRUE );
$this->db = $new_db;
So in this case i don't need to change all my queries. Hurray!!! :)

Resources