티스토리 툴바


Artifactory 2.2.1 "Allow Anonymous Access"에 대한 고찰

2011/03/22 19:49 | Posted by 포데브(엄지사랑) 엄지사랑
메이븐을 이용하면서 레파지토리로 Nexus나 Artifactory를 이용할 수 있다.
필자의 경우 최근엔 Nexus를 이용하고 있지만 아직도 Artifactory를 사용하는 프로젝트가 많이 있어서 종종 사용하게 된다. 

오늘은 다음과 같은 목적으로 Artifactory의 설정을 바꿔보았다.

1. 새로운 레파지토리가 필요하여 아이디를 지정하고 생성함.
2. 보안을 위해서 기존 사용자는 모든 레파지토리를 이용할 수 있지만 신규 사용자는 새로 만들어진 레파지토리만 이용하게하려고 함.
3. 사용자와 그룹 및 퍼미션을 생성하고 관계를 설정.
4. 생성된 레파지토리에 퍼미션을 할당함.
5. Admin -> Security -> General 메뉴에서 "Allow Anonymous Access"를 Unchecked 함.

기대했던 동작은 기존 사용자는 모든 레파지토리에 접근할 수 있고 신규 사용자만 새로이 생성된 레파지토리에 접근했어야 했는데 어찌된 일인지 모든 사용자에게서 

[WARNING] repository metadata for: 'snapshot kr.flowerteam.pom:BasicPOM:1.1.2-SNAPSHOT' could not be retrieved from repository: snapshots due to an error: Authorization failed: Access denied to: http://{myhost}/artifactory/repo/kr/flowerteam/pom:BasicPOM/7.13-SNAPSHOT/maven-metadata.xml 


와 같은 경고와 더불어 배포가 되지 않았다.

다음은 당시의 설정 내역이다.

setting.xml

...

<servers>
    <server>
      <id>flowerteam-rep</id>
      <username>flowerteam</username>
      <password>flowerteam</password>
    </server>
  </servers>
...



pom.xml

...
 <distributionManagement>

    <repository>
      <id>flowerteam-rep</id>
      <name>Flowerteam Releases</name>
      <url>dav:http://{myhost}/artifactory/libs-releases-local</url>
    </repository>
    <snapshotRepository>
      <id>flowerteam-rep</id>
      <name>Flowerteam Snapshots</name>
      <url>dav:http://{myhost}/artifactory/libs-snapshots-local</url>
    </snapshotRepository>
  </distributionManagement>
... 


지금까지는 Security 설정을 변경해 본적이 없어서 사용자와 패스워드만 맞으면 되는 것으로알았다. 그런데 "Allow Anonymous Access" 체크를 빼보니 그렇지 않다는 것을 알 수 있었다.

이에 대한 논의는 2010년에 많이 있었던 듯하다. 
참고: http://forums.jfrog.org/quot-Allow-Anonymous-Access-quot-only-for-selected-repos-td5469007.html
 
별다른 성과가 없었는데 

다음의 URL에서 실마리를 찾을 수 있었다.
참고: http://old.nabble.com/Authorization-failed---Access-denied-td28238554.html

중간쯤에 freddy33 이라는 사람이 답글에 보면 각각의 레파지토리는 서버 선언에 따라서 ID가 필요하다는 내용을 볼 수 가 있다. 아래는 그 내용이다.

Re: Authorization failed - Access denied

Click to flag this post 

by freddy33 Apr 14, 2010; 06:02pm :: Rate this Message:    - Use ratings to moderate (?)

Reply | Print | View Threaded | Show Only this Message

Hi,

You just need to repeat yourself :) The DRY principle does not really apply in Maven...
Every repository declaration with ID needs its corresponding server declaration. So adding:
<server>
     <id>central</id>
     <username>user1</username>
     <password><here the password encrypted></password>
</server>
<server>
     <id>snapshots</id>
     <username>user1</username>
     <password><here the password encrypted></password>
</server>

to your list of server should solve your issue.
HTH,
Fred.


