Changeset 1364


Ignore:
Timestamp:
Jan 11, 2011, 5:25:35 PM (6 years ago)
Author:
work@…
Message:
  • and another one for issue #219, moved authentication to the environment specific configuration files
Location:
trunk/grails-app/conf
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrapAuthentication.groovy

    r1120 r1364  
    11import dbnp.authentication.*
     2import org.codehaus.groovy.grails.commons.ConfigurationHolder
    23
    34/**
     
    1920                "setting up default authentication".grom()
    2021
     22                // user work variable
     23                def user=null
     24
     25                // get configuration
     26                def config = ConfigurationHolder.config
     27
     28                // create the admin role
    2129                def adminRole = SecRole.findByAuthority('ROLE_ADMIN') ?: new SecRole(authority: 'ROLE_ADMIN').save()
    22                 def user = SecUser.findByUsername('user') ?: new SecUser(
    23                         username: 'user',
    24                         password: springSecurityService.encodePassword('useR123!', 'user'),
    25                         email: 'user@dbnp.org',
    26                         userConfirmed: true, adminConfirmed: true).save(failOnError: true)
    27                 def userTest = SecUser.findByUsername('test') ?: new SecUser(
    28                         username: 'test',
    29                         password: springSecurityService.encodePassword('useR123!', 'test'),
    30                         email: 'test@dbnp.org',
    31                         userConfirmed: true, adminConfirmed: true).save(failOnError: true)
    32                 def userAdmin = SecUser.findByUsername('admin') ?: new SecUser(
    33                         username: 'admin',
    34                         password: springSecurityService.encodePassword('admiN123!', 'admin'),
    35                         email: 'admin@dbnp.org',
    36                         userConfirmed: true, adminConfirmed: true).save(failOnError: true)
    3730
    38                 // Make the admin user an administrator
    39                 SecUserSecRole.create userAdmin, adminRole, true
     31                // iterate through default users, see
     32                //      - grails-app/conf/config-environment.properties
     33                //      - ~/.grails-config/environment-gscf.properties
     34                config.authentication.users.each { key, values ->
     35                        // make sure we do not add duplicate users
     36                        if (!SecUser.findAllByUsername(values.username)) {
     37                                // create user instance
     38                                user = new SecUser(
     39                                        username:values.username,
     40                                        password:springSecurityService.encodePassword( values.password , values.username ),
     41                                        email:values.email,
     42                                        userConfirmed: true,
     43                                        adminConfirmed: true
     44                                ).save(failOnError: true)
     45
     46                                // is this user an administrator?
     47                                if (values.administrator == 'true') {
     48                                        SecUserSecRole.create(user, adminRole, true)
     49                                }
     50                        }
     51                }
    4052        }
    4153}
  • trunk/grails-app/conf/config-ci.properties

    r1363 r1364  
    3030modules.metabolomics.url=http://ci.metabolomics.nmcdsp.org
    3131modules.metagenomics.url=http://ci.metagenomics.nmcdsp.org
     32
     33# default application users
     34authentication.users.admin.username=admin
     35authentication.users.admin.password=admiN123!
     36authentication.users.admin.email=admin@dbnp.org
     37authentication.users.admin.administrator=true
     38authentication.users.user.username=user
     39authentication.users.user.password=useR123!
     40authentication.users.user.email=user@dbnp.org
     41authentication.users.user.administrator=false
  • trunk/grails-app/conf/config-dbnpdemo.properties

    r1363 r1364  
    3030modules.metabolomics.url=http://demo.metabolomics.dbnp.org
    3131modules.metagenomics.url=http://demo.metagenomics.dbnp.org
     32
     33# default application users
     34authentication.users.admin.username=admin
     35authentication.users.admin.password=admiN123!
     36authentication.users.admin.email=admin@dbnp.org
     37authentication.users.admin.administrator=true
     38authentication.users.user.username=user
     39authentication.users.user.password=useR123!
     40authentication.users.user.email=user@dbnp.org
     41authentication.users.user.administrator=false
  • trunk/grails-app/conf/config-dbnptest.properties

    r1363 r1364  
    3030modules.metabolomics.url=http://test.metabolomics.dbnp.org
    3131modules.metagenomics.url=http://test.metagenomics.dbnp.org
     32
     33# default application users
     34authentication.users.admin.username=admin
     35authentication.users.admin.password=admiN123!
     36authentication.users.admin.email=admin@dbnp.org
     37authentication.users.admin.administrator=true
     38authentication.users.user.username=user
     39authentication.users.user.password=useR123!
     40authentication.users.user.email=user@dbnp.org
     41authentication.users.user.administrator=false
  • trunk/grails-app/conf/config-development.properties

    r1363 r1364  
    2929modules.metabolomics.url=http://localhost:8183/nmcdsp
    3030modules.metagenomics.url=http://localhost:8184/metagenomics
     31
     32# default application users
     33authentication.users.admin.username=admin
     34authentication.users.admin.password=admiN123!
     35authentication.users.admin.email=admin@dbnp.org
     36authentication.users.admin.administrator=true
     37authentication.users.user.username=user
     38authentication.users.user.password=useR123!
     39authentication.users.user.email=user@dbnp.org
     40authentication.users.user.administrator=false
  • trunk/grails-app/conf/config-production.properties

    r1363 r1364  
    3030modules.metabolomics.url=http://metabolomics.nmcdsp.org
    3131modules.metagenomics.url=http://metagenomics.nmcdsp.org
     32
     33# default application users
     34authentication.users.admin.username=admin
     35authentication.users.admin.password=admiN123!
     36authentication.users.admin.email=admin@dbnp.org
     37authentication.users.admin.administrator=true
     38authentication.users.user.username=user
     39authentication.users.user.password=useR123!
     40authentication.users.user.email=user@dbnp.org
     41authentication.users.user.administrator=false
  • trunk/grails-app/conf/config-test.properties

    r1363 r1364  
    3030modules.metabolomics.url=http://test.metabolomics.nmcdsp.org
    3131modules.metagenomics.url=http://test.metagenomics.nmcdsp.org
     32
     33# default application users
     34authentication.users.admin.username=admin
     35authentication.users.admin.password=admiN123!
     36authentication.users.admin.email=admin@dbnp.org
     37authentication.users.admin.administrator=true
     38authentication.users.user.username=user
     39authentication.users.user.password=useR123!
     40authentication.users.user.email=user@dbnp.org
     41authentication.users.user.administrator=false
  • trunk/grails-app/conf/config-www.properties

    r1363 r1364  
    3030modules.metabolomics.url=http://metabolomics.nmcdsp.org
    3131modules.metagenomics.url=http://metagenomics.nmcdsp.org
     32
     33# default application users
     34authentication.users.admin.username=admin
     35authentication.users.admin.password=admiN123!
     36authentication.users.admin.email=admin@dbnp.org
     37authentication.users.admin.administrator=true
     38authentication.users.user.username=user
     39authentication.users.user.password=useR123!
     40authentication.users.user.email=user@dbnp.org
     41authentication.users.user.administrator=false
Note: See TracChangeset for help on using the changeset viewer.