2016-07-18 2 views
0

누구든지 CAS (초보자)와 함께 이해할 수 없도록 도와 줄 수 있습니까? URL이 http://localhost/program/phpcas/CodeIgniter-3.0.6/인데, 누구도 URL이/http://localhost:8080/cas의 SSO CAS를 사용하여 리디렉션해야하는 경우입니다.CAS 4.0 서비스 관리 웹 응용 프로그램 - 응용 프로그램이 CAS를 사용하도록 승인되지 않았습니다.

응용 프로그램이 아닙니다 CAS

응용 프로그램을 사용할 수있는 권한이 권한이 없습니다에 인증을 시도 : 나는 캐스에서 메시지 오류가 발생했습니다 http://localhost/program/phpcas/CodeIgniter-3.0.6/에 액세스하는 경우

는하지만 난은 문제가 CAS를 사용합니다. 여기

가 CAS 코드입니다 :

ServiceManagementWebApplication-52497044623301.json

{ 
    "@class" : "org.jasig.cas.services.RegexRegisteredService", 
    "serviceId" : "^http://localhost/program/phpcas/CodeIgniter-3.0.6/", 
    "name" : "Services Management Web Application", 
    "id" : 52497044623301, 
    "description" : "Services Management Web Application", 
} 

propertyFileConfigurer.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:util="http://www.springframework.org/schema/util" 
     xmlns="http://www.springframework.org/schema/beans" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> 
    <description> 
     This file lets CAS know where you've stored the cas.properties file which details some of the configuration 
     options 
     that are specific to your environment. You can specify the location of the file here. You may wish to place the 
     file outside 
     of the Servlet context if you have options that are specific to a tier (i.e. test vs. production) so that the 
     WAR file 
     can be moved between tiers without modification. 
    </description> 

    <util:properties id="casProperties" location="${cas.properties.config.location:/WEB-INF/cas.properties}"/> 

    <context:property-placeholder properties-ref="casProperties"/> 

</beans> 
다음

PHPCAS이 URL에 대한 CI3을 사용하고 :

설정/cas.php

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
$config['cas_server_url'] = 'http://localhost:8080/cas'; 
$config['phpcas_path'] = 'application/libraries/phpcas/source'; 
$config['cas_disable_server_validation'] = TRUE; 

라이브러리/cas.php

<?php 
if (! defined('BASEPATH')) exit('No direct script access allowed'); 

function cas_show_config_error(){ 
    show_error("CAS authentication is not properly configured.<br /><br /> 
    Please, check your configuration for the following file: 
    <code>config/cas.php</code> 
    The minimum configuration requires: 
    <ul> 
     <li><em>cas_server_url</em>: the <strong>URL</strong> of your CAS server</li> 
     <li><em>phpcas_path</em>: path to a installation of 
      <a href=\"https://wiki.jasig.org/display/CASC/phpCAS\">phpCAS library</a></li> 
     <li>and one of <em>cas_disable_server_validation</em> and <em>cas_ca_cert_file</em>.</li> 
    </ul> 
    "); 
} 
class Cas { 
    public function __construct(){ 
     if (!function_exists('curl_init')){ 
      show_error('<strong>ERROR:</strong> You need to install the PHP module 
       <strong><a href="http://php.net/curl">curl</a></strong> to be able 
       to use CAS authentication.'); 
     } 
     $CI =& get_instance(); 
     $this->CI = $CI; 
     $CI->config->load('cas'); 
     $this->phpcas_path = $CI->config->item('phpcas_path'); 
     $this->cas_server_url = $CI->config->item('cas_server_url'); 
     if (empty($this->phpcas_path) 
      or filter_var($this->cas_server_url, FILTER_VALIDATE_URL) === FALSE) { 
      cas_show_config_error(); 
     } 
     $cas_lib_file = $this->phpcas_path . '/CAS.php'; 
     if (!file_exists($cas_lib_file)){ 
      show_error("<strong>ERROR:</strong> Could not find a file <em>CAS.php</em> in directory 
       <strong>$this->phpcas_path</strong><br /><br /> 
       Please, check your config file <strong>config/cas.php</strong> and make sure the 
       configuration <em>phpcas_path</em> is a valid phpCAS installation."); 
     } 
     require_once $cas_lib_file; 
     if ($CI->config->item('cas_debug')) { 
      phpCAS::setDebug(); 
     } 
     // init CAS client 
     $defaults = array('path' => '', 'port' => 443); 
     $cas_url = array_merge($defaults, parse_url($this->cas_server_url)); 
     phpCAS::client(CAS_VERSION_2_0, $cas_url['host'], 
      $cas_url['port'], $cas_url['path']); 
     // configures SSL behavior 
     if ($CI->config->item('cas_disable_server_validation')){ 
      phpCAS::setNoCasServerValidation(); 
     } else { 
      $ca_cert_file = $CI->config->item('cas_server_ca_cert'); 
      if (empty($ca_cert_file)) { 
       cas_show_config_error(); 
      } 
      phpCAS::setCasServerCACert($ca_cert_file); 
     } 
    } 
    /** 
     * Trigger CAS authentication if user is not yet authenticated. 
     */ 
    public function force_auth() 
    { 
     phpCAS::forceAuthentication(); 
    } 
    /** 
    * Return 
    */ 
    public function user() 
    { 
     if (phpCAS::isAuthenticated()) { 
      $userlogin = phpCAS::getUser(); 
      $attributes = phpCAS::getAttributes(); 
      return (object) array('userlogin' => $userlogin, 
       'attributes' => $attributes); 
     } else { 
      show_error("User was not authenticated yet."); 
     } 
    } 
    /** 
    * Logout and redirect to the main site URL, 
    * or to the URL passed as argument 
    */ 
    public function logout($url = '') 
    { 
     if (empty($url)) { 
      $this->CI->load->helper('url'); 
      $url = base_url(); 
     } 
     phpCAS::logoutWithRedirectService($url); 
    } 
    public function is_authenticated() 
    { 
     return phpCAS::isAuthenticated(); 
    } 
} 

컨트롤러

public function index(){ 
    $this->load->library('cas'); 
    $this->cas->force_auth(); 
    $user = $this->cas->user(); 
    echo "<h1>Hello, $user->userlogin!</h1>"; 
} 

제발, 당신은 방법을 알고있는 경우 고칠 수 있니?

답변

0

CAS 4.0.x를 사용하는 경우 deployerConfigContext.xml에서 서비스를 인증해야합니다. src/main/webapp/WEBINF /에 있습니다. 파일에는 여러 기본 구성이 있습니다. 데모 목적으로 cas을 오픈 모드 serviceId="^(https?|imaps?)://.* (추천하지 않음)으로 사용하십시오.

관련 문제