그래서 위에 문제가 되었던 설정 부문을 다음과 같이 변경함으로써 해결되었다.

setting.xml

...

<servers>
    <server>
      <id>flowerteam-rep-central</id>
      <username>flowerteam</username>
      <password>flowerteam</password>
    </server>
    <server>
      <id>flowerteam-rep-snapshots</id>
      <username>flowerteam</username>
      <password>flowerteam</password>
    </server> 
  </servers>
...



pom.xml

...
 <distributionManagement>

    <repository>
      <id>flowerteam-rep-central</id>
      <name>Flowerteam Releases</name>
      <url>dav:http://{myhost}/artifactory/libs-releases-local</url>
    </repository>
    <snapshotRepository>
      <id>flowerteam-rep-snapshots</id>
      <name>Flowerteam Snapshots</name>
      <url>dav:http://{myhost}/artifactory/libs-snapshots-local</url>
    </snapshotRepository>
  </distributionManagement>
... 

저작자 표시
크리에이티브 커먼즈 라이선스
Creative Commons License

Maven Jetty JNDI 설정 WST Tomcat과 동일하게 사용하는 방법

2009/12/13 15:55 | Posted by 포데브(엄지사랑) 엄지사랑
상황: maven jetty 6.1.14 에 DataSource를 설정하고 개발환경을 구축하여 개발하는 도중 REST 로 개발되어야 할 상황이 발생하여 strusts2-rest-plugin 2.1.6으로 개발환경을 구축하였으나 동작하지 않음. 정확한 원인은 모르겠으나 Jetty 환경에서 REST 적용이 안되는 것 같아서 WST 환경으로 전환함. 이때 Jetty Server가 설치되어 있지 않은 관계로 Tomcat 6.0 으로 Server 설정을 했으나 Jetty의 JNDI 설정을 인식하지 못함.

목적: Jetty 와 Tomcat 개발환경에서 설정변경없이 동시에 개발하고 싶다.

--------
Jetty 6.1.14 에서 기본 JNDI 작업

:jetty.xml
<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC   "-//Mort Bay Consulting//DTD Configure 1.1//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
<Configure class="org.mortbay.jetty.Server">
  <New id="NEXFA_DS" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg></Arg>
    <Arg>java:NEXFA_DS</Arg>
    <Arg>
      <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
        <Set name="Url">jdbc:mysql://localhost:3306/nexfadb</Set>
        <Set name="User">nexfa</Set>
        <Set name="Password">nexfa</Set>
      </New>
    </Arg>
  </New>
</Configure>


: applicationContext.xml(spring 설정)
...
<bean id="nexfaDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName" value="java:NEXFA_DS" />
</bean>
...


: web.xml (만약 설정한다면)
...
<resource-ref>
  <description>Nexfa Mysql Datasource</description>
  <res-ref-name>java:NEXFA_DS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
...


Tomcat 6.0에서 JNDI 작업

:server.xml(tomcat 설정)
...
  <GlobalNamingResources>
    <!-- Added Resource -->
    <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" name="jdbc/NEXFA_DS"
      username="nexfa" password="nexfa" url="jdbc:mysql://localhost:3306/nexfadb?autoReconnect=true"
      logAbandoned="true" maxActive="1000" maxIdle="30" maxWait="180"  removeAbandoned="true"
      removeAbandonedTimeout="60" type="javax.sql.DataSource" />
  </GlobalNamingResources>
...

:context.xml(tomcat 설정)
<?xml version="1.0" encoding="UTF-8"?>
<Context>
    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <!-- Added -->
    <ResourceLink global="jdbc/NEXFA_DS" name="jdbc/NEXFA_DS" type="javax.sql.DataSource"/>
</Context>


: applicationContext.xml(spring 설정)
...
<bean id="nexfaDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName" value="java:comp/env/jdbc/NEXFA_DS" />
</bean>
...


: web.xml(web 설정)
...
<resource-ref>
  <description>Nexfa Mysql Datasource</description>
  <res-ref-name>jdbc/NEXFA_DS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
...


