<commit_before>#
# Cookbook Name:: wt_sauth
# Recipe:: cam_auth
# Author: <NAME>(<<EMAIL>>)
#
# Copyright 2012, Webtrends
#
# All rights reserved - Do Not Redistribute
# This recipe installs the Auth IIS app component of CAM

if ENV["deploy_build"] == "true" then
  include_recipe "ms_dotnet4::regiis"
  include_recipe "wt_sauth::uninstall"
  include_recipe "wt_cam::uninstall"
end

#Properties
install_dir = "#{node['wt_common']['install_dir_windows']}\\Webtrends.Auth"
install_logdir = node['wt_common']['install_log_dir_windows']
log_dir = "#{node['wt_common']['install_dir_windows']}\\logs"
app_pool = node['wt_sauth']['app_pool']
user_data = data_bag_item('authorization', node.chef_environment)
auth_cmd = "/section:applicationPools /[name='#{app_pool}'].processModel.identityType:SpecificUser /[name='#{app_pool}'].processModel.userName:#{user_data['wt_common']['ui_user']} /[name='#{app_pool}'].processModel.password:#{user_data['wt_common']['ui_pass']}"
http_port = node['wt_sauth']['port']

iis_pool app_pool do
    pipeline_mode :Integrated
    runtime_version "4.0"
    action [:add, :config]
end

iis_site 'Default Web Site' do
	action [:stop, :delete]
end

iis_pool 'DefaultAppPool' do
    action [:stop, :delete]
end

directory install_dir do
	recursive true
	action :create
end

directory log_dir do
	recursive true
	action :create
end

iis_site 'AUTH' do
    protocol :http
    port http_port
	application_pool app_pool
    path install_dir
	action [:add,:start]
	retries 1
end


wt_base_firewall 'AUTHWS' do
    protocol "TCP"
    port http_port
    action [:open_port]
 end

wt_base_icacls install_dir do
	action :grant
	user user_data['wt_common']['ui_user']
	perm :modify
end

wt_base_icacls log_dir do
	action :grant
	user user_data['wt_common']['ui_user']
	perm :modify
end

if ENV["deploy_build"] == "true" then
  windows_zipfile install_dir do
    source node['wt_sauth']['download_url']
    action :unzip
  end

  template "#{install_dir}\\web.config" do
  	source "web.config.erb"
	variables(
		:db_server => node['wt_cam']['db_server'],
		:db_name   => node['wt_cam']['db_name'],
                :tokenExpirationMinutes => node['wt_sauth']['tokenExpirationMinutes'],
        	:machine_validation_key => user_data['wt_iis']['machine_validation_key'],
	        :machine_decryption_key => user_data['wt_iis']['machine_decryption_key']<commit_msg>	added anonymous access for scripts/css<commit_after>#
# Cookbook Name:: wt_sauth
# Recipe:: cam_auth
# Author: <NAME>(<<EMAIL>>)
#
# Copyright 2012, Webtrends
#
# All rights reserved - Do Not Redistribute
# This recipe installs the Auth IIS app component of CAM

if ENV["deploy_build"] == "true" then
  include_recipe "ms_dotnet4::regiis"
  include_recipe "wt_sauth::uninstall"
  include_recipe "wt_cam::uninstall"
end

#Properties
install_dir = "#{node['wt_common']['install_dir_windows']}\\Webtrends.Auth"
install_logdir = node['wt_common']['install_log_dir_windows']
log_dir = "#{node['wt_common']['install_dir_windows']}\\logs"
app_pool = node['wt_sauth']['app_pool']
user_data = data_bag_item('authorization', node.chef_environment)
auth_cmd = "/section:applicationPools /[name='#{app_pool}'].processModel.identityType:SpecificUser /[name='#{app_pool}'].processModel.userName:#{user_data['wt_common']['ui_user']} /[name='#{app_pool}'].processModel.password:#{user_data['wt_common']['ui_pass']}"
http_port = node['wt_sauth']['port']

iis_pool app_pool do
    pipeline_mode :Integrated
    runtime_version "4.0"
    action [:add, :config]
end

iis_site 'Default Web Site' do
	action [:stop, :delete]
end

iis_pool 'DefaultAppPool' do
    action [:stop, :delete]
end

directory install_dir do
	recursive true
	action :create
end

directory log_dir do
	recursive true
	action :create
end

iis_site 'AUTH' do
    protocol :http
    port http_port
	application_pool app_pool
    path install_dir
	action [:add,:start]
	retries 1
end


wt_base_firewall 'AUTHWS' do
    protocol "TCP"
    port http_port
    action [:open_port]
 end

wt_base_icacls install_dir do
	action :grant
	user user_data['wt_common']['ui_user']
	perm :modify
end

# Allow anonymous access to scripts, etc
wt_base_icacls install_dir do
	action :grant
	user "IUSR"
	perm :read
end

wt_base_icacls log_dir do
	action :grant
	user user_data['wt_common']['ui_user']
	perm :modify
end

if ENV["deploy_build"] == "true" then
  windows_zipfile install_dir do
    source node['wt_sauth']['download_url']
    action :unzip
  end

  template "#{install_dir}\\web.config" do
  	source "web.config.erb"
	variables(
		:db_server => node['wt_cam']['db_server'],
		:db_name   => node['wt_cam']['db_name'],
                :tokenExpirationMinutes => node['wt_sauth']['tokenExpirationMinutes'],
        	:machine_validation_key => user_data['wt_iis']['machine_validation_key'],
	        :machine_decryption_key => user_data['wt_iis']['machine_decryption_key']
{'fraction_non_alphanumeric': 0.13533988533988534, 'fraction_numerical': 0.003276003276003276, 'mean_word_length': 5.673497267759563, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3207786', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1717, 'n_words': 368}