Grailsフォーラムアプリケーションのチュートリアルは、http://grails.asia/grails-forum-applicationです。Grailsでのアプリケーションへのアクセスが拒否されている
私はspring-security-core:spring-security-coreの代わりに2.0.0プラグインを使用していることを除いて、それが持っているものを正確に行っています:チュートリアル(1.2.7.3)上記)。
私がログインしようとすると:私はこのエラーを取得する:
"Sorry, you're not authorized to view this page"
は、私は、コンソールは、トレースを与えないようにエラーが正確に何であるかわかりません。
私はGGTS Groovy/Grails Tool Suiteバージョン:3.6.4.RELEASEをUbuntu Linux 16.04で使用しています。
私が使用していたコードは、githubの上でとのリンクに記載されている同じコード(https://github.com/grailsasia/grails-ex-forum)
私が間違って何をやっているのですか?アプリケーションが生成しているユーザー名とパスワードを使用していても、アプリケーションからアクセスが拒否されています。
class BootStrap {
def random = new Random();
def words = ("time,person,year,way,day,thing,man,world,life,hand,part,child,eye,woman,place,work,week,case,point," +
"government,company,number,group,problem,fact,be,have,do,say,get,make,go,know,take,see,come,think,look," +
"want,give,use,find,tell,ask,work,seem,feel,try,leave,call,good,new,first,last,long,great,little,own," +
"other,old,right,big,high,different,small,large,next,early,young,important,few,public,bad,same,able,to,of," +
"in,for,on,with,at,by,from,up,about,into,over,after,beneath,under,above,the,and,a,that,I,it,not,he,as,you," +
"this,but,his,they,her,she,or,an,will,my,one,all,would,there,their").split(",")
def init = { servletContext ->
if (SecUser.count() == 0) { // no user in db, lets create some
def defaultRole = new SecRole(authority: 'ROLE_USER').save()
// create 100 users
(1..100).each { userNo ->
String username = "user${userNo}"
def user = new SecUser(username:username, password: 'secret', enabled: true).save()
// all users will have default role
new SecUserSecRole(secUser:user, secRole: defaultRole).save()
}
}
if (Section.count() == 0) { // create data if no forum data found
// get all users
def users = SecUser.list()
// create 3 sections
('A'..'C').each { sectionLetter ->
def sectionTitle = "Section ${sectionLetter}"
def section = new Section(title: sectionTitle).save()
// create 4 topics per section
(1..4).each { topicNumber ->
def topicTitle = "Topic ${sectionLetter}-${topicNumber}"
def topicDescription = "Description of ${topicTitle}"
def topic = new Topic(section: section, title: topicTitle, description: topicDescription).save()
// create 10-20 threads each topic
def numberOfThreads = random.nextInt(11)+10
(1..numberOfThreads).each { threadNo ->
def opener = users[random.nextInt(100)]
def subject = "Subject ${sectionLetter}-${topicNumber}-${threadNo} "
def thread = new DiscussionThread(topic:topic, subject:subject, opener:opener).save()
new Comment(thread:thread, commentBy:opener, body:generateRandomComment()).save()
// create 10-35 replies per thread
def numberOfReplies = random.nextInt(26)+10
numberOfReplies.times {
def commentBy = users[random.nextInt(100)]
new Comment(thread:thread, commentBy:commentBy, body:generateRandomComment()).save()
}
}
}
}
}
}
private String generateRandomComment() {
def numberOfWords = random.nextInt(50) + 15
StringBuilder sb = new StringBuilder()
numberOfWords.times {
def randomWord = words[random.nextInt(words.length)]
sb.append("${randomWord} ")
}
return sb.toString()
}
def destroy = {
}
}
私は何が起こっているかを把握するために私ができる最善を尽くしています: - ここ
は私が(ストレートチュートリアル自体から再び)のデータをロードするために使用していますBootstrap.groovyのコードですしかし、問題の内容に関するエラーメッセージが表示されず、チュートリアルではその理由を理解できません。
UPDATE !!
私が受け取った返事を見てから、チュートリアルをもう一度見て、リンクに投稿して、問題が実際に許可された役割とアクセスのリストに関連していることがわかりました。ここで
は、私が一緒にプレイし、より多くを理解する必要が許可のアクセス/役割/リソースのリストは以下のとおりです。積極的に私は自分自身を助け、新しいスキルを獲得する助けに貢献し、すべての
// Added by the Spring Security Core plugin: grails.plugin.springsecurity.userLookup.userDomainClassName = 'furqanforum.SecUser' grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'furqanforum.SecUserSecRole' grails.plugin.springsecurity.authority.className = 'furqanforum.SecRole' grails.plugin.springsecurity.controllerAnnotations.staticRules = [ '/': ['permitAll'], '/forum/**': ['permitAll'], '/index': ['permitAll'], '/index.gsp': ['permitAll'], '/assets/**': ['permitAll'], '/**/js/**': ['permitAll'], '/**/css/**': ['permitAll'], '/**/images/**': ['permitAll'], '/**/favicon.ico': ['permitAll'], '/login/**': ['permitAll'], '/logout/**': ['permitAll'] ]
ありがとう!
私は春のセキュリティと調整についてもっと読んでおり、私は学びます。しかし、チェックされた答えと回答と提案に基づいて、これは私の問題を解決しました
参照してください...これはまさに私が意味するものです。なぜこの投稿は投票されたのですか?なぜそれがダウン投票されているのか、少なくとも最悪の状態。このような恣意的な行動は成長を助長するものではなく、このような場所への奨励を促進するものでもありません。 – ironmantis7x
もし私があなたを助けてくれたらおそらくなぜあまりにも多くの下降気味があるのか分かりません。なぜなら、質問の角度は簡単ではなく、答えは比較的シンプルだからです。ここでの問題は春の安全保障と深いところですチュートリアルを行う前にgrails spring securityについての読み物を読む必要があるかもしれません - あなたは春のセキュリティデバッグログを使って何をしているのかを知ることができ、生成された静的ルールを見直して、/** permitAllルールにアクセス権を与える - msgは春のセキュリティをブロックするページ – Vahid
このチュートリアルでは、作成した春のセキュリティのバージョンで、期待通りに動作しますか? – doelleri