Jetty 6.1.14에서 Tomcat 6.0과 같이 작업하기

핵심은 'java:comp/env'를 인식하게 만드는것.
참조 URL : http://docs.codehaus.org/display/JETTY/JNDI

:jetty.xml
<?xml version="1.0"  encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC   "-//Mort Bay Consulting//DTD Configure 1.1//EN" "http://jetty.mortbay.org/configure_1_2.dtd">
<Configure class="org.mortbay.jetty.Server">

 
<Array id="plusConfig" type="java.lang.String">
    <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
    <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
    <Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
    <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
    <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
  </Array>

  <New id="nexfaWebAppContext"  class="org.mortbay.jetty.webapp.WebAppContext">
    <Set name="ConfigurationClasses"><Ref id="plusConfig"/></Set>
  </New>


  <New id="NEXFA_DS" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg></Arg>
    <Arg>jdbc/NEXFA_DS</Arg>
    <Arg>
      <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
        <Set name="Url">jdbc:mysql://localhost:3306/nexfadb</Set>
        <Set name="User">nexfa</Set>
        <Set name="Password">nexfa</Set>
      </New>
    </Arg>
  </New>
</Configure>


: applicationContext.xml(spring 설정)
...
<bean id="nexfaDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName" value="java:comp/env/jdbc/NEXFA_DS" />
</bean>
...


: web.xml(web 설정)
...
<resource-ref>
  <description>Nexfa Mysql Datasource</description>
  <res-ref-name>jdbc/NEXFA_DS</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>
...



위와 같이 함으로써 Tomcat 6.0과 Jetty 6.1.14에서 JNDI를 동일한 방식으로 접근할 수 있으므로 개발에 편리성을 제공한다.

결국 java:comp/env 를 어떻게 인식시키느냐가 핵심이었다는 것...

저작자 표시
크리에이티브 커먼즈 라이선스
Creative Commons License

Maven2+Jetty+SSL 적용하기

2008/07/30 13:22 | Posted by 포데브(엄지사랑) 엄지사랑
먼저 "How to configure SSL"을 참고하여 인증서를 만든다.

위의 내용은 keytool, openssl을 사용하여 ssl을 적용하는 방법을 설명하고 있다.
여기에서 keytool은 java, openssl은 non-java(Apache webserver 와 같은) 영역에 적용할 수 있다.

이 글에서는 keytool을 적용하는 방법만 설명한다. 만약 이미 인증서를 보유하고 있는 경우 위의 참고 사이트에서 "Step 3: Loading Keys and Certificates"를 참고한다.

약어:
- CA : Certificate Authority(인증기관)
- CSR : Certificate Signing Request
- RSA : Rivest-Shamir-Adleman(암호화알고리즘 및 인증 시스템)

step1. keytool 명령어를 사용하여 RSA키를 생성한다.

keytool -keystore keystore -alias jetty -genkey -keyalg RSA

step2. pom.xml의 jetty 플러그인 정보에 아래의 내용을 프로젝트 환경에 맞게 변경하여 반영한다.

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <configuration>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <connectors>
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                <port>8080</port>
                <maxIdleTime>60000</maxIdleTime>
            </connector>
            <connector implementation="org.mortbay.jetty.security.SslSocketConnector">
                <port>8443</port>
                <maxIdleTime>60000</maxIdleTime>
                <keystore>metadata/keystore</keystore><!-- 인증서키위치 -->
                <password>opcapl</password>
                <keyPassword>opcapl</keyPassword>
            </connector>
        </connectors>
    </configuration>
</plugin>

step3. 8443포트로 대기중인지 여부를 확인한다.

mvn jetty:run
...
...
2008-07-30 14:34:39.071::INFO:  Started SelectChannelConnector@0.0.0.0:8080
2008-07-30 14:34:40.865::INFO:  Started SslSocketConnector@0.0.0.0:8443
[INFO] Started Jetty Server


참고
- SSL인증서 신청(CSR, 인증요청서 작성)
요령
크리에이티브 커먼즈 라이선스
Creative Commons License
이전 1 다음